From 9b2b22d6aee17ea99a6f61d2e5d4eba0426ab028 Mon Sep 17 00:00:00 2001 From: KV Date: Thu, 9 May 2024 16:06:22 +0200 Subject: [PATCH] Add check for outdated connector attributes --- src/wireviz/Harness.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/wireviz/Harness.py b/src/wireviz/Harness.py index 93100db6..30468a6a 100644 --- a/src/wireviz/Harness.py +++ b/src/wireviz/Harness.py @@ -53,6 +53,17 @@ ) from wireviz.wv_html import generate_html_output +OLD_CONNECTOR_ATTR = { + "pinout": "was renamed to 'pinlabels' in v0.2", + "pinnumbers": "was renamed to 'pins' in v0.2", + "autogenerate": "is replaced with new syntax in v0.4", +} + +def check_old(node: str, old_attr: dict, args: dict) -> None: + """Raise exception for any outdated attributes in args.""" + for attr, descr in old_attr.items(): + if attr in args: + raise ValueError(f"'{attr}' in {node}: '{attr}' {descr}") @dataclass class Harness: @@ -68,6 +79,7 @@ def __post_init__(self): self.additional_bom_items = [] def add_connector(self, name: str, *args, **kwargs) -> None: + check_old(f"Connector '{name}'", OLD_CONNECTOR_ATTR, kwargs) self.connectors[name] = Connector(name, *args, **kwargs) def add_cable(self, name: str, *args, **kwargs) -> None: