WireViz icon indicating copy to clipboard operation
WireViz copied to clipboard

Exception when using : (colon) in Connector Name

Open Katzenbiber opened this issue 1 month ago • 4 comments

When using colons in the connector name / designator:

connectors:
  ABC:J1:
    pinlabels: ['4']
    pins: [4]
  DEF:J1:
    pinlabels: ['1']
    pins: [1]
cables:
  1-1:
    wirecount: 3
    color_code: DIN
connections:
- - DEF:J1: [1]
  - 1-1: [1]
  - ABC:J1: [4]

the following Error is raised:

  File "/nix/store/lj6gk0psav27llxv1yns11h0s6j0gscg-python3.13-graphviz-0.21/lib/python3.13/site-packages/graphviz/_tools.py", line 185, in wrapper
    return func(*args, **kwargs)
  File "/nix/store/lj6gk0psav27llxv1yns11h0s6j0gscg-python3.13-graphviz-0.21/lib/python3.13/site-packages/graphviz/backend/rendering.py", line 326, in render
    execute.run_check(cmd,
    ~~~~~~~~~~~~~~~~~^^^^^
                      cwd=filepath.parent if filepath.parent.parts else None,
                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
                      quiet=quiet,
                      ^^^^^^^^^^^^
                      capture_output=True)
                      ^^^^^^^^^^^^^^^^^^^^
  File "/nix/store/lj6gk0psav27llxv1yns11h0s6j0gscg-python3.13-graphviz-0.21/lib/python3.13/site-packages/graphviz/backend/execute.py", line 90, in run_check
    raise CalledProcessError(*e.args)
graphviz.backend.execute.CalledProcessError: Command '[PosixPath('/nix/store/6rd874kd8w2b33287gr1py5w09lp1m22-graphviz-12.2.1/bin/dot'), '-Kdot', '-Tsvg', '-O', 'example.tmp']' returned non-zero exit status 1. [stderr: b"Error: example.tmp: syntax error in line 52 near ':'\n"]

It would be nice if this limitation could be removes, as I use the colon notation in my documentation for Connectors on e.g. a PCB. I hope this isn't a foundational limitation by GraphViz...

Regardless, reading this error, I assume, that this limitation isn't checked on data input, which leads to this convoluted Error.

Katzenbiber avatar Nov 29 '25 15:11 Katzenbiber

Please try surrounding designators containing special characters that might be illegal in YAML or Graphviz with double quote characters.

kvid avatar Dec 01 '25 00:12 kvid

connectors:
  "ABC:J1":
    pins:
    - 1
    - 2
    - BShl
  "DEF:J1":
    pins:
    - 1
    - 2
    - BShl
cables:
  1-1:
    shield: true
    colors:
    - RD
    - BU
connections:
- - "ABC:J1":
    - '1'
    - '2'
    - BShl
  - 1-1:
    - RD
    - BU
    - s
  - "DEF:J1":
    - '2'
    - '1'
    - BShl

Nope, still fails with:

  File "/nix/store/qbwf1gxz2nynjphsairlck2czslq8g7n-wireviz-0.4.1/lib/python3.13/site-packages/wireviz/wireviz.py", line 385, in parse
    harness.output(filename=output_file, fmt=output_formats, view=False)
    ~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/nix/store/qbwf1gxz2nynjphsairlck2czslq8g7n-wireviz-0.4.1/lib/python3.13/site-packages/wireviz/Harness.py", line 684, in output
    graph.render(filename=_filename, view=view, cleanup=cleanup)
    ~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/nix/store/lj6gk0psav27llxv1yns11h0s6j0gscg-python3.13-graphviz-0.21/lib/python3.13/site-packages/graphviz/_tools.py", line 185, in wrapper
    return func(*args, **kwargs)
  File "/nix/store/lj6gk0psav27llxv1yns11h0s6j0gscg-python3.13-graphviz-0.21/lib/python3.13/site-packages/graphviz/rendering.py", line 122, in render
    rendered = self._render(*args, **kwargs)
  File "/nix/store/lj6gk0psav27llxv1yns11h0s6j0gscg-python3.13-graphviz-0.21/lib/python3.13/site-packages/graphviz/_tools.py", line 185, in wrapper
    return func(*args, **kwargs)
  File "/nix/store/lj6gk0psav27llxv1yns11h0s6j0gscg-python3.13-graphviz-0.21/lib/python3.13/site-packages/graphviz/backend/rendering.py", line 326, in render
    execute.run_check(cmd,
    ~~~~~~~~~~~~~~~~~^^^^^
                      cwd=filepath.parent if filepath.parent.parts else None,
                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
                      quiet=quiet,
                      ^^^^^^^^^^^^
                      capture_output=True)
                      ^^^^^^^^^^^^^^^^^^^^
  File "/nix/store/lj6gk0psav27llxv1yns11h0s6j0gscg-python3.13-graphviz-0.21/lib/python3.13/site-packages/graphviz/backend/execute.py", line 90, in run_check
    raise CalledProcessError(*e.args)
graphviz.backend.execute.CalledProcessError: Command '[PosixPath('/nix/store/6rd874kd8w2b33287gr1py5w09lp1m22-graphviz-12.2.1/bin/dot'), '-Kdot', '-Tsvg', '-O', 'example.tmp']' returned non-zero exit status 1. [stderr: b"Error: example.tmp: syntax error in line 62 near ':'\n"]

I tried also single quotes with the same result

Katzenbiber avatar Dec 05 '25 18:12 Katzenbiber

Can you try on of the following, instead of the :

  • :
  • &#58
  • &#x3A
  • \u003A

These are the unicode representations.

tobiasfalk avatar Dec 06 '25 08:12 tobiasfalk

I have verified that colon is legal in YAML designators, but colon followed by space is interpreted as a separator unless within quotes.

Graphviz seems to have a problem with colon in designators, and some recommend using designators without colon and use colon only in the label part that is rendered, but that will need code changes in WireViz. See also https://github.com/xflr6/graphviz/issues/53

@tobiasfalk - thank's for your suggestions. The following YAML input seems to work with Graphviz version 2.43.0:

connectors:
  ABC:J1:
    pinlabels: ['4']
    pins: [4]
  DEF:J1:
    pinlabels: ['1']
    pins: [1]
cables:
  1-1:
    wirecount: 3
    color_code: DIN
connections:
- - DEF:J1: [1]
  - 1-1: [1]
  - ABC:J1: [4]

Graphviz doesn't decode such character encodings until the final rendering step, so we need to use identical encoding strings at all places where the same designator is used.

However, one possible drawback with this work-around is that such encoded designator characters also will be present in the BOM TSV output file.

kvid avatar Dec 07 '25 13:12 kvid