/usr/lib/python3/dist-packages/pyutilib/dev/checkCopyright.py is in python3-pyutilib 5.3.5-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 | #!/usr/bin/env python
#
# A script that verifies that suitable copyright statements are
# defined in files.
#
import sys
import os
import re
suffixes = ['.c', '.cc', '.h', '.H', '.cpp', '.py']
def recurse(dir):
for root, dirnames, filenames in os.walk(dir):
for filename in filenames:
for suffix in suffixes:
if filename.endswith(suffix):
yield os.path.join(root,filename)
def match(filename, pat):
INPUT = open(filename,'r')
fstring = INPUT.read()
INPUT.close()
if pat.search(fstring):
return True
return False
def main():
nfiles = 0
badfiles = []
if sys.argv[1] == '-c':
cfile = sys.argv[2]
files = sys.argv[3:]
INPUT = open(cfile, 'r')
cstring = INPUT.read()
INPUT.close()
pat = re.compile(cstring)
else:
cfile = None
cstring = None
pat = re.compile('Copyright')
files = sys.argv[1:]
for dir_ in files:
for filename in recurse(dir_):
nfiles += 1
if not match(filename, pat):
badfiles.append(filename)
print("Total number of files missing copyright: "+str(len(badfiles)))
print("Total number of files checked: "+str(nfiles))
if len(badfiles) > 0:
print("")
print("Bad Files")
print("-" * 40)
for filename in badfiles:
print(filename)
if __name__ == '__main__':
main()
|