From 8e3014911ac4af0c842986a46421f08b58ae7fe1 Mon Sep 17 00:00:00 2001 From: Daniel Rojas Date: Thu, 9 May 2024 10:53:32 +0200 Subject: [PATCH] Apply suggestions from code review Co-authored-by: kvid --- docs/CHANGELOG.md | 5 ++--- docs/README.md | 2 +- src/wireviz/DataClasses.py | 4 ++-- src/wireviz/wv_cli.py | 6 +++++- src/wireviz/wv_colors.py | 4 ++-- 5 files changed, 12 insertions(+), 9 deletions(-) diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.md index 4dd7c98..5bf6de7 100644 --- a/docs/CHANGELOG.md +++ b/docs/CHANGELOG.md @@ -7,6 +7,7 @@ - Components that are not referenced in any connection set will not be rendered. Instead, a warning will be output in the console. ([#328](https://github.com/wireviz/WireViz/issues/328), [#332](https://github.com/wireviz/WireViz/pull/332)) - New command line interface ([#244](https://github.com/wireviz/WireViz/pull/244)). Run `wireviz --help` for details - The path specified with the `-o`/`--output-dir` option no longer includes the filename (without extension) of the generated files. Use the `-O`/`--output-name` option to specify a different filename for the generated files. +- The `.gv` file is no longer included as a default output format (only as an intermediate file during processing) unless specified with the new `-f` option described below. ### New features @@ -49,9 +50,7 @@ - Remove HTML links from the input attributes ([#164](https://github.com/formatc1702/WireViz/pull/164)) - Add harness metadata section ([#158](https://github.com/formatc1702/WireViz/issues/158), [#214](https://github.com/formatc1702/WireViz/pull/214)) - Add support for supplier and supplier part number information ([#240](https://github.com/formatc1702/WireViz/issues/240), [#241](https://github.com/formatc1702/WireViz/pull/241/)) -- Add graph rendering options (colors, font, color name display style, ...) ([#158](https://github.com/formatc1702/WireViz/issues/158), [#214](https://github.com/formatc1702/WireViz/pull/214)) -- Add support for supplier and supplier part number information ([#240](https://github.com/formatc1702/WireViz/issues/240), [#241](https://github.com/formatc1702/WireViz/pull/241/)) -- Add graph rendering options (colors, font, color name display style, ...) ([#158](https://github.com/formatc1702/WireViz/issues/158), [#214](https://github.com/formatc1702/WireViz/pull/214)) +- Add graph rendering options (background colors, fontname, color name display style, ...) ([#158](https://github.com/formatc1702/WireViz/issues/158), [#214](https://github.com/formatc1702/WireViz/pull/214)) - Add support for background colors for cables and connectors, as well as for some individual cells ([#210](https://github.com/formatc1702/WireViz/issues/210), [#219](https://github.com/formatc1702/WireViz/pull/219)) - Add optional tweaking of the .gv output ([#215](https://github.com/formatc1702/WireViz/pull/215)) (experimental) diff --git a/docs/README.md b/docs/README.md index 8045f85..732f671 100644 --- a/docs/README.md +++ b/docs/README.md @@ -137,7 +137,7 @@ mywire.bom.tsv BOM (bill of materials) as tab-separated text file mywire.html HTML page with wiring diagram and BOM embedded ``` -Wildcars in the file path are also supported to process multiple files at once, e.g.: +Wildcards in the file path are also supported to process multiple files at once, e.g.: ``` $ wireviz ~/path/to/files/*.yml ``` diff --git a/src/wireviz/DataClasses.py b/src/wireviz/DataClasses.py index 7f5f59b..5b4bb06 100644 --- a/src/wireviz/DataClasses.py +++ b/src/wireviz/DataClasses.py @@ -216,7 +216,7 @@ class Connector: f'Unknown loop pin "{pin}" for connector "{self.name}"!' ) # Make sure loop connected pins are not hidden. - self.activate_pin(pin) + self.activate_pin(pin, None) for i, item in enumerate(self.additional_components): if isinstance(item, dict): @@ -318,7 +318,7 @@ class Cable: f"Warning: Cable {self.name} length_unit={self.length_unit} is ignored because its length contains {u}" ) self.length_unit = u - elif not any(isinstance(self.length, t) for t in [int, float]): + elif not isinstance(self.length, (int, float)): raise Exception(f"Cable {self.name} length has a non-numeric value") elif self.length_unit is None: self.length_unit = "m" diff --git a/src/wireviz/wv_cli.py b/src/wireviz/wv_cli.py index 7315072..c6f108e 100644 --- a/src/wireviz/wv_cli.py +++ b/src/wireviz/wv_cli.py @@ -28,7 +28,11 @@ epilog += "following characters to specify which file types to output:\n" epilog += ", ".join([f"{key} ({value.upper()})" for key, value in format_codes.items()]) -@click.command(epilog=epilog, no_args_is_help=True) +@click.command( + epilog=epilog, + no_args_is_help=True, + context_settings=dict(help_option_names=["-h", "--help"]), +) @click.argument("file", nargs=-1) @click.option( "-f", diff --git a/src/wireviz/wv_colors.py b/src/wireviz/wv_colors.py index 857f307..62957f9 100644 --- a/src/wireviz/wv_colors.py +++ b/src/wireviz/wv_colors.py @@ -28,7 +28,7 @@ COLOR_CODES = { "BUVT", "VTBU", "OGVT", "VTOG", "GNVT", "VTGN", "BNVT", "VTBN", "SLVT", "VTSL", ], "TELALT": [ # 25x2: Tip and then ring of each pair - "WHBU", "BU", "WHOG", "OG", "WHGN", "GN", "WHBN", "BN", "WHSL", "SL", + "WHBU", "BU", "WHOG", "OG", "WHGN", "GN", "WHBN", "BN", "WHSL", "SL", "RDBU", "BURD", "RDOG", "OGRD", "RDGN", "GNRD", "RDBN", "BNRD", "RDSL", "SLRD", "BKBU", "BUBK", "BKOG", "OGBK", "BKGN", "GNBK", "BKBN", "BNBK", "BKSL", "SLBK", "YEBU", "BUYE", "YEOG", "OGYE", "YEGN", "GNYE", "YEBN", "BNYE", "YESL", "SLYE", @@ -156,7 +156,7 @@ def get_color_hex(input: Colors, pad: bool = False) -> List[str]: if len(output) == 2: # Give wires with EXACTLY 2 colors that striped look. output += output[:1] elif pad and len(output) == 1: # Hacky style fix: Give single color wires - output *= 3 # a triple-up so that wires are the same size. + output *= 3 # a triple-up so that wires are the same size return output