Browse Source

fixes

pypackage 2.6.0
Volker Birk 2 years ago
parent
commit
802a0f1d11
3 changed files with 13 additions and 18 deletions
  1. +1
    -1
      backend.py
  2. +3
    -6
      yml2c
  3. +9
    -11
      yml2proc

+ 1
- 1
backend.py View File

@ -246,7 +246,7 @@ class YF:
hasContent = True
resultParms = self.values.copy()
macros = self.macros.copy()
toDelete = resultParms.keys()
toDelete = [ key for key in resultParms.keys() ]
for key in toDelete:
if key[0] == "*":
del resultParms[key]


+ 3
- 6
yml2c View File

@ -20,10 +20,7 @@ def printInfo(option, opt_str, value, parser):
def w(msg):
if isinstance(msg, BaseException):
try:
msg = str(msg) + "\n"
except:
msg = u(msg) + u"\n"
msg = str(msg) + "\n"
if type(msg) is bytes:
msg = codecs.encode(msg, sys.stderr.encoding)
sys.stderr.write(msg)
@ -87,10 +84,10 @@ except KeyboardInterrupt:
w("\n")
sys.exit(1)
except KeyError as msg:
w(u"not found: " + u(msg) + u"\n")
w("not found: " + u(msg) + "\n")
sys.exit(4)
except LookupError as msg:
w(u"not found: " + u(msg) + u"\n")
w("not found: " + u(msg) + "\n")
sys.exit(4)
except Exception as msg:
w(msg)


+ 9
- 11
yml2proc View File

@ -32,9 +32,7 @@ def w(msg):
try:
msg = str(msg) + "\n"
except:
msg = u(msg) + u"\n"
if type(msg) is str:
msg = codecs.encode(msg, sys.stderr.encoding)
msg = u(msg) + "\n"
sys.stderr.write(msg)
optParser = OptionParser()
@ -114,7 +112,7 @@ if (options.xslt and options.yslt) or (options.xslt and options.xpath) or (opti
try:
ymlC = ymlCStyle()
rtext = u""
rtext = ""
if not options.emptyinput:
files = fileinput.input(args, mode="rU", openhook=fileinput.hook_encoded(options.encoding))
@ -132,7 +130,7 @@ try:
rtext = backend.finish(result)
if not rtext:
rtext = u"<empty/>"
rtext = "<empty/>"
def ymldebug(context, text):
if options.trace:
@ -153,7 +151,7 @@ try:
if options.xpath:
tree = etree.fromstring(rtext)
ltree = tree.xpath(codecs.decode(options.xpath, options.encoding))
rtext = u""
rtext = ""
try:
for rtree in ltree:
rtext += etree.tostring(rtree, pretty_print=options.pretty, encoding=unicode)
@ -186,7 +184,7 @@ try:
params[key] = u(value)
if options.stringparams:
for key, value in eval(options.stringparams).iteritems():
params[key] = u"'" + u(value) + u"'"
params[key] = "'" + u(value) + "'"
rresult = transform(doc, **params)
# lxml is somewhat buggy
@ -226,18 +224,18 @@ except KeyboardInterrupt:
w("\n")
sys.exit(1)
except YMLAssert as msg:
w(u"YML Assertion failed: " + u(msg) + u"\n")
w("YML Assertion failed: " + u(msg) + "\n")
sys.exit(2)
except KeyError as msg:
w(u"not found: " + u(msg) + u"\n")
w("not found: " + u(msg) + "\n")
sys.exit(4)
except LookupError as msg:
w(u"not found: " + u(msg) + u"\n")
w("not found: " + u(msg) + "\n")
sys.exit(4)
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")
w("XML error: " + u(entry.message) + "\n")
sys.exit(5)
except Exception as msg:
w(msg)


Loading…
Cancel
Save