beginning with Python 3 compat

python3
Volker Birk 6 years ago
parent 0a3d0fee6f
commit 7cd9acf7be
  1. 10
      yml2c
  2. 14
      yml2proc

10
yml2c

@ -75,7 +75,7 @@ try:
result = parse(ymlC, files, True, comment, packrat=True)
if options.parseonly:
print result
print(result)
else:
result = backend.finish(result)
if options.normalization != "none":
@ -86,17 +86,17 @@ try:
outfile.write(codecs.encode(result, options.encoding))
outfile.close()
else:
print codecs.encode(result, options.encoding)
print(codecs.encode(result, options.encoding))
except KeyboardInterrupt:
w("\n")
sys.exit(1)
except KeyError, msg:
except KeyError as msg:
w(u"not found: " + u(msg) + u"\n")
sys.exit(4)
except LookupError, msg:
except LookupError as msg:
w(u"not found: " + u(msg) + u"\n")
sys.exit(4)
except Exception, msg:
except Exception as msg:
w(msg)
sys.exit(5)

@ -132,7 +132,7 @@ try:
else:
result = parse(ymlC, files, True, comment)
if options.parseonly:
print result
print(result)
sys.exit(0)
else:
rtext = backend.finish(result)
@ -224,25 +224,25 @@ try:
outfile.write(plaintext)
outfile.close()
else:
print plaintext
print(plaintext)
except KeyboardInterrupt:
w("\n")
sys.exit(1)
except YMLAssert, msg:
except YMLAssert as msg:
w(u"YML Assertion failed: " + u(msg) + u"\n")
sys.exit(2)
except KeyError, msg:
except KeyError as msg:
w(u"not found: " + u(msg) + u"\n")
sys.exit(4)
except LookupError, msg:
except LookupError as msg:
w(u"not found: " + u(msg) + u"\n")
sys.exit(4)
except etree.XMLSyntaxError, e:
except etree.XMLSyntaxError as e:
log = e.error_log.filter_from_level(etree.ErrorLevels.FATAL)
for entry in log:
w(u"XML error: " + u(entry.message) + u"\n")
sys.exit(5)
except Exception, msg:
except Exception as msg:
w(msg)
sys.exit(5)

Loading…
Cancel
Save