#!/usr/bin/env python import os,sys,re,os.path,time from cStringIO import StringIO from datetime import date from optparse import OptionParser from string import Template module=None namespace={ 'prog':None, 'author':None, 'author_email':None, 'url':None, 'description':None, 'long_description': None, 'packages': None, 'cvs_version':None, 'release_version':None, 'version':None, 'codename': None, 'release_date':None, # should stat the file instead 'release_file':None, 'today':date.today().strftime("%d %B %Y"), 'year':date.today().strftime("%Y"), 'yearstart':'2006', 'htmlBody':'', 'preBody':'', } def findLongDescription(): # skip the opening one-line description and grab the first paragraph # out of the module's docstring to use as the long description. long_description = '' lines = module.__doc__.splitlines() for firstline in range(len(lines)): # skip until we reach a blank line if len(lines[firstline])==0 or lines[firstline].isspace(): break if firstline=0: count+=1 doc.write(line) unparsed=fh.read() t=Template(doc.getvalue()) out=t.safe_substitute(namespace) return out+unparsed def parsechangelog(infile): if isinstance(infile, str): fh = open(infile) else: fh = infile doc=StringIO() doc.write("

ChangeLog

") release_date = '' version = '' show_items = False for line in fh: match=re.match('(\d+-\d+-\d+).*',line) if match: if show_items: doc.write("\n") show_items = False print 'found date %s' % match.group(1) release_date=date.fromtimestamp(time.mktime(time.strptime(match.group(1),'%Y-%m-%d'))).strftime('%d %B %Y') else: match=re.match('\s+\*\s*[Rr]eleased peppy-([\d\.]+)',line) if match: print 'found version %s' % match.group(1) version=match.group(1) doc.write("

%s, released %s

\n