fix update-copyright when there is only year without author

Otherwise the script would fail on this file:

qtlocation/src/3rdparty/mapbox-gl-native/deps/boost/1.65.1/include/boost/preprocessor/cat.hpp

Which matches this (author is not mentioned) :
Copyright (C) 2001

Error reported before the fix:

  File ".../debian/scripts/update-copyright", line 114, in parse_file
    if copyright[4] == '-':
IndexError: string index out of range
ci/unstable
tenzap 3 years ago
parent 9518e1ec09
commit 09a7d3c05d

@ -108,14 +108,17 @@ def parse_file(filename):
if match:
copyright = match.group(1)
max_year = min_year = int(copyright[:4])
if copyright[4] == '-':
max_year = int(copyright[5:9])
author = copyright[10:]
elif copyright[4:7] == ' - ':
max_year = int(copyright[7:11])
author = copyright[12:]
if len(copyright) >= 5:
if copyright[4] == '-':
max_year = int(copyright[5:9])
author = copyright[10:]
elif copyright[4:7] == ' - ':
max_year = int(copyright[7:11])
author = copyright[12:]
else:
author = copyright[5:]
else:
author = copyright[5:]
author = ""
author = canonicalize_author_name(author)
authors.append((min_year, max_year, author))
match = header_re.search(line)

Loading…
Cancel
Save