Skip to content

Commit

Permalink
Add check for outdated connector attributes
Browse files Browse the repository at this point in the history
  • Loading branch information
kvid committed May 19, 2024
1 parent de1a410 commit cb97c4d
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/wireviz/Harness.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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:
Expand Down

0 comments on commit cb97c4d

Please sign in to comment.