Python 2 EOL: migrate gitlog2changelog.py to Python 3
[claws.git] / tools / gitlog2changelog.py
index 82fc4491ccdf7bfd348e5fce31f4a825cafef35a..e331a5b66f9132dedd2d83da5a353b0bc206076d 100755 (executable)
@@ -1,4 +1,4 @@
-#!/usr/bin/python
+#!/usr/bin/env python3
 # Copyright 2008 Marcus D. Hanwell <marcus@cryos.org>
 # Adapted for Claws Mail - Copyright 2013 Colin Leroy <colin@colino.net>
 # Distributed under the terms of the GNU General Public License v2 or later
@@ -40,7 +40,7 @@ prevAuthorLine = ""
 # The main part of the loop
 for line in fin:
     # The commit line marks the start of a new commit object.
-    if re.match('^commit', line) >= 0:
+    if re.match('^commit', line):
         # Start all over again...
         authorFound = False
         dateFound = False
@@ -49,30 +49,30 @@ for line in fin:
         message = ""
         filesFound = False
         files = ""
-       commitCmd = os.popen("git describe "+re.split(' ', line, 1)[1])
-       commit = commitCmd.read()
-       commitCmd.close()
+        commitCmd = os.popen("git describe "+re.split(' ', line, 1)[1])
+        commit = commitCmd.read()
+        commitCmd.close()
         commit = commit[0:len(commit)-1]
         continue
     # Match the author line and extract the part we want
-    elif re.match('^Author:', line) >=0:
+    elif re.match('^Author:', line):
         authorList = re.split(': ', line, 1)
         author = re.split('<', authorList[1], 1)[0]
         author = "[" + author[0:len(author)-1]+"]"
         authorFound = True
-       continue
+        continue
     # Match the date line
-    elif re.match('^Date:', line) >= 0:
+    elif re.match('^Date:', line):
         dateList = re.split(':   ', line, 1)
         date = dateList[1]
         date = date[0:len(date)-1]
         dateFound = True
-       continue
+        continue
     # The svn-id lines are ignored
-    elif re.match('    git-svn-id:', line) >= 0:
+    elif re.match('    git-svn-id:', line):
         continue
     # The sign off line is ignored too
-    elif re.search('Signed-off-by', line) >= 0:
+    elif re.search('Signed-off-by', line) != None:
         continue
     # Extract the actual commit message for this commit
     elif authorFound & dateFound & messageFound == False:
@@ -90,7 +90,7 @@ for line in fin:
             else:
                 message = message + " " + line.strip()
     # If this line is hit all of the files have been stored for this commit
-    elif re.search('file(s)? changed', line) >= 0:
+    elif re.search('file(s)? changed', line) != None:
         filesFound = True
         continue
     # Collect the files for this commit. FIXME: Still need to add +/- to files
@@ -107,8 +107,8 @@ for line in fin:
         # author on this day
         authorLine = date + "  " + author
         if len(prevAuthorLine) != 0:
-           fout.write("\n");
-       fout.write(authorLine + " " + commit + "\n\n")
+            fout.write("\n");
+        fout.write(authorLine + " " + commit + "\n\n")
 
         # Assemble the actual commit message line(s) and limit the line length
         # to 80 characters.
@@ -128,7 +128,7 @@ for line in fin:
                 i = i+71
 
         # Write out the commit line
-       fout.write(files + "\t\t" + commit + "\n")
+        fout.write(files + "\t\t" + commit + "\n")
 
         #Now reset all the variables ready for a new commit block.
         authorFound = False