[Python-checkins] r54831 - sandbox/trunk/pep0/TODO sandbox/trunk/pep0/pep0.py

brett.cannon python-checkins at python.org
Sun Apr 15 04:15:05 CEST 2007


Author: brett.cannon
Date: Sun Apr 15 04:15:01 2007
New Revision: 54831

Modified:
   sandbox/trunk/pep0/TODO
   sandbox/trunk/pep0/pep0.py
Log:
Get the index to output by category.


Modified: sandbox/trunk/pep0/TODO
==============================================================================
--- sandbox/trunk/pep0/TODO	(original)
+++ sandbox/trunk/pep0/TODO	Sun Apr 15 04:15:01 2007
@@ -3,23 +3,15 @@
 
 * Read PEPs as UTF-8.
 
-* Output static text for PEP 0.
-    + Author/email list.
-        - names
-        - emails
-        - Column headers.
-            * Underline to length of author name or just column header like in
-              rest of doc?
-
-* Index by Category.
-    + Sort PEPs and output
-    + Section info.
+* Author/email list.
+    + names
+    + emails
+    + Column headers.
+        - Underline to length of author name or just column header like in
+          rest of doc?
 
 * Make sure that it is easy to identify which PEP triggered an error.
-    + Has all expected fields.
     + Values in fields correct.
-        - Type
-        - Status
         - All authors declared in authors.py.
     + Formatting correct.
         - Plaintext.
@@ -41,8 +33,6 @@
         - Meta-PEPs are not delineated as such.
 
     + Status field.
-        - Not all PEPs use consistent names (e.g., some just say "Standard" instead
-        of "Standard Track").
         - Empty PEPs are not specified as such.
 
 * In the index:
@@ -61,5 +51,7 @@
             - Just deal with some being longer than expected?
 
     * Type/Status field.
-        + Informational PEPs inconsistenty leave out Status.
+        + Active and Draft status is not listed in index.
+            - Conflicts with Accepted and Deferred initials, respectively.
+            - Worth using other letters?
 

Modified: sandbox/trunk/pep0/pep0.py
==============================================================================
--- sandbox/trunk/pep0/pep0.py	(original)
+++ sandbox/trunk/pep0/pep0.py	Sun Apr 15 04:15:01 2007
@@ -47,7 +47,9 @@
 
 
 type_values = ("Standards Track", "Informational", "Process")
-status_values = ("Accepted", "Rejected", "Withdrawn", "Deferred", "Final")
+# Active and Draft are not listed in the index.
+status_values = ("Accepted", "Rejected", "Withdrawn", "Deferred", "Final",
+                 "Active", "Draft")
 
 def consume_headers(directory='.'):
     """Pull out metadata for every PEP in the specified directory and return
@@ -74,6 +76,19 @@
         except Exception:
             print "In", pep_file
             raise
+    if not 'PEP' in pep_info:
+        raise ValueError("PEP at file %s lacks a PEP number" % path)
+    if not 'Author' in pep_info:
+        raise ValueError("PEP %s is missing the Author field" %
+                         pep_info['PEP'])
+    if len(pep_info['Author']) < 1:
+        raise ValueError("PEP %s is lacking authors" % pep_info['PEP'])
+    if pep_info['Type'] not in type_values:
+        raise ValueError("%s is an invalid Type value for PEP %s" %
+                         (pep_info['Type'], pep_info['PEP']))
+    if pep_info['Status'] not in status_values:
+        raise ValueError("%s is an invalid Status value for PEP %s" %
+                         (pep_info['Status'], pep_info['PEP']))
     return pep_info
 
 def parse_metadata(pep_info, line, previous_type=None):
@@ -176,28 +191,28 @@
     empty = []
     dead = []
     for pep in peps:
-        # XXX not all meta PEPs are process PEPs.
-        if pep['Type'] == 'Process':
+        # Order of 'if' statement important.  Key Status values take precedence
+        # over Type value, and vice-versa.
+        if pep['Status'] == 'Draft':
+            open_.append(pep)
+        elif pep['Status'] in ('Rejected', 'Withdrawn', 'Deferred',
+                'Incomplete'):
+            dead.append(pep)
+        elif pep['Type'] == 'Process':
             meta.append(pep)
         elif pep['Type'] == 'Informational':
             info.append(pep)
         elif pep['Status'] == 'Accepted':
             accepted.append(pep)
-        elif pep['Status'] == 'Draft':
-            open_.append(pep)
         elif pep['Status'] == 'Final':
             finished.append(pep)
-        # XXX empty
-        elif pep['Status'] in ('Rejected', 'Withdrawn', 'Deferred',
-                'Incomplete'):
-            dead.append(pep)
-        return meta, info, accepted, open_, finished, empty, dead
+    return meta, info, accepted, open_, finished, empty, dead
 
 def write_pep(pep, output):
     """Write PEP info to 'output'."""
     type_abbr = pep['Type'][0].upper()
     status = pep['Status']
-    if status == 'Draft':
+    if status in ('Draft', 'Active'):
         status_abbr = ' '
     else:
         status_abbr = status[0].upper()
@@ -238,11 +253,45 @@
     print "Index by Category"
     print
     write_column_headers(stdout)
-    #XXX meta, info, accepted, open_, done, empty, dead = sort_peps(peps)
-    print ' XXX'
+    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 " Numerical Index"
     print
     write_column_headers(stdout)
     prev_pep = 0


More information about the Python-checkins mailing list