commit-gnue
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[gnue] r9839 - in trunk/gnue-common: . src/setup utils


From: johannes
Subject: [gnue] r9839 - in trunk/gnue-common: . src/setup utils
Date: Thu, 6 Dec 2007 09:09:28 -0600 (CST)

Author: johannes
Date: 2007-12-06 09:09:28 -0600 (Thu, 06 Dec 2007)
New Revision: 9839

Added:
   trunk/gnue-common/utils/changelog.py
Modified:
   trunk/gnue-common/setup.py
   trunk/gnue-common/src/setup/GSetup.py
   trunk/gnue-common/utils/update-tool-docs
Log:
ChangeLog is moved into utils and built by update-tools-docs now, 
instead of GSetup.py or setup.py


Modified: trunk/gnue-common/setup.py
===================================================================
--- trunk/gnue-common/setup.py  2007-12-06 10:37:35 UTC (rev 9838)
+++ trunk/gnue-common/setup.py  2007-12-06 15:09:28 UTC (rev 9839)
@@ -26,7 +26,6 @@
 import sys
 import os
 
-from src.setup import ChangeLog
 from src.utils import version
 
 from src import TITLE, PACKAGE, VERSION
@@ -120,11 +119,6 @@
 
         # ---------------------------------------------------------------------
 
-        if action == 'sdist':
-            # build ChangeLog file
-            log.info('building ChangeLog')
-            ChangeLog.build()
-
         # build translations
         if os.path.isdir('po'):
             log.info("building translations")

Modified: trunk/gnue-common/src/setup/GSetup.py
===================================================================
--- trunk/gnue-common/src/setup/GSetup.py       2007-12-06 10:37:35 UTC (rev 
9838)
+++ trunk/gnue-common/src/setup/GSetup.py       2007-12-06 15:09:28 UTC (rev 
9839)
@@ -39,7 +39,6 @@
 import gnue.paths
 
 from gnue.common.utils import version
-from gnue.common.setup import ChangeLog
 
 __all__ = ['GSetup']
 
@@ -426,11 +425,6 @@
 
             # -----------------------------------------------------------------
 
-            if action == 'sdist':
-                # build ChangeLog file
-                log.info("building ChangeLog")
-                ChangeLog.build()
-
             # build translations
             if os.path.isdir('po'):
                 log.info("building translations")

Added: trunk/gnue-common/utils/changelog.py
===================================================================
--- trunk/gnue-common/utils/changelog.py        2007-12-06 10:37:35 UTC (rev 
9838)
+++ trunk/gnue-common/utils/changelog.py        2007-12-06 15:09:28 UTC (rev 
9839)
@@ -0,0 +1,217 @@
+#!/usr/bin/python
+# GNU Enterprise Common Library - ChangeLog creation
+#
+# This file is part of GNU Enterprise.
+#
+# GNU Enterprise is free software; you can redistribute it
+# and/or modify it under the terms of the GNU General Public
+# License as published by the Free Software Foundation; either
+# version 2, or (at your option) any later version.
+#
+# GNU Enterprise is distributed in the hope that it will be
+# useful, but WITHOUT ANY WARRANTY; without even the implied
+# warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
+# PURPOSE. See the GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public
+# License along with program; see the file COPYING. If not,
+# write to the Free Software Foundation, Inc., 59 Temple Place
+# - Suite 330, Boston, MA 02111-1307, USA.
+#
+# Copyright 2001-2007 Free Software Foundation
+#
+# $Id$
+"""
+Build a ChangeLog file based on the log information from subversion
+"""
+
+import xml.parsers.expat
+import tempfile
+import os
+import sys
+
+
+__all__ = ['Parser', 'build']
+
+SVNCMD = 'svn log -v --xml'
+
+# =============================================================================
+# The Parser
+# =============================================================================
+
+class Parser:
+    """
+    An EXPAT parser for the XML log information from SubVersion.
+    """
+
+    # -------------------------------------------------------------------------
+    # Constructor
+    # -------------------------------------------------------------------------
+
+    def __init__(self, infile, outfile):
+
+        self.out = outfile
+        self.package = os.path.basename(os.getcwd())
+
+        parser = xml.parsers.expat.ParserCreate()
+
+        parser.StartElementHandler = self.start_element
+        parser.EndElementHandler = self.end_element
+        parser.CharacterDataHandler = self.char_data
+
+        self.paths = []
+        self.revision = ''
+        self.date = ''
+        self.author = ''
+        self.text = ''
+
+        parser.ParseFile(infile)
+
+
+    # -------------------------------------------------------------------------
+    # Start of an XML element
+    # -------------------------------------------------------------------------
+
+    def start_element(self, name, attrs):
+        """
+        Called for the start of every element.
+
+        @param name: Name of the element started
+        @type name: string
+        @param attrs: a dictionary mapping attribute names to their values
+        @type attrs: dictionary
+        """
+
+        self.text = ''
+
+        if name == 'logentry':
+            self.revision = attrs['revision'].ljust(5)
+
+        elif name == 'paths':
+            self.paths = []
+
+
+    # -------------------------------------------------------------------------
+    # End of an XML element
+    # -------------------------------------------------------------------------
+
+    def end_element(self, name):
+        """
+        Called for the end of every element
+
+        @param name: name of the element ended
+        @type name: string
+        """
+
+        if name == 'logentry':
+            self.out.write('\n')
+
+        elif name == 'author':
+            self.author = self.text
+
+        elif name == 'path':
+            parts = self.text.split('/', 3)
+            if len(parts) == 4:
+                if parts[2] == self.package:
+                    self.paths.append(parts[3])
+
+        elif name == 'msg':
+            self.out.write('%s  Rev %s  %s\n\n' % \
+                            (self.date, self.revision, self.author))
+            text = '%s: %s' % (', '.join(self.paths), self.text)
+            self.out.write('\t* %s' % linewrap(text))
+
+        elif name == 'date':
+            self.date = self.text[:10] + ' ' + self.text[11:19]
+
+
+    # -------------------------------------------------------------------------
+    # Contents of an XML element
+    # -------------------------------------------------------------------------
+
+    def char_data(self, data):
+        """
+        Called for character data including normal character data, CDATA marked
+        content and ignorable whitespace.
+
+        @param data: the data being processed
+        @type data: string
+        """
+        self.text += data.encode('ascii','replace')
+
+
+# -----------------------------------------------------------------------------
+# Helper function to wrap long lines
+# -----------------------------------------------------------------------------
+
+def linewrap(message, max_width=69, indent = '\t  '):
+    """
+    Fold the given message so it fits into a ChangeLog entry
+
+    @param message: the message to be folded
+    @param max_width: the maximum width of a line
+    @param indent: the indentation of each line
+
+    @returns: folded message
+    """
+
+    text = ''
+
+    temptext = str(message).strip()
+    temptext = temptext.replace('\n\n', '\r')
+    temptext = temptext.replace('\n', ' ')
+
+    buff = temptext.split('\r')
+
+    for strings in buff:
+        while len(strings) > max_width:
+
+            index = strings.rfind(' ', 0, max_width)
+
+            if index > 0:
+                line = strings[:index]
+            else:
+                line = strings[:max_width]
+                index = max_width - 1
+
+            if text != '':
+                text += indent
+            text += '%s\n' % line
+            strings = strings[index+1:]
+            strings = strings.strip()
+
+        line = strings
+        if text != '':
+            text += indent
+        text += '%s\n' % line
+
+    return text
+
+
+# -----------------------------------------------------------------------------
+# Build the ChangeLog file
+# -----------------------------------------------------------------------------
+
+def build():
+    """
+    Create the ChangeLog file
+    """
+    filename = tempfile.mktemp('xml')
+    if os.system(SVNCMD + '> %s' % filename):
+        print 'Unable to retrieve svn log'
+        sys.exit(1)
+
+    inp = open(filename)
+    out = open('ChangeLog' ,'w')
+
+    try:
+        Parser(inp, out)
+
+    finally:
+        inp.close()
+        out.close()
+
+        os.unlink(filename)
+
+if __name__ == '__main__':
+    build()


Property changes on: trunk/gnue-common/utils/changelog.py
___________________________________________________________________
Name: svn:executable
   + *
Name: svn:keywords
   + Id

Modified: trunk/gnue-common/utils/update-tool-docs
===================================================================
--- trunk/gnue-common/utils/update-tool-docs    2007-12-06 10:37:35 UTC (rev 
9838)
+++ trunk/gnue-common/utils/update-tool-docs    2007-12-06 15:09:28 UTC (rev 
9839)
@@ -45,16 +45,23 @@
   build_docs_schema
 }
 
+build_changelog() {
+  echo "Building ChangeLog for $1 ..."
+  (cd "gnue-$1"; ../gnue-common/utils/changelog.py)
+}
+
 case "$1" in
   forms|reports|schema|designer|appserver|navigator|common)
     echo Building docs for $1.....
     build_docs_$1
+    build_changelog $1
     ;;
   *)
     for name in forms reports schema designer navigator
       do 
         echo Building docs for $name.....
         build_docs_$name
+        build_changelog $name
       done
     # Quick check
 





reply via email to

[Prev in Thread] Current Thread [Next in Thread]