[Python-checkins] r59975 - peps/trunk/PyRSS2Gen.py peps/trunk/pep2rss.py

andrew.kuchling python-checkins at python.org
Tue Jan 15 13:06:20 CET 2008


Author: andrew.kuchling
Date: Tue Jan 15 13:06:19 2008
New Revision: 59975

Modified:
   peps/trunk/PyRSS2Gen.py
   peps/trunk/pep2rss.py
Log:
Patch from Frank Benkstein:
  * Fix links for three-digit PEPs.  The leading zero was eaten by an
    integer conversion.
  * PEPs are encoded as UTF-8 as per PEP 1.  Change the input and output
    encodings from latin1 to utf-8 to make the feed render correctly.


Modified: peps/trunk/PyRSS2Gen.py
==============================================================================
--- peps/trunk/PyRSS2Gen.py	(original)
+++ peps/trunk/PyRSS2Gen.py	Tue Jan 15 13:06:19 2008
@@ -10,14 +10,14 @@
 
 # Could make this the base class; will need to add 'publish'
 class WriteXmlMixin:
-    def write_xml(self, outfile, encoding = "iso-8859-1"):
+    def write_xml(self, outfile, encoding = "utf-8"):
         from xml.sax import saxutils
         handler = saxutils.XMLGenerator(outfile, encoding)
         handler.startDocument()
         self.publish(handler)
         handler.endDocument()
 
-    def to_xml(self, encoding = "iso-8859-1"):
+    def to_xml(self, encoding = "utf-8"):
         try:
             import cStringIO as StringIO
         except ImportError:

Modified: peps/trunk/pep2rss.py
==============================================================================
--- peps/trunk/pep2rss.py	(original)
+++ peps/trunk/pep2rss.py	Tue Jan 15 13:06:19 2008
@@ -4,13 +4,14 @@
 # (standard post-commit args)
 
 import os, glob, time, datetime, stat, re, sys
+import codecs
 from subprocess import Popen, PIPE
 import PyRSS2Gen as rssgen
 
 RSS_PATH = os.path.join(sys.argv[1], 'peps.rss')
 
 def firstline_startingwith(full_path, text):
-    for line in file(full_path):
+    for line in codecs.open(full_path, encoding="utf-8"):
         if line.startswith(text):
             return line[len(text):].strip()
     return None
@@ -46,7 +47,7 @@
         pass
     title = firstline_startingwith(full_path, 'Title:')
     author = firstline_startingwith(full_path, 'Author:')
-    url = 'http://www.python.org/dev/peps/pep-%d' % n
+    url = 'http://www.python.org/dev/peps/pep-%0.4d' % n
     item = rssgen.RSSItem(
         title = 'PEP %d: %s' % (n, title),
         link = url,


More information about the Python-checkins mailing list