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.
This commit is contained in:
parent
da08263556
commit
c45b869b65
|
@ -10,14 +10,14 @@ import datetime
|
||||||
|
|
||||||
# Could make this the base class; will need to add 'publish'
|
# Could make this the base class; will need to add 'publish'
|
||||||
class WriteXmlMixin:
|
class WriteXmlMixin:
|
||||||
def write_xml(self, outfile, encoding = "iso-8859-1"):
|
def write_xml(self, outfile, encoding = "utf-8"):
|
||||||
from xml.sax import saxutils
|
from xml.sax import saxutils
|
||||||
handler = saxutils.XMLGenerator(outfile, encoding)
|
handler = saxutils.XMLGenerator(outfile, encoding)
|
||||||
handler.startDocument()
|
handler.startDocument()
|
||||||
self.publish(handler)
|
self.publish(handler)
|
||||||
handler.endDocument()
|
handler.endDocument()
|
||||||
|
|
||||||
def to_xml(self, encoding = "iso-8859-1"):
|
def to_xml(self, encoding = "utf-8"):
|
||||||
try:
|
try:
|
||||||
import cStringIO as StringIO
|
import cStringIO as StringIO
|
||||||
except ImportError:
|
except ImportError:
|
||||||
|
|
|
@ -4,13 +4,14 @@
|
||||||
# (standard post-commit args)
|
# (standard post-commit args)
|
||||||
|
|
||||||
import os, glob, time, datetime, stat, re, sys
|
import os, glob, time, datetime, stat, re, sys
|
||||||
|
import codecs
|
||||||
from subprocess import Popen, PIPE
|
from subprocess import Popen, PIPE
|
||||||
import PyRSS2Gen as rssgen
|
import PyRSS2Gen as rssgen
|
||||||
|
|
||||||
RSS_PATH = os.path.join(sys.argv[1], 'peps.rss')
|
RSS_PATH = os.path.join(sys.argv[1], 'peps.rss')
|
||||||
|
|
||||||
def firstline_startingwith(full_path, text):
|
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):
|
if line.startswith(text):
|
||||||
return line[len(text):].strip()
|
return line[len(text):].strip()
|
||||||
return None
|
return None
|
||||||
|
@ -46,7 +47,7 @@ for dt, full_path in peps_with_dt[-10:]:
|
||||||
pass
|
pass
|
||||||
title = firstline_startingwith(full_path, 'Title:')
|
title = firstline_startingwith(full_path, 'Title:')
|
||||||
author = firstline_startingwith(full_path, 'Author:')
|
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(
|
item = rssgen.RSSItem(
|
||||||
title = 'PEP %d: %s' % (n, title),
|
title = 'PEP %d: %s' % (n, title),
|
||||||
link = url,
|
link = url,
|
||||||
|
|
Loading…
Reference in New Issue