[Python-checkins] CVS: python/nondist/peps pep2html.py,1.26,1.27
Barry Warsaw
bwarsaw@users.sourceforge.net
Tue, 14 Aug 2001 09:45:21 -0700
Update of /cvsroot/python/python/nondist/peps
In directory usw-pr-cvs1:/tmp/cvs-serv6221
Modified Files:
pep2html.py
Log Message:
fixfile(): Added special casing to handle the new PEP 0 format, which
eliminates the "filename" field in favor of just the unadorned PEP
number.
Index: pep2html.py
===================================================================
RCS file: /cvsroot/python/python/nondist/peps/pep2html.py,v
retrieving revision 1.26
retrieving revision 1.27
diff -C2 -d -r1.26 -r1.27
*** pep2html.py 2001/07/05 18:44:20 1.26
--- pep2html.py 2001/08/14 16:45:19 1.27
***************
*** 58,67 ****
def usage(code, msg=''):
! sys.stderr.write(__doc__ % globals() + '\n')
if msg:
! msg = str(msg)
! if msg[-1] <> '\n':
! msg = msg + '\n'
! sys.stderr.write(msg)
sys.exit(code)
--- 58,64 ----
def usage(code, msg=''):
! print >> sys.stderr, __docs__ % globals()
if msg:
! print >> sys.stderr, msg
sys.exit(code)
***************
*** 82,86 ****
link = RFCURL % rfcnum
if link:
! return "<a href='%s'>%s</a>" % (link, cgi.escape(text))
return cgi.escape(match.group(0)) # really slow, but it works...
--- 79,83 ----
link = RFCURL % rfcnum
if link:
! return '<a href="%s">%s</a>' % (link, cgi.escape(text))
return cgi.escape(match.group(0)) # really slow, but it works...
***************
*** 88,91 ****
--- 85,89 ----
def fixfile(infile, outfile):
+ basename = os.path.basename(infile)
# convert plain text pep to minimal XHTML markup
try:
***************
*** 96,100 ****
return
fo = open(outfile, "w")
! fo.write(DTD + "\n<html>\n<head>\n")
# head
header = []
--- 94,100 ----
return
fo = open(outfile, "w")
! print >> fo, DTD
! print >> fo, '<html>'
! print >> fo, '<head>'
# head
header = []
***************
*** 123,139 ****
title = "PEP " + pep + " -- " + title
if title:
! fo.write(" <title>%s</title>\n"
! ' <link rel="STYLESHEET" href="style.css">\n'
! % cgi.escape(title))
! fo.write("</head>\n")
# body
! fo.write('<body bgcolor="white">\n'
! '<div class="navigation">\n')
! fo.write('[<b><a href="../">home</a></b>]\n')
! if os.path.basename(infile) != "pep-0000.txt":
! fo.write('[<b><a href=".">index</a></b>]\n')
! fo.write('[<b><a href="pep-%04d.txt">PEP source</a></b>]\n' % int(pep))
! fo.write('</div>\n'
! '<div class="header">\n<table border="0">\n')
for k, v in header:
if k.lower() in ('author', 'discussions-to'):
--- 123,138 ----
title = "PEP " + pep + " -- " + title
if title:
! print >> fo, ' <title>%s</title>' % cgi.escape(title)
! print >> fo, ' <link rel="STYLESHEET" href="style.css">'
! print >> fo, '</head>'
# body
! print >> fo, '<body bgcolor="white">'
! print >> fo, '<div class="navigation">'
! print >> fo, '[<b><a href="../">home</a></b>]'
! if basename <> 'pep-0000.txt':
! print >> fo, '[<b><a href=".">index</a></b>]'
! print >> fo, '[<b><a href="pep-%04d.txt">PEP source</a></b>]' % int(pep)
! print >> fo, '</div>'
! print >> fo, '<div class="header">\n<table border="0">'
for k, v in header:
if k.lower() in ('author', 'discussions-to'):
***************
*** 158,185 ****
else:
v = cgi.escape(v)
! fo.write(" <tr><th align='right'>%s:</th><td>%s</td></tr>\n"
! % (cgi.escape(k), v))
! title = 0
! fo.write("</table>\n</div>\n<hr />\n"
! "<pre>")
while 1:
line = fi.readline()
if not line:
break
! if line[0] != "\f":
! if line[0].strip():
! if line.strip() == LOCALVARS:
! break
! fo.write("</pre>\n<h3>%s</h3>\n<pre>" % line.strip())
! title = 0
! else:
! line = fixpat.sub(lambda x, c=infile: fixanchor(c, x), line)
! fo.write(line)
! fo.write("</pre>\n"
! "</body>\n"
! "</html>\n")
fo.close()
os.chmod(outfile, 0664)
def find_pep(pep_str):
--- 157,207 ----
else:
v = cgi.escape(v)
! print >> fo, ' <tr><th align="right">%s:</th><td>%s</td></tr>' % (
! cgi.escape(k), v)
! print >> fo, '</table>'
! print >> fo, '</div>'
! print >> fo, '<hr />'
! print >> fo, '<pre>'
while 1:
line = fi.readline()
if not line:
break
! if line[0] == '\f':
! continue
! if line.strip() == LOCALVARS:
! break
! if line[0].strip():
! if line.strip() == LOCALVARS:
! break
! print >> fo, '</pre>'
! print >> fo, '<h3>%s</h3>' % line.strip()
! print >> fo, '<pre>',
! else:
! # PEP 0 has some special treatment
! if basename == 'pep-0000.txt':
! parts = line.split()
! if len(parts) > 1 and re.match(r'\s*\d{1,4}', parts[1]):
! # This is a PEP summary line, which we need to hyperlink
! url = PEPURL % int(parts[1])
! print >> fo, re.sub(
! parts[1],
! '<a href="%s">%s</a>' % (url, parts[1]),
! line, 1),
! continue
! elif parts and '@' in parts[-1]:
! # This is a pep email address line, so hyperlink it
! url = '<a href="mailto:%s">%s</a>' % (parts[-1], parts[-1])
! print >> fo, re.sub(
! parts[-1], url, line, 1),
! continue
! line = fixpat.sub(lambda x, c=infile: fixanchor(c, x), line)
! fo.write(line)
! print >> fo, '</pre>'
! print >> fo, '</body>'
! print >> fo, '</html>'
fo.close()
os.chmod(outfile, 0664)
+
def find_pep(pep_str):
***************
*** 257,260 ****
--- 279,283 ----
if update:
push_pep(html, peptxt, username, verbose)
+