Author: johannes Date: 2007-12-06 09:37:09 -0600 (Thu, 06 Dec 2007) New Revision: 9840
Removed: trunk/gnue-common/src/setup/ChangeLog.py Log: Module is no longer needed Deleted: trunk/gnue-common/src/setup/ChangeLog.py =================================================================== --- trunk/gnue-common/src/setup/ChangeLog.py 2007-12-06 15:09:28 UTC (rev 9839) +++ trunk/gnue-common/src/setup/ChangeLog.py 2007-12-06 15:37:09 UTC (rev 9840) @@ -1,213 +0,0 @@ -# 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) _______________________________________________ commit-gnue mailing list commit-gnue@gnu.org http://lists.gnu.org/mailman/listinfo/commit-gnue