Skip to content

Commit

Permalink
Simplify overly complicated regex
Browse files Browse the repository at this point in the history
To use re module just to get the basename without the extension is
not pythonic ;)
=> Use os.path.splitext and os.path.basename which is more readable.
  • Loading branch information
tomschr committed Sep 30, 2016
1 parent 68d8317 commit d64cacc
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions src/sdsc/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -677,8 +677,7 @@ def initialize():

for checkfile in checkfiles:
try:
checkmodule = re.sub(r'^.*/', r'', checkfile)
checkmodule = re.sub(r'.xslc$', r'', checkmodule)
checkmodule = os.path.splitext(os.path.basename(checkfile))[0]
transform = etree.XSLT(etree.parse(checkfile, XMLParser))
prepared_checks.append({'name': checkmodule, 'transform': transform})
except Exception as error:
Expand Down

0 comments on commit d64cacc

Please sign in to comment.