summaryrefslogtreecommitdiff
path: root/gerbonara/layers.py
diff options
context:
space:
mode:
authorjaseg <git@jaseg.de>2023-03-31 16:31:44 +0200
committerjaseg <git@jaseg.de>2023-04-10 23:57:15 +0200
commit02954407703430dcefba0b165360d201fe8e205c (patch)
treee103a7df869064f8d1d4b36b4311f4aee393f12a /gerbonara/layers.py
parent800827b2c575c31f1449ce9d690d158c7bb2f497 (diff)
downloadgerbonara-02954407703430dcefba0b165360d201fe8e205c.tar.gz
gerbonara-02954407703430dcefba0b165360d201fe8e205c.tar.bz2
gerbonara-02954407703430dcefba0b165360d201fe8e205c.zip
Improve layer stack handling
Diffstat (limited to 'gerbonara/layers.py')
-rw-r--r--gerbonara/layers.py11
1 files changed, 9 insertions, 2 deletions
diff --git a/gerbonara/layers.py b/gerbonara/layers.py
index abdd570..b2b3900 100644
--- a/gerbonara/layers.py
+++ b/gerbonara/layers.py
@@ -113,16 +113,22 @@ class NamingScheme:
def _match_files(filenames):
matches = {}
for generator, rules in MATCH_RULES.items():
+ already_matched = set()
gen = {}
matches[generator] = gen
for layer, regex in rules.items():
for fn in filenames:
+ if fn in already_matched:
+ continue
+
if (m := re.fullmatch(regex, fn.name, re.IGNORECASE)):
if layer == 'inner copper':
target = 'inner_' + ''.join(e or '' for e in m.groups()) + ' copper'
else:
target = layer
+
gen[target] = gen.get(target, []) + [fn]
+ already_matched.add(fn)
return matches
@@ -615,8 +621,10 @@ class LayerStack:
if self.drill_pth is not None:
yield get_name('plated drill', self.drill_pth), self.drill_pth
+
if self.drill_npth is not None:
yield get_name('nonplated drill', self.drill_npth), self.drill_npth
+
for layer in self._drill_layers:
yield get_name('unknown drill', layer), layer
@@ -872,8 +880,7 @@ class LayerStack:
npth_out.append(obj)
self.drill_pth, self.drill_npth = pth_out, npth_out
- self._drill_layers = unknown_out if unknown_out else None
- self._drill_layers = []
+ self._drill_layers = [unknown_out] if unknown_out else []
@property
def drill_layers(self):