Skip to content

Commit

Permalink
Fix crash when licenseupdate.py can't find a '{year}' in .styleguide-…
Browse files Browse the repository at this point in the history
…license

This gives __try_regex() the same behavior as __try_string_search(),
which defaults the first year to the last year in the copyright range.
  • Loading branch information
calcmogul committed Jan 8, 2020
1 parent fed03cd commit ee7407c
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion wpiformat/wpiformat/licenseupdate.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ def __try_regex(self, lines, last_year, license_template):
r"(?P<year>[0-9]+)(-[0-9]+)?").replace("{padding}", "[ ]*")
license_rgx = regex.compile(license_rgxstr, regex.M)

first_year = last_year

# Compare license
match = license_rgx.search(lines)
if match:
Expand All @@ -51,7 +53,7 @@ def __try_regex(self, lines, last_year, license_template):
# If comment at beginning of file is non-empty license, update it
return (True, first_year, linesep + lines[match.end():].lstrip())
else:
return (False, last_year, lines)
return (False, first_year, lines)

def __try_string_search(self, lines, last_year, license_template):
"""Try finding license with string search.
Expand Down

0 comments on commit ee7407c

Please sign in to comment.