Skip to content

Commit

Permalink
Remove unused part_id field; improve csv parsing
Browse files Browse the repository at this point in the history
Check that the number of fields is correct for each row.
  • Loading branch information
mairas committed Mar 2, 2023
1 parent e554018 commit 8172604
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions kikit/fab/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,11 +64,13 @@ class FormatError(Exception):
class CorrectionPattern:
"""Single correction pattern to match a component against."""
footprint: re.Pattern
part_id: re.Pattern
x_correction: float
y_correction: float
rotation: float

class CorrectionPatternError(Exception):
pass

def layerToSide(layer):
if layer == pcbnew.F_Cu:
return "T"
Expand Down Expand Up @@ -112,7 +114,7 @@ def readCorrectionPatterns(filename):
- Regexp to match to the part id (ignored at the moment)
- X correction
- Y correction
- Rotation
- Rotation (positive is counterclockwise)
"""
corrections = OrderedDict()
correctionPatterns = []
Expand All @@ -124,16 +126,17 @@ def readCorrectionPatterns(filename):
reader = csv.reader(csvfile, dialect)
first = True
for row in reader:
if len(row) != 4:
raise CorrectionPatternError(f"Invalid number of fields in {row}")
if has_header and first:
first = False
continue
correctionPatterns.append(
CorrectionPattern(
re.compile(row[0]),
re.compile(row[1]),
float(row[1]),
float(row[2]),
float(row[3]),
float(row[4]),
)
)
return correctionPatterns
Expand Down

0 comments on commit 8172604

Please sign in to comment.