222 if options.outputFile and options.outputFile != "-": |
222 if options.outputFile and options.outputFile != "-": |
223 outfile = open(options.outputFile, "w") |
223 outfile = open(options.outputFile, "w") |
224 outfile.write(plaintext) |
224 outfile.write(plaintext) |
225 outfile.close() |
225 outfile.close() |
226 else: |
226 else: |
227 print plaintext |
227 print(plaintext) |
228 |
228 |
229 except KeyboardInterrupt: |
229 except KeyboardInterrupt: |
230 w("\n") |
230 w("\n") |
231 sys.exit(1) |
231 sys.exit(1) |
232 except YMLAssert, msg: |
232 except YMLAssert as msg: |
233 w(u"YML Assertion failed: " + u(msg) + u"\n") |
233 w(u"YML Assertion failed: " + u(msg) + u"\n") |
234 sys.exit(2) |
234 sys.exit(2) |
235 except KeyError, msg: |
235 except KeyError as msg: |
236 w(u"not found: " + u(msg) + u"\n") |
236 w(u"not found: " + u(msg) + u"\n") |
237 sys.exit(4) |
237 sys.exit(4) |
238 except LookupError, msg: |
238 except LookupError as msg: |
239 w(u"not found: " + u(msg) + u"\n") |
239 w(u"not found: " + u(msg) + u"\n") |
240 sys.exit(4) |
240 sys.exit(4) |
241 except etree.XMLSyntaxError, e: |
241 except etree.XMLSyntaxError as e: |
242 log = e.error_log.filter_from_level(etree.ErrorLevels.FATAL) |
242 log = e.error_log.filter_from_level(etree.ErrorLevels.FATAL) |
243 for entry in log: |
243 for entry in log: |
244 w(u"XML error: " + u(entry.message) + u"\n") |
244 w(u"XML error: " + u(entry.message) + u"\n") |
245 sys.exit(5) |
245 sys.exit(5) |
246 except Exception, msg: |
246 except Exception as msg: |
247 w(msg) |
247 w(msg) |
248 sys.exit(5) |
248 sys.exit(5) |