Make prefix for autogenerated component names configurable
`edotor.net` does not seem to like leading underscores, which makes GraphViz debugging difficult.
This commit is contained in:
parent
9cb9ede487
commit
18782444b1
@ -42,6 +42,8 @@ MetadataKeys = PlainText # Literal['title', 'description', 'notes', ...]
|
||||
|
||||
Side = Enum("Side", "LEFT RIGHT")
|
||||
|
||||
AUTOGENERATED_PREFIX = "AUTOGENERATED_"
|
||||
|
||||
|
||||
class Metadata(dict):
|
||||
pass
|
||||
@ -163,6 +165,10 @@ class Connector:
|
||||
ignore_in_bom: bool = False
|
||||
additional_components: List[AdditionalComponent] = field(default_factory=list)
|
||||
|
||||
@property
|
||||
def is_autogenerated(self):
|
||||
return self.name.startswith(AUTOGENERATED_PREFIX)
|
||||
|
||||
def __post_init__(self) -> None:
|
||||
|
||||
if isinstance(self.image, dict):
|
||||
@ -196,8 +202,7 @@ class Connector:
|
||||
raise Exception("Pins are not unique")
|
||||
|
||||
if self.show_name is None:
|
||||
# hide designators for simple and for auto-generated connectors by default
|
||||
self.show_name = self.style != "simple" and self.name[0:2] != "__"
|
||||
self.show_name = self.style != "simple" and not self.is_autogenerated
|
||||
|
||||
if self.show_pincount is None:
|
||||
# hide pincount for simple (1 pin) connectors by default
|
||||
@ -269,6 +274,10 @@ class Cable:
|
||||
ignore_in_bom: bool = False
|
||||
additional_components: List[AdditionalComponent] = field(default_factory=list)
|
||||
|
||||
@property
|
||||
def is_autogenerated(self):
|
||||
return self.name.startswith(AUTOGENERATED_PREFIX)
|
||||
|
||||
def __post_init__(self) -> None:
|
||||
|
||||
if isinstance(self.image, dict):
|
||||
@ -360,8 +369,7 @@ class Cable:
|
||||
raise Exception("lists of part data are only supported for bundles")
|
||||
|
||||
if self.show_name is None:
|
||||
# hide designators for auto-generated cables by default
|
||||
self.show_name = self.name[0:2] != "__"
|
||||
self.show_name = not self.is_autogenerated
|
||||
|
||||
if self.show_wirenumbers is None:
|
||||
# by default, show wire numbers for cables, hide for bundles
|
||||
|
||||
@ -17,8 +17,8 @@ from wireviz.DataClasses import (
|
||||
MatePin,
|
||||
Metadata,
|
||||
Options,
|
||||
Tweak,
|
||||
Side,
|
||||
Tweak,
|
||||
)
|
||||
from wireviz.svgembed import embed_svg_images_file
|
||||
from wireviz.wv_bom import (
|
||||
@ -650,7 +650,6 @@ class Harness:
|
||||
graph = self.graph
|
||||
return embed_svg_images(graph.pipe(format="svg").decode("utf-8"), Path.cwd())
|
||||
|
||||
|
||||
def output(
|
||||
self,
|
||||
filename: (str, Path),
|
||||
|
||||
@ -10,7 +10,7 @@ import yaml
|
||||
if __name__ == "__main__":
|
||||
sys.path.insert(0, str(Path(__file__).parent.parent)) # add src/wireviz to PATH
|
||||
|
||||
from wireviz.DataClasses import Metadata, Options, Tweak
|
||||
from wireviz.DataClasses import AUTOGENERATED_PREFIX, Metadata, Options, Tweak
|
||||
from wireviz.Harness import Harness
|
||||
from wireviz.wv_helper import (
|
||||
expand,
|
||||
@ -164,7 +164,7 @@ def parse(
|
||||
autogenerated_designators[template] = (
|
||||
autogenerated_designators.get(template, 0) + 1
|
||||
)
|
||||
designator = f"__{template}_{autogenerated_designators[template]}"
|
||||
designator = f"{AUTOGENERATED_PREFIX}{template}_{autogenerated_designators[template]}"
|
||||
# check if redefining existing component to different template
|
||||
if designator in designators_and_templates:
|
||||
if designators_and_templates[designator] != template:
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user