From c45b869b657edc731ed393aa57d6dc93ed9d1cbc Mon Sep 17 00:00:00 2001 From: "Andrew M. Kuchling" Date: Tue, 15 Jan 2008 12:06:19 +0000 Subject: [PATCH] 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. --- PyRSS2Gen.py | 4 ++-- pep2rss.py | 5 +++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/PyRSS2Gen.py b/PyRSS2Gen.py index fc1f1cf24..5a1975e7f 100644 --- a/PyRSS2Gen.py +++ b/PyRSS2Gen.py @@ -10,14 +10,14 @@ import datetime # 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: diff --git a/pep2rss.py b/pep2rss.py index 4e6b426ed..4a9206920 100755 --- a/pep2rss.py +++ b/pep2rss.py @@ -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 @@ for dt, full_path in peps_with_dt[-10:]: 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,