Merge pull request #87 from ju5t/full-filename-regex

Match full filename instead of the base name
This commit is contained in:
Hamilton Kibbe 2018-06-27 12:31:00 -05:00 committed by GitHub
commit 7c20bd3699
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 4 deletions

View file

@ -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]

View file

@ -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=[]
),
]