[SKiDL BUG] Using components that do not contain a defined datasheet property throws 'Key Error'
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 75/100
Research direction
Start in src/skidl/tools/kicad8/lib.py at the property population logic and inspect how the KiCad symbol is parsed into props. Reproduce with the provided Part('220-3342-00-0602J.kicad_sym', '220-3342-00-0602J'), then check the corresponding lib.py files for other KiCad versions. Done means a symbol without a datasheet property loads without raising KeyError, while symbols that define it retain the value.
Written by the indexing model from the issue text.
Description
Describe the bug
When custom components don't contain the datasheet property, then attempting to parse it throws an error.
To Reproduce
Steps to reproduce the behavior:
- Load a part that fits the description.
zif = Part('220-3342-00-0602J.kicad_sym','220-3342-00-0602J')
Expected behavior
I expected the part to load without error.
Fix
The problem exists in (https://github.com/devbisme/skidl/blob/cad164fa6ea6bfdd872c6bd9c90a99e40c39b62e/src/skidl/tools/kicad8/lib.py#L462)
Specifically
# Populate part fields from symbol properties. Properties will also be included below in drawing commands.
props = {
prop[1].lower(): prop
for prop in part.part_defn
if prop[0].value().lower() == "property"
}
part.ref_prefix = props["reference"][2]
part.value = props["value"][2]
part.fplist.append(props["footprint"][2])
part.datasheet = props["datasheet"][2]
part.draw_cmds[1].extend([props["reference"], props["value"]])
Line 462: if props datasheet[2] doesn't exist, then the script errors out.
Replace line 462 with these two lines:
part.datasheet = props.get("datasheet", ["", "", ""])
part.datasheet = part.datasheet[2] if len(part.datasheet) > 2 else ""
I have no clue if this is the most robust or clean way of handling this, but I do know that this fixes my issue.
Desktop (please complete the following information):
- Windows 11 Pro.
- Jupyter Notebook 7.2.2
- Python 3.12.7
- SKiDL version 2.0.1
Additional context
This will likely need to be changed in all the different kicad version lib.py's. The troublesome part, downloaded from the normal part sites, is attached.
- Dominant language
- Python
- Stars
- 1.7k
- Forks
- 184
- PR merge metrics
- No merged PRs in 30d
Getting set up
This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from devbisme/skidl
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
-
SPICE netlist wires the wrong node to a subcircuit port when an earlier pin is unconnectedPossibly taken A pull request linked to this issue is open or already merged. Open
Difficulty 2/5 1-3 hours Newbie friendliness 85/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
-
enhancement
Difficulty 5/5 Over a week Newbie friendliness 35/100
-
bug
Difficulty 3/5 1-2 days Newbie friendliness 48/100
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
pimutils/vdirsyncer#1242 ·
-
priority:P2
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
QuantConnect/lean-cli#792 ·
Maintainers usually reply within 1 day
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
open-webui/open-webui#35360 · 1 comment ·
Maintainers usually reply within 1 day
-
Suggest link: Destiny Verify (MIT zero-dependency pre-commit security, citation & link hygiene CLI)Open
Difficulty 1/5 Under an hour Newbie friendliness 68/100
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 85/100
Maintainers usually reply within 1 day