Skip to content
This repository has been archived by the owner on Oct 2, 2020. It is now read-only.

Handle footprint name as string #336

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pcb/kicad_mod.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ def __init__(self, filename):
self.sexpr_data = sexpr_data

# module name
self.name = self.sexpr_data[1]
self.name = str(self.sexpr_data[1])

# module layer
self.layer = self._getValue('layer', 'pth', 2)
Expand Down
2 changes: 1 addition & 1 deletion pcb/rules/F5_2.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ def checkMissingValue(self):
self.error("Missing 'value' field")
return True

if not val['value'] == mod.name:
if not str(val['value']) == mod.name:
errors.append("Value text should match footprint name:")
errors.append("Value text is '{v}', expected: '{n}'".format(
v = val['value'],
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

also convert to str here.

Expand Down
2 changes: 1 addition & 1 deletion pcb/rules/F9_1.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ def check(self):
self.error("footprint name (in file) was '{0}', but expected (from filename) '{1}'.\n".format(module.name, os.path.splitext(os.path.basename(module.filename))[0]))
err = True

if module.value['value'] != module.name:
if str(module.value['value']) != module.name:
self.error("Value label '{lbl}' does not match filename '{fn}'".format(
lbl=module.value['value'],
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same as above.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For example Molex uses numeric-only part numbers.

image

You can see the error message below if the module name contains only numeric characters:

./check_kicad_mod.py ~/work/sharkrf-kicad-library/footprints/srf_Molex.pretty/5051100892.kicad_mod
Traceback (most recent call last):
  File "./check_kicad_mod.py", line 117, in <module>
    rule.check()
  File "/home/makos/work/kicad-library-utils/pcb/rules/F7_4.py", line 140, in check
    return any([self.checkPads(module.pads)])
  File "/home/makos/work/kicad-library-utils/pcb/rules/F7_4.py", line 46, in checkPads
    exposed_pad_search = re.search('\-\d+[EP]{2}', fpName, re.IGNORECASE)
  File "/usr/lib64/python3.8/re.py", line 201, in search
    return _compile(pattern, flags).search(string)
TypeError: expected string or bytes-like object

fn = module.name))
Expand Down