[AC_DEFINE([ENDIAN_HDR], [<sys/isa_defs.h>])])])])
build_www=yes
-AC_PATH_PROGS(PYTHON, [python2 python], [], $PATH:/bin:/usr/bin)
-if (test -n "${ac_cv_path_PYTHON}"); then
- AC_MSG_CHECKING([that python is version 2.x])
- if $PYTHON --version 2>&1 | grep "Python 2\." > /dev/null; then
- AC_MSG_RESULT([yes])
- AC_SUBST(PYTHON, ${ac_cv_path_PYTHON})
- else
- AC_MSG_RESULT([no])
- AC_MSG_NOTICE([Python is not v2.x; not building HTML pages])
- build_www=no
- fi
-else
+AC_PATH_PROGS(PYTHON, [python3 python2 python], [], $PATH:/bin:/usr/bin)
+if test -z "${ac_cv_path_PYTHON}"; then
AC_MSG_NOTICE([Python not found; not building HTML pages])
build_www=no
fi
-#!/usr/bin/env python
+#!/usr/bin/env python3
#
# Simple XML to HTML converter.
#
import socket
import time
import xml.sax
-import commands
import codecs
-reload(sys)
-sys.setdefaultencoding('utf-8')
+if sys.version_info >= (3,0):
+ sys.stdout = codecs.getwriter("utf-8")(sys.stdout.detach())
+else:
+ reload(sys)
+ sys.setdefaultencoding('utf-8')
+ sys.stdout = codecs.getwriter("utf-8")(sys.stdout)
lookupdir = ''
# Print the usage information
def usage():
- print "USAGE:"
- print "html.py <-f -h file.xml>"
- print " -d DIR use DIR as base directory for opening files"
- print " -f write output to file.html (default is stdout)"
- print " -h help"
+ print ("USAGE:")
+ print ("html.py <-f -h file.xml>")
+ print (" -d DIR use DIR as base directory for opening files")
+ print (" -f write output to file.html (default is stdout)")
+ print (" -h help")
return
return
elif name == "INCLUDE":
try:
- fd = open(attrs.get('file'), 'r')
+ fd = codecs.open(attrs.get('file'), 'r', 'utf-8')
except:
- fd = open(lookupdir + attrs.get('file'), 'r')
+ fd = codecs.open(lookupdir + attrs.get('file'), 'r', 'utf-8')
lines = fd.readlines()
fd.close()
for line in lines:
elif name == "br":
writeHtml("<br")
- if attrs.getLength > 0:
+ if attrs.getLength() > 0:
names = attrs.getNames()
for name in names:
writeHtml(" " + name + "=\"" + attrs.get(name) + "\"")
else:
writeHtml("<" + name)
- if attrs.getLength > 0:
+ if attrs.getLength() > 0:
names = attrs.getNames()
for name in names:
writeHtml(" " + name + "=\"" + attrs.get(name) + "\"")
parser.setErrorHandler(eh)
try:
- fd = open(file, 'r')
+ fd = codecs.open(file, 'r', 'utf-8')
except:
- fd = open(lookupdir + file, 'r')
+ fd = codecs.open(lookupdir + file, 'r', 'utf-8')
# Parse the file
parser.parse(fd)
try:
(options, arguments) = getopt.getopt(sys.argv[1:],'fhd:')
-except getopt.GetoptError, ex:
+except getopt.GetoptError as ex:
print
- print "ERROR:"
- print ex.msg
+ print ("ERROR:")
+ print (ex.msg)
usage()
sys.exit(1)
pass
replace[idx:] = [lookupdir]
if not arguments:
- print "No source file specified"
+ print ("No source file specified")
usage()
sys.exit(1)
pass