devbisme / skidl

SKiDL is a module that extends Python with the ability to design electronic circuits.
https://devbisme.github.io/skidl/
MIT License
1.06k stars 120 forks source link

Skidl sometimes not respecting ```ref_prefix``` dictionary keyword #174

Closed rtpavlovsk21 closed 1 year ago

rtpavlovsk21 commented 1 year ago

Describe the bug A clear and concise description of what the bug is. Skidl reference designators ref_prefix not respected on the call of a part, ie

#/bin/bash ipython3.10
In [14]: from skidl import *

In [15]: resistor = Part('CustomLibDevice', 'SD25', ref_prefix='RR')

In [16]: resistor.ref
Out[16]: 'U1'

To Reproduce Steps to reproduce the behavior:

#/bin/bash ipython3.10
In [14]: from skidl import *

In [15]: resistor = Part('CustomLibDevice', 'SD25', ref_prefix='RR')

In [16]: resistor.ref
Out[16]: 'U1'

Expect to see resistor.ref prefixed with 'RR'. ~~

Desktop (please complete the following information):

OS: Windows/WSL/Debian 12 (bookworm) Python version 3.10 SKiDL 1.1.0 (development)

Additional context Add any other context about the problem here.

 pip install git+https://github.com/devbisme/skidl.git@development
python3
>>> from skidl import *
>>> resistor = Part('CustomLibDevice', 'SD25', ref_prefix="RR")
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/ryanpavlovsky/.local/lib/python3.10/site-packages/skidl/part.py", line 191, in __init__
    lib = SchLib(filename=libname, tool=tool)
  File "/home/ryanpavlovsky/.local/lib/python3.10/site-packages/skidl/schlib.py", line 88, in __init__
    tool_modules[tool].load_sch_lib(
  File "/home/ryanpavlovsky/.local/lib/python3.10/site-packages/skidl/tools/kicad/kicad.py", line 93, in load_sch_lib
    v6.load_sch_lib(lib, f, filename, lib_search_paths_)
  File "/home/ryanpavlovsky/.local/lib/python3.10/site-packages/skidl/tools/kicad/v6.py", line 96, in load_sch_lib
    keywords = properties["ki_keywords"]
KeyError: 'ki_keywords'

Checked out development version per advice #172 but the code conflicted with a few custom parts, returning KeyError: 'ki_keywords'

The code contained at https://github.com/devbisme/skidl/blob/7cea69751e97e310d077aa2fc76c7adfa44889ce/src/skidl/tools/kicad/v6.py#L69-96 potentially requires that the part derives from parent parts, otherwise ki_keywords is never populated. Is there a template that could be provided there?

rtpavlovsk21 commented 1 year ago

https://github.com/devbisme/skidl/pull/175 provides default values for key items not found. This is a hack, and possibly produces unwanted behavior. I haven't looked around the code-base to observe the impact of this yet.

rtpavlovsk21 commented 1 year ago

175 merged, therefore my issue is closed!

devbisme commented 1 year ago

Great! Thanks for reporting the problems.