rclpython: only python3 now
This commit is contained in:
parent
38fb735447
commit
0f6b5911d5
@ -32,11 +32,8 @@ __author__ = 'J
|
||||
|
||||
# Imports
|
||||
import cgi, string, sys
|
||||
PY2 = sys.version < '3'
|
||||
if PY2:
|
||||
import cStringIO
|
||||
else:
|
||||
import io
|
||||
import html
|
||||
import io
|
||||
import keyword, token, tokenize
|
||||
|
||||
def makebytes(data):
|
||||
@ -142,18 +139,12 @@ class Parser:
|
||||
|
||||
# parse the source and write it
|
||||
self.pos = 0
|
||||
if PY2:
|
||||
text = cStringIO.StringIO(self.raw)
|
||||
else:
|
||||
text = io.BytesIO(self.raw)
|
||||
text = io.BytesIO(self.raw)
|
||||
self.out.write(makebytes(self.stylesheet))
|
||||
self.out.write(b'<pre class="code">\n')
|
||||
try:
|
||||
if PY2:
|
||||
tokenize.tokenize(text.readline, self)
|
||||
else:
|
||||
for a,b,c,d,e in tokenize.tokenize(text.readline):
|
||||
self(a,b,c,d,e)
|
||||
for a,b,c,d,e in tokenize.tokenize(text.readline):
|
||||
self(a,b,c,d,e)
|
||||
except tokenize.TokenError as ex:
|
||||
msg = ex[0]
|
||||
line = ex[1][0]
|
||||
@ -205,7 +196,7 @@ class Parser:
|
||||
|
||||
# send text
|
||||
self.out.write(makebytes('<span class="%s">' % (css_class,)))
|
||||
self.out.write(makebytes(cgi.escape(toktext)))
|
||||
self.out.write(makebytes(html.escape(toktext)))
|
||||
self.out.write(b'</span>')
|
||||
|
||||
|
||||
@ -249,10 +240,7 @@ def colorize_file(file=None, outstream=sys.stdout, standalone=True):
|
||||
|
||||
if __name__ == "__main__":
|
||||
import os
|
||||
if PY2:
|
||||
out = sys.stdout
|
||||
else:
|
||||
out = sys.stdout.buffer
|
||||
out = sys.stdout.buffer
|
||||
if os.environ.get('PATH_TRANSLATED'):
|
||||
filepath = os.environ.get('PATH_TRANSLATED')
|
||||
print('Content-Type: text/html; charset="iso-8859-1"\n')
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user