Added support for multiple matching rules
We now use the last matching rule when there are multiple matches. This allows local overrides as well as rules defined in order of specificity. This relies on Python 3.7+ ordered dicts.
This commit is contained in:
parent
feabc95236
commit
5ecf6c9b13
|
@ -7,7 +7,7 @@ JLCKicadTools is a tool aims to work with JLCPCB assembly service featuring KiCa
|
|||
See [this blog post](https://dubiouscreations.com/2019/10/21/using-kicad-with-jlcpcb-assembly-service) for instructions.
|
||||
|
||||
## Requirements
|
||||
Python 3.6+
|
||||
Python 3.7+
|
||||
|
||||
### Installation
|
||||
```
|
||||
|
|
|
@ -1 +1 @@
|
|||
__version__ = "1.0.4"
|
||||
__version__ = "1.0.5"
|
||||
|
|
|
@ -111,22 +111,24 @@ def FixRotations(input_filename, output_filename, db):
|
|||
row[posx_index] = "{0:.6f}".format(-float(row[posx_index]))
|
||||
|
||||
row[ref_index] = row[ref_index].upper()
|
||||
no_match = True
|
||||
last_correction = None
|
||||
for pattern, correction in db.items():
|
||||
if pattern.match(row[package_index]):
|
||||
no_match = False
|
||||
_LOGGER.logger.info(
|
||||
"Footprint {} matched {}. Applying {} deg correction".format(
|
||||
row[package_index], pattern.pattern, correction
|
||||
)
|
||||
)
|
||||
if row[side_index].strip() == "bottom":
|
||||
rotation = (rotation - correction + 180) % 360
|
||||
else:
|
||||
rotation = (rotation + correction) % 360
|
||||
row[rotation_index] = "{0:.6f}".format(rotation)
|
||||
break
|
||||
if no_match and row[side_index].strip() == "bottom":
|
||||
last_correction = correction
|
||||
|
||||
if last_correction is not None:
|
||||
if row[side_index].strip() == "bottom":
|
||||
rotation = (rotation - correction + 180) % 360
|
||||
else:
|
||||
rotation = (rotation + correction) % 360
|
||||
row[rotation_index] = "{0:.6f}".format(rotation)
|
||||
|
||||
if last_correction is None and row[side_index].strip() == "bottom":
|
||||
rotation = (rotation + 180) % 360
|
||||
row[rotation_index] = "{0:.6f}".format(rotation)
|
||||
writer.writerow(row)
|
||||
|
|
Loading…
Reference in New Issue