|
|
@ -200,6 +200,18 @@ def log(cond, why, filename): |
|
|
|
print(filename) |
|
|
|
print(filename) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def write_copyright(license_text, file_text, filename): |
|
|
|
|
|
|
|
shebang = "" |
|
|
|
|
|
|
|
lines = file_text.split("\n") |
|
|
|
|
|
|
|
if lines and lines[0].startswith("#!"): |
|
|
|
|
|
|
|
shebang = lines[0] + "\n" |
|
|
|
|
|
|
|
file_text = file_text[len(shebang):] |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
rewritten_text = shebang + license_text + "\n" + file_text |
|
|
|
|
|
|
|
with open(filename, 'w') as f: |
|
|
|
|
|
|
|
f.write(rewritten_text) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# scan files, validate the text |
|
|
|
# scan files, validate the text |
|
|
|
ok = True |
|
|
|
ok = True |
|
|
|
filename_list = [] |
|
|
|
filename_list = [] |
|
|
@ -236,8 +248,7 @@ for filename in filename_list: |
|
|
|
pass |
|
|
|
pass |
|
|
|
elif 'DO NOT EDIT' not in text: |
|
|
|
elif 'DO NOT EDIT' not in text: |
|
|
|
if args.fix: |
|
|
|
if args.fix: |
|
|
|
text = license_text + '\n' + text |
|
|
|
write_copyright(license_text, text, filename) |
|
|
|
open(filename, 'w').write(text) |
|
|
|
|
|
|
|
log(1, 'copyright missing (fixed)', filename) |
|
|
|
log(1, 'copyright missing (fixed)', filename) |
|
|
|
else: |
|
|
|
else: |
|
|
|
log(1, 'copyright missing', filename) |
|
|
|
log(1, 'copyright missing', filename) |
|
|
|