Apply black
This commit is contained in:
parent
b9357f3928
commit
55c6ab51f1
@ -212,7 +212,9 @@ class Connector:
|
|||||||
raise Exception("Loops must be between exactly two pins!")
|
raise Exception("Loops must be between exactly two pins!")
|
||||||
for pin in loop:
|
for pin in loop:
|
||||||
if pin not in self.pins:
|
if pin not in self.pins:
|
||||||
raise Exception(f'Unknown loop pin "{pin}" for connector "{self.name}"!')
|
raise Exception(
|
||||||
|
f'Unknown loop pin "{pin}" for connector "{self.name}"!'
|
||||||
|
)
|
||||||
# Make sure loop connected pins are not hidden.
|
# Make sure loop connected pins are not hidden.
|
||||||
self.activate_pin(pin)
|
self.activate_pin(pin)
|
||||||
|
|
||||||
@ -234,7 +236,7 @@ class Connector:
|
|||||||
return self.pincount
|
return self.pincount
|
||||||
elif qty_multiplier == "populated":
|
elif qty_multiplier == "populated":
|
||||||
return sum(self.visible_pins.values())
|
return sum(self.visible_pins.values())
|
||||||
elif qty_multiplier == 'unpopulated':
|
elif qty_multiplier == "unpopulated":
|
||||||
return max(0, self.pincount - sum(self.visible_pins.values()))
|
return max(0, self.pincount - sum(self.visible_pins.values()))
|
||||||
else:
|
else:
|
||||||
raise ValueError(
|
raise ValueError(
|
||||||
|
|||||||
@ -94,7 +94,7 @@ class Harness:
|
|||||||
to_pin: (int, str),
|
to_pin: (int, str),
|
||||||
) -> None:
|
) -> None:
|
||||||
# check from and to connectors
|
# check from and to connectors
|
||||||
for (name, pin) in zip([from_name, to_name], [from_pin, to_pin]):
|
for name, pin in zip([from_name, to_name], [from_pin, to_pin]):
|
||||||
if name is not None and name in self.connectors:
|
if name is not None and name in self.connectors:
|
||||||
connector = self.connectors[name]
|
connector = self.connectors[name]
|
||||||
# check if provided name is ambiguous
|
# check if provided name is ambiguous
|
||||||
@ -372,16 +372,20 @@ class Harness:
|
|||||||
)
|
)
|
||||||
manufacturer_info = pn_info_string(
|
manufacturer_info = pn_info_string(
|
||||||
HEADER_MPN,
|
HEADER_MPN,
|
||||||
|
(
|
||||||
cable.manufacturer[i - 1]
|
cable.manufacturer[i - 1]
|
||||||
if isinstance(cable.manufacturer, list)
|
if isinstance(cable.manufacturer, list)
|
||||||
else None,
|
else None
|
||||||
|
),
|
||||||
cable.mpn[i - 1] if isinstance(cable.mpn, list) else None,
|
cable.mpn[i - 1] if isinstance(cable.mpn, list) else None,
|
||||||
)
|
)
|
||||||
supplier_info = pn_info_string(
|
supplier_info = pn_info_string(
|
||||||
HEADER_SPN,
|
HEADER_SPN,
|
||||||
|
(
|
||||||
cable.supplier[i - 1]
|
cable.supplier[i - 1]
|
||||||
if isinstance(cable.supplier, list)
|
if isinstance(cable.supplier, list)
|
||||||
else None,
|
else None
|
||||||
|
),
|
||||||
cable.spn[i - 1] if isinstance(cable.spn, list) else None,
|
cable.spn[i - 1] if isinstance(cable.spn, list) else None,
|
||||||
)
|
)
|
||||||
if manufacturer_info:
|
if manufacturer_info:
|
||||||
@ -444,9 +448,11 @@ class Harness:
|
|||||||
# shield is shown with specified color and black borders, or as a thin black wire otherwise
|
# shield is shown with specified color and black borders, or as a thin black wire otherwise
|
||||||
dot.attr(
|
dot.attr(
|
||||||
"edge",
|
"edge",
|
||||||
color=":".join(["#000000", shield_color_hex, "#000000"])
|
color=(
|
||||||
|
":".join(["#000000", shield_color_hex, "#000000"])
|
||||||
if isinstance(cable.shield, str)
|
if isinstance(cable.shield, str)
|
||||||
else "#000000",
|
else "#000000"
|
||||||
|
),
|
||||||
)
|
)
|
||||||
if connection.from_pin is not None: # connect to left
|
if connection.from_pin is not None: # connect to left
|
||||||
from_connector = self.connectors[connection.from_name]
|
from_connector = self.connectors[connection.from_name]
|
||||||
@ -650,7 +656,6 @@ class Harness:
|
|||||||
graph = self.graph
|
graph = self.graph
|
||||||
return embed_svg_images(graph.pipe(format="svg").decode("utf-8"), Path.cwd())
|
return embed_svg_images(graph.pipe(format="svg").decode("utf-8"), Path.cwd())
|
||||||
|
|
||||||
|
|
||||||
def output(
|
def output(
|
||||||
self,
|
self,
|
||||||
filename: (str, Path),
|
filename: (str, Path),
|
||||||
|
|||||||
@ -116,11 +116,11 @@ def parse(
|
|||||||
autogenerated_designators = {}
|
autogenerated_designators = {}
|
||||||
|
|
||||||
# When title is not given, either deduce it from filename, or use default text.
|
# When title is not given, either deduce it from filename, or use default text.
|
||||||
if 'title' not in harness.metadata:
|
if "title" not in harness.metadata:
|
||||||
if yaml_file is None:
|
if yaml_file is None:
|
||||||
harness.metadata['title'] = "WireViz diagram and BOM"
|
harness.metadata["title"] = "WireViz diagram and BOM"
|
||||||
else:
|
else:
|
||||||
harness.metadata['title'] = Path(yaml_file).stem
|
harness.metadata["title"] = Path(yaml_file).stem
|
||||||
|
|
||||||
# add items
|
# add items
|
||||||
# parse YAML input file ====================================================
|
# parse YAML input file ====================================================
|
||||||
@ -411,6 +411,7 @@ def _get_yaml_data_and_path(inp: Union[str, Path, Dict]) -> (Dict, Path):
|
|||||||
# when trying to expand and resolve it as a path.
|
# when trying to expand and resolve it as a path.
|
||||||
# Catch this error, but raise any others
|
# Catch this error, but raise any others
|
||||||
from errno import ENAMETOOLONG
|
from errno import ENAMETOOLONG
|
||||||
|
|
||||||
if type(e) is OSError and e.errno != ENAMETOOLONG:
|
if type(e) is OSError and e.errno != ENAMETOOLONG:
|
||||||
raise e
|
raise e
|
||||||
# file does not exist; assume inp is a YAML string
|
# file does not exist; assume inp is a YAML string
|
||||||
|
|||||||
@ -36,7 +36,11 @@ def get_additional_component_table(
|
|||||||
if component.additional_components:
|
if component.additional_components:
|
||||||
rows.append(["Additional components"])
|
rows.append(["Additional components"])
|
||||||
# Ignore components that have qty 0
|
# Ignore components that have qty 0
|
||||||
for part in [part for part in component.additional_components if component.get_qty_multiplier(part.qty_multiplier)]:
|
for part in [
|
||||||
|
part
|
||||||
|
for part in component.additional_components
|
||||||
|
if component.get_qty_multiplier(part.qty_multiplier)
|
||||||
|
]:
|
||||||
common_args = {
|
common_args = {
|
||||||
"qty": part.qty * component.get_qty_multiplier(part.qty_multiplier),
|
"qty": part.qty * component.get_qty_multiplier(part.qty_multiplier),
|
||||||
"unit": part.unit,
|
"unit": part.unit,
|
||||||
@ -65,7 +69,11 @@ def get_additional_component_bom(component: Union[Connector, Cable]) -> List[BOM
|
|||||||
"""Return a list of BOM entries with additional components."""
|
"""Return a list of BOM entries with additional components."""
|
||||||
bom_entries = []
|
bom_entries = []
|
||||||
# Ignore components that have qty 0
|
# Ignore components that have qty 0
|
||||||
for part in [part for part in component.additional_components if component.get_qty_multiplier(part.qty_multiplier)]:
|
for part in [
|
||||||
|
part
|
||||||
|
for part in component.additional_components
|
||||||
|
if component.get_qty_multiplier(part.qty_multiplier)
|
||||||
|
]:
|
||||||
bom_entries.append(
|
bom_entries.append(
|
||||||
{
|
{
|
||||||
"description": part.description,
|
"description": part.description,
|
||||||
|
|||||||
@ -97,9 +97,9 @@ def generate_html_output(
|
|||||||
if isinstance(entry, Dict):
|
if isinstance(entry, Dict):
|
||||||
replacements[f"<!-- %{item}_{index+1}% -->"] = str(category)
|
replacements[f"<!-- %{item}_{index+1}% -->"] = str(category)
|
||||||
for entry_key, entry_value in entry.items():
|
for entry_key, entry_value in entry.items():
|
||||||
replacements[
|
replacements[f"<!-- %{item}_{index+1}_{entry_key}% -->"] = (
|
||||||
f"<!-- %{item}_{index+1}_{entry_key}% -->"
|
html_line_breaks(str(entry_value))
|
||||||
] = html_line_breaks(str(entry_value))
|
)
|
||||||
|
|
||||||
replacements['"sheetsize_default"'] = '"{}"'.format(
|
replacements['"sheetsize_default"'] = '"{}"'.format(
|
||||||
metadata.get("template", {}).get("sheetsize", "")
|
metadata.get("template", {}).get("sheetsize", "")
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user