diff options
author | jaseg <git@jaseg.de> | 2022-01-29 03:05:27 +0100 |
---|---|---|
committer | jaseg <git@jaseg.de> | 2022-01-29 03:05:27 +0100 |
commit | 80121e6e5aecea1faf5d33b0511ccc2827d820f4 (patch) | |
tree | ff634825e3196731df57b7e41a0835d41f4248eb /gerbonara/gerber/layers.py | |
parent | 35f24607fe65385370cd6e267ea5afffbfbd1e34 (diff) | |
download | gerbonara-80121e6e5aecea1faf5d33b0511ccc2827d820f4.tar.gz gerbonara-80121e6e5aecea1faf5d33b0511ccc2827d820f4.tar.bz2 gerbonara-80121e6e5aecea1faf5d33b0511ccc2827d820f4.zip |
Make all layer matching tests run through
Diffstat (limited to 'gerbonara/gerber/layers.py')
-rw-r--r-- | gerbonara/gerber/layers.py | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/gerbonara/gerber/layers.py b/gerbonara/gerber/layers.py index 69f9316..d6f06b2 100644 --- a/gerbonara/gerber/layers.py +++ b/gerbonara/gerber/layers.py @@ -64,7 +64,9 @@ def best_match(filenames): return generator, files
def identify_file(data):
- if 'M48' in data or 'G90' in data:
+ if 'M48' in data:
+ return 'excellon'
+ if 'G90' in data and ';LEADER:' in data: # yet another allegro special case
return 'excellon'
if 'FSLAX' in data or 'FSTAX' in data:
return 'gerber'
@@ -162,6 +164,7 @@ class LayerStack: files = [ path for path in directory.glob('**/*') if path.is_file() ]
generator, filemap = best_match(files)
+ print('detected generator', generator)
if len(filemap) < 6:
warnings.warn('Ambiguous gerber filenames. Trying last-resort autoguesser.')
@@ -213,6 +216,9 @@ class LayerStack: else:
excellon_settings = None
+ import pprint
+ pprint.pprint(filemap)
+
ambiguous = [ key for key, value in filemap.items() if len(value) > 1 and not 'drill' in key ]
if ambiguous:
raise SystemError(f'Ambiguous layer names for {", ".join(ambiguous)}')
@@ -224,7 +230,14 @@ class LayerStack: raise ValueError(f'Multiple matching files found for {key} layer: {", ".join(value)}')
for path in paths:
- if ('outline' in key or 'drill' in key) and identify_file(path.read_text()) != 'gerber':
+ id_result = identify_file(path.read_text())
+ print('id_result', id_result)
+ if ('outline' in key or 'drill' in key) and id_result != 'gerber':
+ if id_result is None:
+ # Since e.g. altium uses ".txt" as the extension for its drill files, we have to assume the
+ # current file might not be a drill file after all.
+ continue
+
if 'nonplated' in key:
plated = False
elif 'plated' in key:
|