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!")
|
||||
for pin in loop:
|
||||
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.
|
||||
self.activate_pin(pin)
|
||||
|
||||
@ -234,7 +236,7 @@ class Connector:
|
||||
return self.pincount
|
||||
elif qty_multiplier == "populated":
|
||||
return sum(self.visible_pins.values())
|
||||
elif qty_multiplier == 'unpopulated':
|
||||
elif qty_multiplier == "unpopulated":
|
||||
return max(0, self.pincount - sum(self.visible_pins.values()))
|
||||
else:
|
||||
raise ValueError(
|
||||
|
||||
@ -94,7 +94,7 @@ class Harness:
|
||||
to_pin: (int, str),
|
||||
) -> None:
|
||||
# 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:
|
||||
connector = self.connectors[name]
|
||||
# check if provided name is ambiguous
|
||||
@ -372,16 +372,20 @@ class Harness:
|
||||
)
|
||||
manufacturer_info = pn_info_string(
|
||||
HEADER_MPN,
|
||||
cable.manufacturer[i - 1]
|
||||
if isinstance(cable.manufacturer, list)
|
||||
else None,
|
||||
(
|
||||
cable.manufacturer[i - 1]
|
||||
if isinstance(cable.manufacturer, list)
|
||||
else None
|
||||
),
|
||||
cable.mpn[i - 1] if isinstance(cable.mpn, list) else None,
|
||||
)
|
||||
supplier_info = pn_info_string(
|
||||
HEADER_SPN,
|
||||
cable.supplier[i - 1]
|
||||
if isinstance(cable.supplier, list)
|
||||
else None,
|
||||
(
|
||||
cable.supplier[i - 1]
|
||||
if isinstance(cable.supplier, list)
|
||||
else None
|
||||
),
|
||||
cable.spn[i - 1] if isinstance(cable.spn, list) else None,
|
||||
)
|
||||
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
|
||||
dot.attr(
|
||||
"edge",
|
||||
color=":".join(["#000000", shield_color_hex, "#000000"])
|
||||
if isinstance(cable.shield, str)
|
||||
else "#000000",
|
||||
color=(
|
||||
":".join(["#000000", shield_color_hex, "#000000"])
|
||||
if isinstance(cable.shield, str)
|
||||
else "#000000"
|
||||
),
|
||||
)
|
||||
if connection.from_pin is not None: # connect to left
|
||||
from_connector = self.connectors[connection.from_name]
|
||||
@ -650,7 +656,6 @@ class Harness:
|
||||
graph = self.graph
|
||||
return embed_svg_images(graph.pipe(format="svg").decode("utf-8"), Path.cwd())
|
||||
|
||||
|
||||
def output(
|
||||
self,
|
||||
filename: (str, Path),
|
||||
|
||||
@ -116,11 +116,11 @@ def parse(
|
||||
autogenerated_designators = {}
|
||||
|
||||
# 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:
|
||||
harness.metadata['title'] = "WireViz diagram and BOM"
|
||||
harness.metadata["title"] = "WireViz diagram and BOM"
|
||||
else:
|
||||
harness.metadata['title'] = Path(yaml_file).stem
|
||||
harness.metadata["title"] = Path(yaml_file).stem
|
||||
|
||||
# add items
|
||||
# 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.
|
||||
# Catch this error, but raise any others
|
||||
from errno import ENAMETOOLONG
|
||||
|
||||
if type(e) is OSError and e.errno != ENAMETOOLONG:
|
||||
raise e
|
||||
# file does not exist; assume inp is a YAML string
|
||||
|
||||
@ -36,7 +36,11 @@ def get_additional_component_table(
|
||||
if component.additional_components:
|
||||
rows.append(["Additional components"])
|
||||
# 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 = {
|
||||
"qty": part.qty * component.get_qty_multiplier(part.qty_multiplier),
|
||||
"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."""
|
||||
bom_entries = []
|
||||
# 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(
|
||||
{
|
||||
"description": part.description,
|
||||
|
||||
@ -97,9 +97,9 @@ def generate_html_output(
|
||||
if isinstance(entry, Dict):
|
||||
replacements[f"<!-- %{item}_{index+1}% -->"] = str(category)
|
||||
for entry_key, entry_value in entry.items():
|
||||
replacements[
|
||||
f"<!-- %{item}_{index+1}_{entry_key}% -->"
|
||||
] = html_line_breaks(str(entry_value))
|
||||
replacements[f"<!-- %{item}_{index+1}_{entry_key}% -->"] = (
|
||||
html_line_breaks(str(entry_value))
|
||||
)
|
||||
|
||||
replacements['"sheetsize_default"'] = '"{}"'.format(
|
||||
metadata.get("template", {}).get("sheetsize", "")
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user