Add check for outdated connector attributes
Co-authored-by: kvid <kvid@users.noreply.github.com>
This commit is contained in:
parent
701815874c
commit
2400193435
@ -40,7 +40,7 @@ from wireviz.wv_output import (
|
||||
embed_svg_images_file,
|
||||
generate_html_output,
|
||||
)
|
||||
from wireviz.wv_utils import bom2tsv, open_file_write
|
||||
from wireviz.wv_utils import OLD_CONNECTOR_ATTR, bom2tsv, check_old, open_file_write
|
||||
|
||||
|
||||
@dataclass
|
||||
@ -58,6 +58,7 @@ class Harness:
|
||||
self.additional_bom_items = []
|
||||
|
||||
def add_connector(self, designator: str, *args, **kwargs) -> None:
|
||||
check_old(f"Connector '{designator}'", OLD_CONNECTOR_ATTR, kwargs)
|
||||
conn = Connector(designator=designator, *args, **kwargs)
|
||||
self.connectors[designator] = conn
|
||||
|
||||
|
||||
@ -214,3 +214,17 @@ def smart_file_resolve(filename: str, possible_paths: Union[str, List[str]]) ->
|
||||
f"{filename} was not found in any of the following locations: \n"
|
||||
+ "\n".join([str(x) for x in possible_paths])
|
||||
)
|
||||
|
||||
|
||||
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}")
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user