Skip to content

Commit

Permalink
Exit with error code if unable to parse copyright line
Browse files Browse the repository at this point in the history
  • Loading branch information
lballabio committed Jun 29, 2021
1 parent d2dd2df commit d32f1b0
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 6 deletions.
@@ -1,7 +1,7 @@
/* -*- mode: c++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */

/*
Copyright (C) 2021, Marcin Rybacki
Copyright (C) 2021 Marcin Rybacki
This file is part of QuantLib, a free-software/open-source library
for financial quantitative analysts and developers - http://quantlib.org/
Expand Down
@@ -1,7 +1,7 @@
/* -*- mode: c++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */

/*
Copyright (C) 2021, Marcin Rybacki
Copyright (C) 2021 Marcin Rybacki
This file is part of QuantLib, a free-software/open-source library
for financial quantitative analysts and developers - http://quantlib.org/
Expand Down
4 changes: 2 additions & 2 deletions ql/math/randomnumbers/primitivepolynomials.cpp
Expand Up @@ -6,11 +6,11 @@
modulo two up to degree 27. Both are slightly edited versions of
PrimitivePolynomialsModuloTwoUpToDegree27.c
© 2002 "Monte Carlo Methods in Finance"
© 2002 "Monte Carlo Methods in Finance"
=========================================================================
Copyright (C) 2002 Peter Jäckel "Monte Carlo Methods in Finance".
Copyright (C) 2002 Peter Jäckel "Monte Carlo Methods in Finance".
All rights reserved.
Permission to use, copy, modify, and distribute this software is freely
Expand Down
2 changes: 1 addition & 1 deletion tools/check_copyrights.sh
Expand Up @@ -2,5 +2,5 @@
#
# Run this from the main QuantLib directory

grep -r --include='*.[hc]pp' "Copyright (C)" * | ./tools/collect_copyrights.py > LICENSE.TXT
grep -r --include='*.[hc]pp' "^ *Copyright (C)" * | ./tools/collect_copyrights.py > LICENSE.TXT

6 changes: 5 additions & 1 deletion tools/collect_copyrights.py
Expand Up @@ -8,13 +8,14 @@
regex2 = re.compile(r"Copyright \(C\) (([0-9]{4})(, [0-9]{4})*) (.+)$")

copyrights = {}
errors = False

for line in sys.stdin:
m1 = regex1.search(line)
m2 = regex2.search(line)
if m1 is None and m2 is None:
sys.stderr.write("Could not parse '%s'\n" % line.strip())
continue
errors = True
if m1:
first, last = [int(y) for y in m1.groups()[0].split("-")]
years = range(first, last + 1)
Expand All @@ -27,6 +28,9 @@
s.add(y)
copyrights[owner] = s

if errors:
exit(1)

for owner in copyrights:
s = copyrights[owner]
l = [y for y in s]
Expand Down

0 comments on commit d32f1b0

Please sign in to comment.