Match full filename instead of the base name

Regular expressions only matched the base name. This matches the
entire filename which allows for more advanced regular expressions.
refactor
ju5t 2018-06-26 22:17:45 +02:00
rodzic 31062ba2ce
commit 8dd8a87fc0
2 zmienionych plików z 4 dodań i 4 usunięć

Wyświetl plik

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

Wyświetl plik

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