Skip to content

Commit 684f6f0

Browse files
17o2kvid
authored andcommitted
Apply black
1 parent 0c73e57 commit 684f6f0

File tree

5 files changed

+37
-20
lines changed

5 files changed

+37
-20
lines changed

src/wireviz/DataClasses.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,9 @@ def __post_init__(self) -> None:
212212
raise Exception("Loops must be between exactly two pins!")
213213
for pin in loop:
214214
if pin not in self.pins:
215-
raise Exception(f'Unknown loop pin "{pin}" for connector "{self.name}"!')
215+
raise Exception(
216+
f'Unknown loop pin "{pin}" for connector "{self.name}"!'
217+
)
216218
# Make sure loop connected pins are not hidden.
217219
self.activate_pin(pin)
218220

@@ -234,7 +236,7 @@ def get_qty_multiplier(self, qty_multiplier: Optional[ConnectorMultiplier]) -> i
234236
return self.pincount
235237
elif qty_multiplier == "populated":
236238
return sum(self.visible_pins.values())
237-
elif qty_multiplier == 'unpopulated':
239+
elif qty_multiplier == "unpopulated":
238240
return max(0, self.pincount - sum(self.visible_pins.values()))
239241
else:
240242
raise ValueError(

src/wireviz/Harness.py

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ def connect(
9494
to_pin: (int, str),
9595
) -> None:
9696
# check from and to connectors
97-
for (name, pin) in zip([from_name, to_name], [from_pin, to_pin]):
97+
for name, pin in zip([from_name, to_name], [from_pin, to_pin]):
9898
if name is not None and name in self.connectors:
9999
connector = self.connectors[name]
100100
# check if provided name is ambiguous
@@ -372,16 +372,20 @@ def create_graph(self) -> Graph:
372372
)
373373
manufacturer_info = pn_info_string(
374374
HEADER_MPN,
375-
cable.manufacturer[i - 1]
376-
if isinstance(cable.manufacturer, list)
377-
else None,
375+
(
376+
cable.manufacturer[i - 1]
377+
if isinstance(cable.manufacturer, list)
378+
else None
379+
),
378380
cable.mpn[i - 1] if isinstance(cable.mpn, list) else None,
379381
)
380382
supplier_info = pn_info_string(
381383
HEADER_SPN,
382-
cable.supplier[i - 1]
383-
if isinstance(cable.supplier, list)
384-
else None,
384+
(
385+
cable.supplier[i - 1]
386+
if isinstance(cable.supplier, list)
387+
else None
388+
),
385389
cable.spn[i - 1] if isinstance(cable.spn, list) else None,
386390
)
387391
if manufacturer_info:
@@ -444,9 +448,11 @@ def create_graph(self) -> Graph:
444448
# shield is shown with specified color and black borders, or as a thin black wire otherwise
445449
dot.attr(
446450
"edge",
447-
color=":".join(["#000000", shield_color_hex, "#000000"])
448-
if isinstance(cable.shield, str)
449-
else "#000000",
451+
color=(
452+
":".join(["#000000", shield_color_hex, "#000000"])
453+
if isinstance(cable.shield, str)
454+
else "#000000"
455+
),
450456
)
451457
if connection.from_pin is not None: # connect to left
452458
from_connector = self.connectors[connection.from_name]
@@ -650,7 +656,6 @@ def svg(self):
650656
graph = self.graph
651657
return embed_svg_images(graph.pipe(format="svg").decode("utf-8"), Path.cwd())
652658

653-
654659
def output(
655660
self,
656661
filename: (str, Path),

src/wireviz/wireviz.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,9 @@ def parse(
117117

118118
# When title is not given, either deduce it from filename, or use default text.
119119
if "title" not in harness.metadata:
120-
harness.metadata["title"] = Path(yaml_file).stem if yaml_file else "WireViz diagram and BOM"
120+
harness.metadata["title"] = (
121+
Path(yaml_file).stem if yaml_file else "WireViz diagram and BOM"
122+
)
121123

122124
# add items
123125
# parse YAML input file ====================================================
@@ -202,7 +204,6 @@ def alternate_type(): # flip between connector and cable/arrow
202204
expected_type = alternating_types[1 - alternating_types.index(expected_type)]
203205

204206
for connection_set in connection_sets:
205-
206207
# figure out number of parallel connections within this set
207208
connectioncount = []
208209
for entry in connection_set:
@@ -408,6 +409,7 @@ def _get_yaml_data_and_path(inp: Union[str, Path, Dict]) -> (Dict, Path):
408409
# when trying to expand and resolve it as a path.
409410
# Catch this error, but raise any others
410411
from errno import ENAMETOOLONG
412+
411413
if type(e) is OSError and e.errno != ENAMETOOLONG:
412414
raise e
413415
# file does not exist; assume inp is a YAML string

src/wireviz/wv_bom.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,11 @@ def get_additional_component_table(
3636
if component.additional_components:
3737
rows.append(["Additional components"])
3838
# Ignore components that have qty 0
39-
for part in [part for part in component.additional_components if component.get_qty_multiplier(part.qty_multiplier)]:
39+
for part in [
40+
part
41+
for part in component.additional_components
42+
if component.get_qty_multiplier(part.qty_multiplier)
43+
]:
4044
common_args = {
4145
"qty": part.qty * component.get_qty_multiplier(part.qty_multiplier),
4246
"unit": part.unit,
@@ -65,7 +69,11 @@ def get_additional_component_bom(component: Union[Connector, Cable]) -> List[BOM
6569
"""Return a list of BOM entries with additional components."""
6670
bom_entries = []
6771
# Ignore components that have qty 0
68-
for part in [part for part in component.additional_components if component.get_qty_multiplier(part.qty_multiplier)]:
72+
for part in [
73+
part
74+
for part in component.additional_components
75+
if component.get_qty_multiplier(part.qty_multiplier)
76+
]:
6977
bom_entries.append(
7078
{
7179
"description": part.description,

src/wireviz/wv_html.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -97,9 +97,9 @@ def generate_html_output(
9797
if isinstance(entry, Dict):
9898
replacements[f"<!-- %{item}_{index+1}% -->"] = str(category)
9999
for entry_key, entry_value in entry.items():
100-
replacements[
101-
f"<!-- %{item}_{index+1}_{entry_key}% -->"
102-
] = html_line_breaks(str(entry_value))
100+
replacements[f"<!-- %{item}_{index+1}_{entry_key}% -->"] = (
101+
html_line_breaks(str(entry_value))
102+
)
103103

104104
replacements['"sheetsize_default"'] = '"{}"'.format(
105105
metadata.get("template", {}).get("sheetsize", "")

0 commit comments

Comments
 (0)