Skip to content
This repository has been archived by the owner on Jun 19, 2024. It is now read-only.

Commit

Permalink
Merge pull request #87 from ju5t/full-filename-regex
Browse files Browse the repository at this point in the history
Match full filename instead of the base name
  • Loading branch information
hamiltonkibbe authored Jun 27, 2018
2 parents 66a1a1c + 8dd8a87 commit 7c20bd3
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
6 changes: 3 additions & 3 deletions gerber/layers.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,11 +122,11 @@ def guess_layer_class(filename):
pass

try:
directory, name = os.path.split(filename)
name, ext = os.path.splitext(name.lower())
directory, filename = os.path.split(filename)
name, ext = os.path.splitext(filename.lower())
for hint in hints:
if hint.regex:
if re.findall(hint.regex, name, re.IGNORECASE):
if re.findall(hint.regex, filename, re.IGNORECASE):
return hint.layer

patterns = [r'^(\w*[.-])*{}([.-]\w*)?$'.format(x) for x in hint.name]
Expand Down
2 changes: 1 addition & 1 deletion gerber/tests/test_layers.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ def test_guess_layer_class_regex():
Hint(layer='top',
ext=[],
name=[],
regex=r'(.*)(\scopper top|\stop copper)$',
regex=r'(.*)(\scopper top|\stop copper).gbr',
content=[]
),
]
Expand Down

0 comments on commit 7c20bd3

Please sign in to comment.