mailr16887 - /trunk/scripts/log_converter.py


Others Months | Index by Date | Thread Index
>>   [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Header


Content

Posted by edward on June 12, 2012 - 21:12:
Author: bugman
Date: Tue Jun 12 21:12:00 2012
New Revision: 16887

URL: http://svn.gna.org/viewcvs/relax?rev=16887&view=rev
Log:
Created a script for converting svn logs into the format for release messages.


Added:
    trunk/scripts/log_converter.py   (with props)

Added: trunk/scripts/log_converter.py
URL: 
http://svn.gna.org/viewcvs/relax/trunk/scripts/log_converter.py?rev=16887&view=auto
==============================================================================
--- trunk/scripts/log_converter.py (added)
+++ trunk/scripts/log_converter.py Tue Jun 12 21:12:00 2012
@@ -1,0 +1,67 @@
+#! /usr/bin/python
+
+"""Convert SVN logs into the format for the "Full list of changes" component 
of the release message."""
+
+# Python module imports.
+from os import F_OK, access
+from re import search
+import sys
+
+
+# Test for a single argument.
+if len(sys.argv) == 1:
+    sys.stderr.write("A file name must be given.\n")
+    sys.exit()
+elif len(sys.argv) != 2:
+    sys.stderr.write("Only a single argument is allowed.\n")
+    sys.exit()
+
+# Test that the argument is a file.
+if not access(sys.argv[1], F_OK):
+    sys.stderr.write(`sys.argv[1]` + " is not accessible as a file.\n")
+    sys.exit()
+
+# Open the file, read the lines, then close it.
+file = open(sys.argv[1], 'r')
+lines = file.readlines()
+file.close()
+
+# Loop over the lines, determining what to do next.
+msg = ''
+for line in lines:
+    # The separator, so reinitialise everything.
+    if search('-----', line):
+        # First, print the old message.
+        print("        * " + msg)
+
+        # Reinitialise.
+        msg = ''
+
+        # Go to the next line.
+        continue
+
+    # The header line.
+    if search('^r[1-9][0-9]', line):
+        continue
+
+    # The 'Changed paths' line.
+    if search('^Changed', line):
+        continue
+
+    # Files and svn message.
+    if search('^  ', line):
+        continue
+
+    # Svnmerge sep.
+    if search('^\.\.\.\.', line):
+        continue
+
+    # Whitespace.
+    if len(msg):
+        if search('[a-zA-Z]$', msg[-1]):
+            msg += ' '
+        elif search('\.$', msg[-1]):
+            msg += '  '
+
+    # Add the line (without the newline char).
+    msg += line[:-1]

Propchange: trunk/scripts/log_converter.py
------------------------------------------------------------------------------
    svn:executable = *




Related Messages


Powered by MHonArc, Updated Tue Jun 12 23:40:02 2012