[Python-checkins] r55980 - sandbox/trunk/pep0/pep0/__init__.py sandbox/trunk/pep0/pep0/authors.py sandbox/trunk/pep0/pep0/constants.py sandbox/trunk/pep0/pep0/output.py sandbox/trunk/pep0/pep0/parse.py sandbox/trunk/pep0/pep0/pep.py sandbox/trunk/pep0/pep0/statictext.py
brett.cannon
python-checkins at python.org
Fri Jun 15 04:35:55 CEST 2007
Author: brett.cannon
Date: Fri Jun 15 04:35:52 2007
New Revision: 55980
Added:
sandbox/trunk/pep0/pep0/constants.py (contents, props changed)
Removed:
sandbox/trunk/pep0/pep0/authors.py
sandbox/trunk/pep0/pep0/statictext.py
Modified:
sandbox/trunk/pep0/pep0/__init__.py
sandbox/trunk/pep0/pep0/output.py
sandbox/trunk/pep0/pep0/parse.py
sandbox/trunk/pep0/pep0/pep.py
Log:
Update code to use pep.PEP object representation.
Along the way consolidate some functionality in more proper modules.
Modified: sandbox/trunk/pep0/pep0/__init__.py
==============================================================================
--- sandbox/trunk/pep0/pep0/__init__.py (original)
+++ sandbox/trunk/pep0/pep0/__init__.py Fri Jun 15 04:35:52 2007
@@ -17,101 +17,18 @@
if __name__ == '__main__':
from pep0.parse import consume_directory, consume_pep
- from pep0.pep import sort_peps, PEP
- from pep0.output import write_column_headers, write_pep
- from pep0.statictext import header, intro, references, footer
+ from pep0.output import write_pep0
- import os
+ from os.path import isdir
from sys import argv, stdout
if not argv[1:]:
path = '.'
else:
path = argv[1]
- if os.path.isdir(path):
+ if isdir(path):
peps = consume_directory(path)
else:
peps = [consume_pep(path)]
- print header
- print
- print "Introduction"
- print intro
- print
- print "Index by Category"
- print
- write_column_headers(stdout)
- meta, info, accepted, open_, done, empty, dead = sort_peps(peps)
- print
- print " Meta-PEPs (PEPs about PEPs or Processs)"
- print
- for pep in meta:
- write_pep(pep, stdout)
- print
- print " Other Informational PEPs"
- print
- for pep in info:
- write_pep(pep, stdout)
- print
- print " Accepted PEPs (accepted; may not be implemented yet)"
- print
- for pep in accepted:
- write_pep(pep, stdout)
- print
- print " Open PEPs (under consideration)"
- print
- for pep in open_:
- write_pep(pep, stdout)
- print
- print " Finished PEPs (done, implemented in code repository)"
- print
- for pep in done:
- write_pep(pep, stdout)
- print
- print " Empty PEPs (or containing only abstract)"
- print
- for pep in empty:
- write_pep(pep, stdout)
- print
- print " Deferred, Abandoned, Withdrawn, and Rejected PEPs"
- print
- for pep in dead:
- write_pep(pep, stdout)
- print
- print
- print " Numerical Index"
- print
- write_column_headers(stdout)
- prev_pep = 0
- for pep in peps:
- if pep['PEP'] - prev_pep > 1:
- print
- write_pep(pep, stdout)
- prev_pep = pep['PEP']
- print
- print
- print "Key"
- print
- for type_ in PEP.type_values:
- print " %s - %s PEP" % (type_[0], type_)
- print
- for status in PEP.status_values:
- print " %s - %s proposal" % (status[0], status)
-
- print
- print
- print "Owners"
- print
- # XXX
- # * get "last, first I." of each name.
- # * add nickname.
- # * find longest name.
- # * column headers.
- # * name/email with a two-space separation between longest name and email.
- print ' XXX'
- print
- print
- print "References"
- print
- print references
- print footer
+ write_pep0(peps)
Deleted: /sandbox/trunk/pep0/pep0/authors.py
==============================================================================
--- /sandbox/trunk/pep0/pep0/authors.py Fri Jun 15 04:35:52 2007
+++ (empty file)
@@ -1,108 +0,0 @@
-# -*- coding: utf-8 -*-
-email_addresses = {
- 'Aahz' : 'aahz at pobox.com',
- 'James C. Ahlstrom' : 'jim at interet.com',
- 'Jim Althoff' : 'james_althoff at i2.com',
- 'Kevin Altis' : 'altis at semi-retired.com',
- 'David Ascher' : 'davida at activestate.com',
- 'Peter Astrand' : 'astrand at lysator.liu.se',
- 'Carl Banks' : 'pythondev at aerojockey.com',
- 'Paul Barrett' : 'barrett at stsci.edu',
- 'Facundo Batista' : 'facundo at taniquetil.com.ar',
- 'Anthony Baxter' : 'anthony at interlink.com.au',
- 'Thomas Bellman' : 'bellman+pep-divmod at lysator.liu.se',
- 'Steven Bethard' : 'steven.bethard at gmail.com',
- 'Georg Brandl' : 'g.brandl at gmx.net',
- 'Brett Cannon' : 'brett at python.org',
- 'Josiah Carlson' : 'jcarlson at uci.edu',
- 'W Isaac Carroll' : 'icarroll at pobox.com',
- 'Nick Coghlan' : 'ncoghlan at gmail.com',
- 'Dave Cole' : 'djc at object-craft.com.au',
- 'Christopher Craig' : 'python-pep at ccraig.org',
- 'Laura Creighton' : 'lac at strakt.com',
- 'Walter Dörwald' : '',
- 'Fred L. Drake, Jr.' : 'fdrake at acm.org',
- 'Michael P. Dubner' : 'dubnerm at mindless.com',
- 'Paul F. Dubois' : 'paul at pfdubois.com',
- 'Phillip J. Eby' : 'pje at telecommunity.com',
- 'Micah Elliott' : 'mde at tracos.org',
- 'Jeff Epler' : 'jepler at unpythonic.net',
- 'David Eppstein' : 'eppstein at ics.uci.edu',
- 'Clark C. Evans' : 'cce at clarkevans.com',
- 'Greg Ewing' : 'greg at cosc.canterbury.ac.nz',
- 'Martijn Faassen' : 'faassen at infrae.com',
- 'Ben Finney' : 'ben+python at benfinney.id.au',
- 'Frédéric B. Giacometti' : 'fred at arakne.com',
- 'Scott Gilbert' : 'xscottg at yahoo.com',
- 'David Goodger' : 'goodger at python.org',
- 'Grant Griffin' : 'g2 at iowegian.com',
- 'Mark Hammond' : 'mhammond at skippinet.com.au',
- 'Peter Harris' : 'scav at blueyonder.co.uk',
- 'Thomas Heller' : 'theller at python.net',
- 'Magnus Lie Hetland' : 'magnus at hetland.org',
- 'Raymond D. Hettinger' : 'python at rcn.com',
- 'Neil Hodgson' : 'neilh at scintilla.org',
- 'Michael Hudson' : 'mwh at python.net',
- 'Jeremy Hylton' : 'jeremy at zope.com',
- 'Jack Jansen' : 'jack at cwi.nl',
- 'Jim Jewett' : 'jimjjewett at users.sourceforge.net',
- 'Richard Jones' : 'richard at mechanicalcat.net',
- 'Stepan Koltsov' : 'yozh at mx1.ru',
- 'A.M. Kuchling' : 'amk at amk.ca',
- 'Marc-Andre Lemburg' : 'mal at lemburg.com',
- 'Gregory Lielens' : 'gregory.lielens at fft.be',
- 'Björn Lindqvist' : 'bjourne at gmail.com',
- 'Martin von Löwis' : 'loewis at informatik.hu-berlin.de',
- 'Tony Lownds' : 'tony at pagedna.com',
- 'Alex Martelli' : 'aleax at aleax.it',
- 'Andrew McClelland' : 'eternalsquire at comcast.net',
- 'Gordon McMillan' : 'gmcm at hypernet.com',
- 'Andrew McNamara' : 'andrewm at object-craft.com.au',
- 'Trent Mick' : 'trentm at activestate.com',
- 'Mike Meyer' : 'mwm at mired.org',
- 'Skip Montanaro' : 'skip at pobox.com',
- 'Paul Moore' : 'gustav at morpheus.demon.co.uk',
- 'Ben North' : 'ben at redfrontdoor.org',
- 'Neal Norwitz' : 'nnorwitz at gmail.com',
- 'Travis Oliphant' : 'oliphant at ee.byu.edu',
- 'Jason Orendorff' : 'jason.orendorff at gmail.com',
- 'Samuele Pedroni' : 'pedronis at python.org',
- 'Michel Pelletier' : 'michel at users.sourceforge.net',
- 'Tim Peters' : 'tim at zope.com',
- 'Jason Petrone' : 'jp at demonseed.net',
- 'Paul Prescod' : 'paul at prescod.net',
- 'Terry Reedy' : 'tjreedy at udel.edu',
- 'Sean Reifschneider' : 'jafo-pep at tummy.com',
- 'Christian R. Reis' : 'kiko at async.com.br',
- 'Jonathan Riehl' : 'jriehl at spaceship.com',
- 'André Roberge' : 'andre.roberge at gmail.com',
- 'Guido van Rossum' : 'guido at python.org',
- 'Just van Rossum' : 'just at letterror.com',
- 'Vinay Sajip' : 'vinay_sajip at red-dove.com',
- 'Neil Schemenauer' : 'nas at arctrix.com',
- 'Peter Schneider-Kamp' : 'nowonder at nowonder.de',
- 'Jiwon Seo' : 'seojiwon at gmail.com',
- 'Kevin D. Smith' : 'Kevin.Smith at theMorgue.org',
- 'Greg Stein' : 'gstein at lyra.org',
- 'Daniel Stutzbach' : 'daniel.stutzbach at gmail.com',
- 'Roman Suzi' : 'rnd at onego.ru',
- 'Talin' : 'talin at acm.org',
- 'Steven Taschuk' : 'staschuk at telusplanet.net',
- 'Oren Tirosh' : 'oren at hishome.net',
- 'Mike Verdone' : 'mike.verdone at gmail.com',
- 'Gregory R. Warnes' : 'warnes at users.sourceforge.net',
- 'Barry Warsaw' : 'barry at python.org',
- 'Terence Way' : 'terry at wayforward.net',
- 'Cliff Wells' : 'LogiplexSoftware at earthlink.net',
- 'Greg Wilson' : 'gvwilson at ddj.com',
- 'Collin Winter' : 'collinw at gmail.com',
- 'Thomas Wouters' : 'thomas at python.org',
- 'Ka-Ping Yee' : 'ping at zesty.ca',
- 'Moshe Zadka' : 'moshez at zadka.site.co.il',
- 'Huaiyu Zhu' : 'hzhu at users.sourceforge.net',
-}
-
-nicknames = {
- 'Guido van Rossum' : 'GvR',
- 'Just van Rossum' : 'JvR',
-}
Added: sandbox/trunk/pep0/pep0/constants.py
==============================================================================
--- (empty file)
+++ sandbox/trunk/pep0/pep0/constants.py Fri Jun 15 04:35:52 2007
@@ -0,0 +1,149 @@
+# -*- coding: utf-8 -*-
+column_format = ' %(status)1s%(type)1s %(number)4s %(title)-44s %(authors)-s'
+
+header = """PEP: 0
+Title: Index of Python Enhancement Proposals (PEPs)
+Version: $Revision$
+Last-Modified: $Date$
+Author: David Goodger <goodger at python.org>,
+ Barry A. Warsaw <barry at python.org>
+Status: Active
+Type: Informational
+Created: 13-Jul-2000
+"""
+
+intro = """
+ The PEP contains the index of all Python Enhancement Proposals,
+ known as PEPs. PEP numbers are assigned by the PEP Editor, and
+ once assigned are never changed. The SVN history[1] of the PEP
+ texts represent their historical record.
+
+ The BDFL maintains his own Pronouncements page[2] at
+ http://www.python.org/doc/essays/pepparade.html which contains his
+ musings on the various outstanding PEPs.
+"""
+
+references = """
+ [1] View PEP history online
+ http://svn.python.org/projects/peps/trunk/
+
+ [2] The Benevolent Dictator For Life's Parade of PEPs
+ http://www.python.org/doc/essays/pepparade.html
+"""
+
+footer = """
+Local Variables:
+mode: indented-text
+indent-tabs-mode: nil
+sentence-end-double-space: t
+fill-column: 70
+coding: utf-8
+End:"""
+
+nicknames = {
+ 'Guido van Rossum' : 'GvR',
+ 'Just van Rossum' : 'JvR',
+}
+
+email_addresses = {
+ 'Aahz' : 'aahz at pobox.com',
+ 'James C. Ahlstrom' : 'jim at interet.com',
+ 'Jim Althoff' : 'james_althoff at i2.com',
+ 'Kevin Altis' : 'altis at semi-retired.com',
+ 'David Ascher' : 'davida at activestate.com',
+ 'Peter Astrand' : 'astrand at lysator.liu.se',
+ 'Carl Banks' : 'pythondev at aerojockey.com',
+ 'Paul Barrett' : 'barrett at stsci.edu',
+ 'Facundo Batista' : 'facundo at taniquetil.com.ar',
+ 'Anthony Baxter' : 'anthony at interlink.com.au',
+ 'Thomas Bellman' : 'bellman+pep-divmod at lysator.liu.se',
+ 'Steven Bethard' : 'steven.bethard at gmail.com',
+ 'Georg Brandl' : 'g.brandl at gmx.net',
+ 'Brett Cannon' : 'brett at python.org',
+ 'Josiah Carlson' : 'jcarlson at uci.edu',
+ 'W Isaac Carroll' : 'icarroll at pobox.com',
+ 'Nick Coghlan' : 'ncoghlan at gmail.com',
+ 'Dave Cole' : 'djc at object-craft.com.au',
+ 'Christopher Craig' : 'python-pep at ccraig.org',
+ 'Laura Creighton' : 'lac at strakt.com',
+ 'Walter Dörwald' : '',
+ 'Fred L. Drake, Jr.' : 'fdrake at acm.org',
+ 'Michael P. Dubner' : 'dubnerm at mindless.com',
+ 'Paul F. Dubois' : 'paul at pfdubois.com',
+ 'Phillip J. Eby' : 'pje at telecommunity.com',
+ 'Micah Elliott' : 'mde at tracos.org',
+ 'Jeff Epler' : 'jepler at unpythonic.net',
+ 'David Eppstein' : 'eppstein at ics.uci.edu',
+ 'Clark C. Evans' : 'cce at clarkevans.com',
+ 'Greg Ewing' : 'greg at cosc.canterbury.ac.nz',
+ 'Martijn Faassen' : 'faassen at infrae.com',
+ 'Ben Finney' : 'ben+python at benfinney.id.au',
+ 'Frédéric B. Giacometti' : 'fred at arakne.com',
+ 'Scott Gilbert' : 'xscottg at yahoo.com',
+ 'David Goodger' : 'goodger at python.org',
+ 'Grant Griffin' : 'g2 at iowegian.com',
+ 'Mark Hammond' : 'mhammond at skippinet.com.au',
+ 'Peter Harris' : 'scav at blueyonder.co.uk',
+ 'Thomas Heller' : 'theller at python.net',
+ 'Magnus Lie Hetland' : 'magnus at hetland.org',
+ 'Raymond D. Hettinger' : 'python at rcn.com',
+ 'Neil Hodgson' : 'neilh at scintilla.org',
+ 'Michael Hudson' : 'mwh at python.net',
+ 'Jeremy Hylton' : 'jeremy at zope.com',
+ 'Jack Jansen' : 'jack at cwi.nl',
+ 'Jim Jewett' : 'jimjjewett at users.sourceforge.net',
+ 'Richard Jones' : 'richard at mechanicalcat.net',
+ 'Stepan Koltsov' : 'yozh at mx1.ru',
+ 'A.M. Kuchling' : 'amk at amk.ca',
+ 'Marc-Andre Lemburg' : 'mal at lemburg.com',
+ 'Gregory Lielens' : 'gregory.lielens at fft.be',
+ 'Björn Lindqvist' : 'bjourne at gmail.com',
+ 'Martin von Löwis' : 'loewis at informatik.hu-berlin.de',
+ 'Tony Lownds' : 'tony at pagedna.com',
+ 'Alex Martelli' : 'aleax at aleax.it',
+ 'Andrew McClelland' : 'eternalsquire at comcast.net',
+ 'Gordon McMillan' : 'gmcm at hypernet.com',
+ 'Andrew McNamara' : 'andrewm at object-craft.com.au',
+ 'Trent Mick' : 'trentm at activestate.com',
+ 'Mike Meyer' : 'mwm at mired.org',
+ 'Skip Montanaro' : 'skip at pobox.com',
+ 'Paul Moore' : 'gustav at morpheus.demon.co.uk',
+ 'Ben North' : 'ben at redfrontdoor.org',
+ 'Neal Norwitz' : 'nnorwitz at gmail.com',
+ 'Travis Oliphant' : 'oliphant at ee.byu.edu',
+ 'Jason Orendorff' : 'jason.orendorff at gmail.com',
+ 'Samuele Pedroni' : 'pedronis at python.org',
+ 'Michel Pelletier' : 'michel at users.sourceforge.net',
+ 'Tim Peters' : 'tim at zope.com',
+ 'Jason Petrone' : 'jp at demonseed.net',
+ 'Paul Prescod' : 'paul at prescod.net',
+ 'Terry Reedy' : 'tjreedy at udel.edu',
+ 'Sean Reifschneider' : 'jafo-pep at tummy.com',
+ 'Christian R. Reis' : 'kiko at async.com.br',
+ 'Jonathan Riehl' : 'jriehl at spaceship.com',
+ 'André Roberge' : 'andre.roberge at gmail.com',
+ 'Guido van Rossum' : 'guido at python.org',
+ 'Just van Rossum' : 'just at letterror.com',
+ 'Vinay Sajip' : 'vinay_sajip at red-dove.com',
+ 'Neil Schemenauer' : 'nas at arctrix.com',
+ 'Peter Schneider-Kamp' : 'nowonder at nowonder.de',
+ 'Jiwon Seo' : 'seojiwon at gmail.com',
+ 'Kevin D. Smith' : 'Kevin.Smith at theMorgue.org',
+ 'Greg Stein' : 'gstein at lyra.org',
+ 'Daniel Stutzbach' : 'daniel.stutzbach at gmail.com',
+ 'Roman Suzi' : 'rnd at onego.ru',
+ 'Talin' : 'talin at acm.org',
+ 'Steven Taschuk' : 'staschuk at telusplanet.net',
+ 'Oren Tirosh' : 'oren at hishome.net',
+ 'Mike Verdone' : 'mike.verdone at gmail.com',
+ 'Gregory R. Warnes' : 'warnes at users.sourceforge.net',
+ 'Barry Warsaw' : 'barry at python.org',
+ 'Terence Way' : 'terry at wayforward.net',
+ 'Cliff Wells' : 'LogiplexSoftware at earthlink.net',
+ 'Greg Wilson' : 'gvwilson at ddj.com',
+ 'Collin Winter' : 'collinw at gmail.com',
+ 'Thomas Wouters' : 'thomas at python.org',
+ 'Ka-Ping Yee' : 'ping at zesty.ca',
+ 'Moshe Zadka' : 'moshez at zadka.site.co.il',
+ 'Huaiyu Zhu' : 'hzhu at users.sourceforge.net',
+}
Modified: sandbox/trunk/pep0/pep0/output.py
==============================================================================
--- sandbox/trunk/pep0/pep0/output.py (original)
+++ sandbox/trunk/pep0/pep0/output.py Fri Jun 15 04:35:52 2007
@@ -1,66 +1,107 @@
"""Code to handle the output of PEP 0.
XXX
- * Move output code from __init__ to here.
* Move PEP sorting to here.
- * Move last name code to here?
-
"""
-from . import authors
-from .pep import last_name
+from . import constants
+from .pep import sort_peps, PEP
+
+from sys import stdout
-indent = ' '
-def make_entry(type_, status, number, title, owners):
- """Return the string representation for a PEP entry (or anything that is
- similarly formatted.
-
- If type_ or status have values of None they are filled in with whitespace.
- All arguments are expected to be valid.
-
- """
- entry = [indent]
- # Type.
- if type_:
- entry.append(type_[0].upper())
- else:
- entry.append(' ')
- # Status.
- if status and status not in ('Active', 'Draft'):
- entry.append(type_[0].upper())
- else:
- entry.append(' ')
- # Number.
- entry.append(str(number).ljust(4))
- # Title.
- entry.append(title.rjust(44))
- # owners.
- entry.append(', '.join(last_name(owner) for owner in owners))
-
- # Indent, Type, Statue, Number, Title, Owners.
- return "%s%s%s %s %s %s" % entry
-
-def write_pep(pep, output):
- """Write PEP info to 'output'."""
- type_abbr = pep['Type'][0].upper()
- status = pep['Status']
- if status in ('Draft', 'Active'):
- status_abbr = ' '
- else:
- status_abbr = status[0].upper()
- number = str(pep['PEP']).rjust(4)
- title = pep['Title']
- authors_list = []
- author_string = ', '.join(last_name(author, authors.nicknames)
- for author in pep['Author'])
- output.write(" %s%s %s %s %s\n" %
- (type_abbr, status_abbr, number, title.ljust(44),
- author_string))
+indent = ' '
def write_column_headers(output):
"""Output the column headers for the PEP indices."""
- output.write('%s %s %s\n' % ("num".rjust(8), "title".ljust(44), "owner"))
- output.write('%s %s %s\n' % ((len("num")*'-').rjust(8),
- (len("title")*'-').ljust(44), len("owner")*'-'))
-
-
+ column_headers = {'status': '', 'type': '', 'number': 'num',
+ 'title': 'title', 'authors': 'owner'}
+ print>>output, constants.column_format % column_headers
+ underline_headers = {}
+ for key, value in column_headers.items():
+ underline_headers[key] = len(value) * '-'
+ print>>output, constants.column_format % underline_headers
+
+
+def write_pep0(peps, output=stdout):
+ print>>output, constants.header
+ print>>output
+ print>>output, "Introduction"
+ print>>output, constants.intro
+ print>>output
+ print>>output, "Index by Category"
+ print>>output
+ write_column_headers(output)
+ meta, info, accepted, open_, done, empty, dead = sort_peps(peps)
+ print>>output
+ print>>output, " Meta-PEPs (PEPs about PEPs or Processs)"
+ print>>output
+ for pep in meta:
+ print>>output, pep
+ print>>output
+ print>>output, " Other Informational PEPs"
+ print>>output
+ for pep in info:
+ print>>output, pep
+ print>>output
+ print>>output, " Accepted PEPs (accepted; may not be implemented yet)"
+ print>>output
+ for pep in accepted:
+ print>>output, pep
+ print>>output
+ print>>output, " Open PEPs (under consideration)"
+ print>>output
+ for pep in open_:
+ print>>output, pep
+ print>>output
+ print>>output, " Finished PEPs (done, implemented in code repository)"
+ print>>output
+ for pep in done:
+ print>>output, pep
+ print>>output
+ print>>output, " Empty PEPs (or containing only abstract)"
+ print>>output
+ for pep in empty:
+ print>>output, pep
+ print>>output
+ print>>output, " Deferred, Abandoned, Withdrawn, and Rejected PEPs"
+ print>>output
+ for pep in dead:
+ print>>output, pep
+ print>>output
+ print>>output
+ print>>output, " Numerical Index"
+ print>>output
+ write_column_headers(output)
+ prev_pep = 0
+ for pep in peps:
+ if pep.number - prev_pep > 1:
+ print>>output
+ print>>output, pep
+ prev_pep = pep.number
+ print>>output
+ print>>output
+ print>>output, "Key"
+ print>>output
+ for type_ in PEP.type_values:
+ print>>output, " %s - %s PEP" % (type_[0], type_)
+ print>>output
+ for status in PEP.status_values:
+ print>>output, " %s - %s proposal" % (status[0], status)
+
+ print>>output
+ print>>output
+ print>>output, "Owners"
+ print>>output
+ # XXX
+ # * get "last, first I." of each name.
+ # * add nickname.
+ # * find longest name.
+ # * column headers.
+ # * name/email with a two-space separation between longest name and email.
+ print>>output, ' XXX'
+ print>>output
+ print>>output
+ print>>output, "References"
+ print>>output
+ print>>output, constants.references
+ print>>output, constants.footer
Modified: sandbox/trunk/pep0/pep0/parse.py
==============================================================================
--- sandbox/trunk/pep0/pep0/parse.py (original)
+++ sandbox/trunk/pep0/pep0/parse.py Fri Jun 15 04:35:52 2007
@@ -12,6 +12,7 @@
from __future__ import with_statement
from .pep import PEP
+from operator import attrgetter
import os
def consume_directory(directory):
@@ -26,7 +27,7 @@
for file_name in os.listdir(directory):
if file_name.startswith('pep-') and file_name.endswith('.txt'):
peps.append(consume_pep(os.path.join(directory, file_name)))
- peps.sort(key=lambda pep: pep['PEP'])
+ peps.sort(key=attrgetter('number'))
return peps
def consume_pep(path):
@@ -50,7 +51,6 @@
data = metadata[field] + data
metadata[field] = data
except Exception:
- print "*** In", pep_file
raise
# Make sure PEP field was found ...
if not 'PEP' in metadata:
@@ -64,7 +64,7 @@
metadata['PEP'] = int(metadata['PEP'])
except ValueError:
raise ValueError("PEP number in file %s is not valid" % path)
- return metadata
+ return PEP(metadata)
def split_metadata(line, continue_field=None):
"""Parse the given line for PEP metadata, returning the field and data for
Modified: sandbox/trunk/pep0/pep0/pep.py
==============================================================================
--- sandbox/trunk/pep0/pep0/pep.py (original)
+++ sandbox/trunk/pep0/pep0/pep.py Fri Jun 15 04:35:52 2007
@@ -1,9 +1,31 @@
"""Code for handling object representation of a PEP."""
+from .constants import nicknames, column_format
+
import re
+
class PEP(object):
- """Representation of PEPs."""
+ """Representation of PEPs.
+
+ Attributes:
+
+ + number : int
+ PEP number.
+
+ + title : str
+ PEP title.
+
+ + type_ : str
+ The type of PEP. Can only be one of the values from
+ PEP.type_values.
+
+ + status : str
+ The PEP's status. Value must be found in PEP.status_values.
+
+ + authors : Sequence(str)
+ A list of the authors' full names.
+ """
type_values = ("Standards Track", "Informational", "Process")
# Active and Draft are not listed in the index.
@@ -13,10 +35,13 @@
def __init__(self, metadata_dict):
"""Init object based on dict containing metadata from a file.
- Required keys are:
+ Required keys from metadata_dict are:
* PEP
- value must be an integer.
+ Value must be an integer.
+
+ * Title
+ A string.
* Type
Value must match a value in self.type_values.
@@ -30,12 +55,14 @@
"""
# Verify keys exist.
- for required_key in ('PEP', 'Type', 'Status', 'Author'):
+ for required_key in ('PEP', 'Title', 'Type', 'Status', 'Author'):
if required_key not in metadata_dict:
raise KeyError("required key %r not in dict")
# 'PEP'. PEP parsing should have already converted the number to an
# integer, so just being safe here.
self.number = int(metadata_dict['PEP'])
+ # 'Title'.
+ self.title = metadata_dict['Title']
# 'Type'.
type_ = metadata_dict['Type']
if type_ not in self.type_values:
@@ -83,8 +110,17 @@
def __str__(self):
"""Return the line entry for the PEP."""
- return ''
- pass
+ pep_info = {'type': self.type_[0].upper(), 'number': str(self.number),
+ 'title': self.title}
+ if self.status in ('Draft', 'Active'):
+ status_abbr = ' '
+ else:
+ status_abbr = self.status[0].upper()
+ pep_info['status'] = status_abbr
+ author_string = ', '.join(last_name(author, nicknames)
+ for author in self.authors)
+ pep_info['authors'] = author_string
+ return column_format % pep_info
def last_name(full_name, nicknames={}):
@@ -124,18 +160,18 @@
for pep in peps:
# Order of 'if' statement important. Key Status values take precedence
# over Type value, and vice-versa.
- if pep['Status'] == 'Draft':
+ if pep.status == 'Draft':
open_.append(pep)
- elif pep['Status'] in ('Rejected', 'Withdrawn', 'Deferred',
+ elif pep.status in ('Rejected', 'Withdrawn', 'Deferred',
'Incomplete'):
dead.append(pep)
- elif pep['Type'] == 'Process':
+ elif pep.status == 'Process':
meta.append(pep)
- elif pep['Type'] == 'Informational':
+ elif pep.status == 'Informational':
info.append(pep)
- elif pep['Status'] == 'Accepted':
+ elif pep.status == 'Accepted':
accepted.append(pep)
- elif pep['Status'] == 'Final':
+ elif pep.status == 'Final':
finished.append(pep)
return meta, info, accepted, open_, finished, empty, dead
Deleted: /sandbox/trunk/pep0/pep0/statictext.py
==============================================================================
--- /sandbox/trunk/pep0/pep0/statictext.py Fri Jun 15 04:35:52 2007
+++ (empty file)
@@ -1,40 +0,0 @@
-# Don't start on a new line to make easier to read as that would cause output to
-# start on a blank line.
-header = """PEP: 0
-Title: Index of Python Enhancement Proposals (PEPs)
-Version: $Revision$
-Last-Modified: $Date$
-Author: David Goodger <goodger at python.org>,
- Barry A. Warsaw <barry at python.org>
-Status: Active
-Type: Informational
-Created: 13-Jul-2000
-"""
-
-intro = """
- The PEP contains the index of all Python Enhancement Proposals,
- known as PEPs. PEP numbers are assigned by the PEP Editor, and
- once assigned are never changed. The SVN history[1] of the PEP
- texts represent their historical record.
-
- The BDFL maintains his own Pronouncements page[2] at
- http://www.python.org/doc/essays/pepparade.html which contains his
- musings on the various outstanding PEPs.
-"""
-
-references = """
- [1] View PEP history online
- http://svn.python.org/projects/peps/trunk/
-
- [2] The Benevolent Dictator For Life's Parade of PEPs
- http://www.python.org/doc/essays/pepparade.html
-"""
-
-footer = """
-Local Variables:
-mode: indented-text
-indent-tabs-mode: nil
-sentence-end-double-space: t
-fill-column: 70
-coding: utf-8
-End:"""
More information about the Python-checkins
mailing list