Added an exception handler for a bad PEP number. Updated docstrings.
This commit is contained in:
parent
22562b2c81
commit
1655ef5d34
27
pep2html.py
27
pep2html.py
|
@ -6,7 +6,7 @@ Usage: %(PROGRAM)s [options] [peps]
|
|||
Options:
|
||||
|
||||
-u/--user
|
||||
SF username
|
||||
python.org username
|
||||
|
||||
-b/--browse
|
||||
After generating the HTML, direct your web browser to view it
|
||||
|
@ -16,10 +16,10 @@ Options:
|
|||
will browse PEP 0.
|
||||
|
||||
-i/--install
|
||||
After generating the HTML, install it and the source file (.txt)
|
||||
SourceForge. In that case the user's name is used in the scp and ssh
|
||||
commands, unless -u sf_username is given (in which case, that is used
|
||||
instead). Without -i, -u is ignored.
|
||||
After generating the HTML, install it and the plaintext source file
|
||||
(.txt) on python.org. In that case the user's name is used in the scp
|
||||
and ssh commands, unless "-u username" is given (in which case, it is
|
||||
used instead). Without -i, -u is ignored.
|
||||
|
||||
-q/--quiet
|
||||
Turn off verbose messages.
|
||||
|
@ -131,7 +131,7 @@ def fixfile(inpath, input_lines, outfile):
|
|||
from email.Utils import parseaddr
|
||||
basename = os.path.basename(inpath)
|
||||
infile = iter(input_lines)
|
||||
# convert plain text pep to minimal XHTML markup
|
||||
# convert plaintext pep to minimal XHTML markup
|
||||
print >> outfile, DTD
|
||||
print >> outfile, '<html>'
|
||||
print >> outfile, '<head>'
|
||||
|
@ -177,8 +177,12 @@ def fixfile(inpath, input_lines, outfile):
|
|||
if basename <> 'pep-0000.txt':
|
||||
print >> outfile, '[<b><a href=".">PEP Index</a></b>]'
|
||||
if pep:
|
||||
print >> outfile, '[<b><a href="pep-%04d.txt">PEP Source</a></b>]' \
|
||||
% int(pep)
|
||||
try:
|
||||
print >> outfile, ('[<b><a href="pep-%04d.txt">PEP Source</a>'
|
||||
'</b>]' % int(pep))
|
||||
except ValueError, error:
|
||||
print >> sys.stderr, ('ValueError (invalid PEP number): %s'
|
||||
% error)
|
||||
print >> outfile, '</td></tr></table>'
|
||||
print >> outfile, '<div class="header">\n<table border="0">'
|
||||
for k, v in header:
|
||||
|
@ -206,10 +210,13 @@ def fixfile(inpath, input_lines, outfile):
|
|||
otherpep)
|
||||
v = otherpeps
|
||||
elif k.lower() in ('last-modified',):
|
||||
url = PEPCVSURL % int(pep)
|
||||
date = v or time.strftime('%d-%b-%Y',
|
||||
time.localtime(os.stat(inpath)[8]))
|
||||
v = '<a href="%s">%s</a> ' % (url, cgi.escape(date))
|
||||
try:
|
||||
url = PEPCVSURL % int(pep)
|
||||
v = '<a href="%s">%s</a> ' % (url, cgi.escape(date))
|
||||
except ValueError, error:
|
||||
v = date
|
||||
elif k.lower() in ('content-type',):
|
||||
url = PEPURL % 9
|
||||
pep_type = v or 'text/plain'
|
||||
|
|
Loading…
Reference in New Issue