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

brett.cannon python-checkins at python.org
Thu Apr 12 06:16:34 CEST 2007


Author: brett.cannon
Date: Thu Apr 12 06:16:33 2007
New Revision: 54773

Modified:
   sandbox/trunk/pep0/TODO
   sandbox/trunk/pep0/pep0.py
   sandbox/trunk/pep0/test_pep0.py
Log:
Fix author parsing (really need to have a consistent way of listing authors).
Also updated TODO list of what is left to do.

Minor bug in running pep0.py with a directory argument also fixed.


Modified: sandbox/trunk/pep0/TODO
==============================================================================
--- sandbox/trunk/pep0/TODO	(original)
+++ sandbox/trunk/pep0/TODO	Thu Apr 12 06:16:33 2007
@@ -1,20 +1,43 @@
-In script:
+Current discrepencies
+---------------------
+
 * Author issues
     + Missing an author
-        - 207
-        - 208
-        - 209
-        - 218
-        - 228
-        - 234
-        - 238
-        - 246
-        - 251
-        - 263
-        - 312
         - 314
     + How to handle suffixes (Jr., etc.)?
-* Read PEPs as UTF-8, not ASCII.
+        - 160
+        - 205
+* Type/status issues:
+    - 160: missing F
+    - 206: missing W
+    - 216: missing R
+    - 220: missing D
+    - 226: missing F
+    - 247: missing F
+    - 248: missing F
+    - 249: missing F
+    - 251: missing F
+    - 269: added D
+    - 272: missing F
+    - 283: missing F
+    - 286: added A
+    - 320: missing F
+    - 344: added A
+    - 353: used F, expected A
+    - 356: missing F
+    - 364: added A
+    - 3102: used A, expected F
+    - 3104: used A, expected F
+    - 3107: used A, expected F
+    - 3104: used A
+* Title are too long (use ellipsis?):
+    - 311
+    - 3001
+
+
+Functionality to add
+--------------------
+
 * Output static text for PEP 0.
     + Store Owners list in a data structure.
         - Support nicknames for PEP listing (e.g., "Guido van Rossum" ->
@@ -28,11 +51,14 @@
         - Would allow for easy validation that metadata is correct in PEPs.
 * Output PEP 0 with numerical PEP index.
 * Output PEP 0 with special sections.
+* Make sure that it is easy to identify which PEP triggered an error.
+
 
-For PEPs:
+To clean up PEPs
+----------------
 * Define (and enforce) consistency in Author field.
 * Empty PEPs are not in any way identified within the PEPs themselves.
-    + Get ride of section and just consider rejected?
+    + Get rid of section and just consider rejected?
         - No longer accept empty PEPs, right?
 * Meta-PEPs are not noted as such within the PEPs.
     + Add a "Meta" option for "Type"?

Modified: sandbox/trunk/pep0/pep0.py
==============================================================================
--- sandbox/trunk/pep0/pep0.py	(original)
+++ sandbox/trunk/pep0/pep0.py	Thu Apr 12 06:16:33 2007
@@ -1,6 +1,7 @@
 """Auto-generate PEP 0 (PEP index).  """
 from __future__ import with_statement
 import os
+import re
 
 def consume_headers(directory='.'):
     """Pull out metadata for every PEP in the specified directory and return
@@ -61,15 +62,20 @@
 
 def handle_author(data):
     """Return a list of author names."""
-    if '<' in data:
-        author, email = data.split('<', 1)
-    elif '(' in data:
-        email, author = data.split('(', 1)
-        author = author[:author.index(')')]
-    else:
-        author = data
-    return [author_name.strip() for author_name in author.split(',') if
-            author_name]
+    angled = r'(?P<author>.+?) <.+?>'
+    paren = r'.+? \((?P<author>.+?)\)'
+    simple = r'(?P<author>[^,]+)'
+    authors = []
+    for regex in (angled, paren, simple):
+        # Watch out for commas separating multiple names.
+        regex += '(,\s+)?'
+        for match in re.finditer(regex, data):
+            authors.append(match.group('author'))
+        else:
+            # If authors were found then stop searching.
+            if authors:
+                break
+    return authors
 
 def handle_csv(data):
     """Handle the Post-History."""
@@ -143,7 +149,7 @@
     else:
         path = argv[1]
     if os.path.isdir(path):
-        peps = consume_headers(directory)
+        peps = consume_headers(path)
     else:
         peps = [consume_pep(path)]
 

Modified: sandbox/trunk/pep0/test_pep0.py
==============================================================================
--- sandbox/trunk/pep0/test_pep0.py	(original)
+++ sandbox/trunk/pep0/test_pep0.py	Thu Apr 12 06:16:33 2007
@@ -41,12 +41,14 @@
         for format in formats:
             rep = format % authors[0]
             expect = authors[0:1]
-            self.failUnlessEqual(pep0.handle_author(rep), expect)
-            rep += ','
+            got = pep0.handle_author(rep)
+            self.failUnlessEqual(got, expect,
+                    "%r failed; %r != %r" % (rep, got, expect))
+            rep += ', '
             self.failUnlessEqual(pep0.handle_author(rep), expect)
             rep += format % authors[1]
             self.failUnlessEqual(pep0.handle_author(rep), authors)
-            rep += ','
+            rep += ', '
             self.failUnlessEqual(pep0.handle_author(rep), authors)
 
 


More information about the Python-checkins mailing list