cgi.escape is deprecated, use html.escape instead.
This commit is contained in:
parent
1adb6b0172
commit
56d4eced1d
20
pep2html.py
20
pep2html.py
|
@ -46,6 +46,10 @@ import errno
|
||||||
import random
|
import random
|
||||||
import time
|
import time
|
||||||
from io import open
|
from io import open
|
||||||
|
try:
|
||||||
|
from html import escape
|
||||||
|
except ImportError:
|
||||||
|
from cgi import escape
|
||||||
|
|
||||||
REQUIRES = {'python': '2.6',
|
REQUIRES = {'python': '2.6',
|
||||||
'docutils': '0.2.7'}
|
'docutils': '0.2.7'}
|
||||||
|
@ -117,8 +121,8 @@ def fixanchor(current, match):
|
||||||
rfcnum = int(match.group('rfcnum'))
|
rfcnum = int(match.group('rfcnum'))
|
||||||
link = RFCURL % rfcnum
|
link = RFCURL % rfcnum
|
||||||
if link:
|
if link:
|
||||||
return '<a href="%s">%s</a>' % (cgi.escape(link), cgi.escape(text))
|
return '<a href="%s">%s</a>' % (escape(link), escape(text))
|
||||||
return cgi.escape(match.group(0)) # really slow, but it works...
|
return escape(match.group(0)) # really slow, but it works...
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -182,7 +186,7 @@ def fixfile(inpath, input_lines, outfile):
|
||||||
if pep:
|
if pep:
|
||||||
title = "PEP " + pep + " -- " + title
|
title = "PEP " + pep + " -- " + title
|
||||||
if title:
|
if title:
|
||||||
print(' <title>%s</title>' % cgi.escape(title), file=outfile)
|
print(' <title>%s</title>' % escape(title), file=outfile)
|
||||||
r = random.choice(list(range(64)))
|
r = random.choice(list(range(64)))
|
||||||
print((
|
print((
|
||||||
' <link rel="STYLESHEET" href="style.css" type="text/css" />\n'
|
' <link rel="STYLESHEET" href="style.css" type="text/css" />\n'
|
||||||
|
@ -241,20 +245,20 @@ def fixfile(inpath, input_lines, outfile):
|
||||||
else:
|
else:
|
||||||
try:
|
try:
|
||||||
url = PEPCVSURL % int(pep)
|
url = PEPCVSURL % int(pep)
|
||||||
v = '<a href="%s">%s</a> ' % (url, cgi.escape(date))
|
v = '<a href="%s">%s</a> ' % (url, escape(date))
|
||||||
except ValueError as error:
|
except ValueError as error:
|
||||||
v = date
|
v = date
|
||||||
elif k.lower() in ('content-type',):
|
elif k.lower() in ('content-type',):
|
||||||
url = PEPURL % 9
|
url = PEPURL % 9
|
||||||
pep_type = v or 'text/plain'
|
pep_type = v or 'text/plain'
|
||||||
v = '<a href="%s">%s</a> ' % (url, cgi.escape(pep_type))
|
v = '<a href="%s">%s</a> ' % (url, escape(pep_type))
|
||||||
elif k.lower() == 'version':
|
elif k.lower() == 'version':
|
||||||
if v.startswith('$' 'Revision: ') and v.endswith(' $'):
|
if v.startswith('$' 'Revision: ') and v.endswith(' $'):
|
||||||
v = cgi.escape(v[11:-2])
|
v = escape(v[11:-2])
|
||||||
else:
|
else:
|
||||||
v = cgi.escape(v)
|
v = escape(v)
|
||||||
print(' <tr><th>%s: </th><td>%s</td></tr>' \
|
print(' <tr><th>%s: </th><td>%s</td></tr>' \
|
||||||
% (cgi.escape(k), v), file=outfile)
|
% (escape(k), v), file=outfile)
|
||||||
print('</table>', file=outfile)
|
print('</table>', file=outfile)
|
||||||
print('</div>', file=outfile)
|
print('</div>', file=outfile)
|
||||||
print('<hr />', file=outfile)
|
print('<hr />', file=outfile)
|
||||||
|
|
Loading…
Reference in New Issue