Skip to content

Commit

Permalink
Use named capture groups
Browse files Browse the repository at this point in the history
  • Loading branch information
BPerlakiH committed Jan 10, 2024
1 parent f71241d commit ac408ad
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/info_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,9 +126,10 @@ def _filename_from(self, url):
return os.path.splitext(os.path.basename(urlparse(url).path))[0]

def _app_version_from(self, file_name):
m = re.search('\d{4}-\d{1,2}', file_name)
yearMonth = m.group(0)
(year, month) = map(lambda x: int(x), yearMonth.split("-"))
p = re.compile('(?P<year>\d{4})-(?P<month>\d{1,2})')
m = p.search(file_name)
year = int(m.group('year'))
month = int(m.group('month'))
assert (year > 2000)
assert (month > 0)
assert (month <= 12)
Expand Down

0 comments on commit ac408ad

Please sign in to comment.