Skip to content

Commit f63abf3

Browse files
committed
Bug fix for optional capture groups (fixes #26)
1 parent c6f5d32 commit f63abf3

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

rotate_backups/__init__.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -677,12 +677,13 @@ def match_to_datetime(self, match):
677677
.. seealso:: :data:`SUPPORTED_DATE_COMPONENTS`
678678
"""
679679
kw = {}
680+
captures = match.groupdict()
680681
for component, required in SUPPORTED_DATE_COMPONENTS:
681-
value = match.group(component)
682+
value = captures.get(component)
682683
if value:
683684
kw[component] = int(value, 10)
684685
elif required:
685-
raise ValueError("Missing required date component! (%s)!" % component)
686+
raise ValueError("Missing required date component! (%s)" % component)
686687
else:
687688
kw[component] = 0
688689
return datetime.datetime(**kw)

0 commit comments

Comments
 (0)