IAP GITLAB

Skip to content
Snippets Groups Projects
Commit ebe51245 authored by ralfulrich's avatar ralfulrich
Browse files

python3

parent 3bedd301
No related branches found
No related tags found
1 merge request!123Copyright
This commit is part of merge request !123. Comments created here will be created in the context of that merge request.
#!/usr/bin/python #!/usr/bin/env python3
import os import os
import sys, getopt import sys, getopt
...@@ -69,9 +69,9 @@ def checkNote(filename): ...@@ -69,9 +69,9 @@ def checkNote(filename):
if Debug>0: if Debug>0:
txt = "states: n=" + str(len(startNote)) txt = "states: n=" + str(len(startNote))
for i in xrange(len(startNote)): for i in range(len(startNote)):
txt += ", [" + str(startNote[i]) + "-" + str(endNote[i]) + "]" txt += ", [" + str(startNote[i]) + "-" + str(endNote[i]) + "]"
print ("stats: ") + txt print ("stats: " + txt)
# now check if first copyright notices is already identical... # now check if first copyright notices is already identical...
isSame = False isSame = False
...@@ -86,7 +86,7 @@ def checkNote(filename): ...@@ -86,7 +86,7 @@ def checkNote(filename):
if not re.match(regex, lines[startNote[0]+iLine].strip(" \n")): if not re.match(regex, lines[startNote[0]+iLine].strip(" \n")):
isSame = False isSame = False
foundMissing = True foundMissing = True
print "needs update: " + filename + " new=\'" + noteLines[iLine+1] + "\' vs old=\'" + lines[startNote[0]+iLine].rstrip('\n') + "\'" print ("needs update: " + filename + " new=\'" + noteLines[iLine+1] + "\' vs old=\'" + lines[startNote[0]+iLine].rstrip('\n') + "\'")
break break
if Debug>0: if Debug>0:
print ("isSame=" + str(isSame) + " " + str(len(startNote))) print ("isSame=" + str(isSame) + " " + str(len(startNote)))
...@@ -118,7 +118,7 @@ def checkNote(filename): ...@@ -118,7 +118,7 @@ def checkNote(filename):
inBlock = False inBlock = False
for iBlock in range(len(startNote)): for iBlock in range(len(startNote)):
if iLine>=startNote[iBlock] and iLine<=endNote[iBlock]: if iLine>=startNote[iBlock] and iLine<=endNote[iBlock]:
print " [remove " + str(iBlock) + "] " + (lines[iLine]).strip() print (" [remove " + str(iBlock) + "] " + (lines[iLine]).strip())
inBlock = True inBlock = True
skip = True skip = True
...@@ -175,23 +175,23 @@ def main(argv): ...@@ -175,23 +175,23 @@ def main(argv):
try: try:
opts, args = getopt.getopt(argv, "cAhd:", ["check", "add=", "debug="]) opts, args = getopt.getopt(argv, "cAhd:", ["check", "add=", "debug="])
except getopt.GetoptError: except getopt.GetoptError:
print 'do-copyright.py [--check] [--add=YEAR] [--debug=0]' print ('do-copyright.py [--check] [--add=YEAR] [--debug=0]')
sys.exit(2) sys.exit(2)
for opt, arg in opts: for opt, arg in opts:
if opt == '-h': if opt == '-h':
print 'do-copyright.py [--check] [--add=YEAR] [--debug=0]' print ('do-copyright.py [--check] [--add=YEAR] [--debug=0]')
sys.exit() sys.exit()
elif opt in ("-c", "--check"): elif opt in ("-c", "--check"):
justCheck = True justCheck = True
elif opt in ("-A", "--add"): elif opt in ("-A", "--add"):
justCheck = False justCheck = False
forYear = str(arg) forYear = str(arg)
print 'Adding \'Copyright ' + forYear + '\' notice, where needed. ' print ('Adding \'Copyright ' + forYear + '\' notice, where needed. ')
elif opt in ("-d", "--debug"): elif opt in ("-d", "--debug"):
Debug = int(arg) Debug = int(arg)
if justCheck: if justCheck:
print 'Only checking. No changes. See \'do-copyright.py -h\' for options.' print ('Only checking. No changes. See \'do-copyright.py -h\' for options.')
for root, dirs, files in os.walk('./'): for root, dirs, files in os.walk('./'):
next_file(root, files) next_file(root, files)
...@@ -204,5 +204,5 @@ if __name__ == "__main__": ...@@ -204,5 +204,5 @@ if __name__ == "__main__":
if justCheck and foundMissing: if justCheck and foundMissing:
sys.exit(-1) # found error sys.exit(-1) # found error
print "Finished" print ("Finished")
sys.exit(0) sys.exit(0)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment