yml2c
changeset 7 f81a4471bc28
parent 4 e7b49a65cf3a
child 11 7026ccc7a60e
equal deleted inserted replaced
6:5ea9477ef8bb 7:f81a4471bc28
    73 
    73 
    74     ymlC = ymlCStyle()
    74     ymlC = ymlCStyle()
    75     result = parse(ymlC, files, True, comment, packrat=True)
    75     result = parse(ymlC, files, True, comment, packrat=True)
    76 
    76 
    77     if options.parseonly:
    77     if options.parseonly:
    78         print result
    78         print(result)
    79     else:
    79     else:
    80         result = backend.finish(result)
    80         result = backend.finish(result)
    81         if options.normalization != "none":
    81         if options.normalization != "none":
    82             result = unicodedata.normalize(options.normalization, result)
    82             result = unicodedata.normalize(options.normalization, result)
    83 
    83 
    84         if options.outputFile and options.outputFile != "-":
    84         if options.outputFile and options.outputFile != "-":
    85             outfile = open(options.outputFile, "w")
    85             outfile = open(options.outputFile, "w")
    86             outfile.write(codecs.encode(result, options.encoding))
    86             outfile.write(codecs.encode(result, options.encoding))
    87             outfile.close()
    87             outfile.close()
    88         else:
    88         else:
    89             print codecs.encode(result, options.encoding)
    89             print(codecs.encode(result, options.encoding))
    90 
    90 
    91 except KeyboardInterrupt:
    91 except KeyboardInterrupt:
    92     w("\n")
    92     w("\n")
    93     sys.exit(1)
    93     sys.exit(1)
    94 except KeyError, msg:
    94 except KeyError as msg:
    95     w(u"not found: " + u(msg) + u"\n")
    95     w(u"not found: " + u(msg) + u"\n")
    96     sys.exit(4)
    96     sys.exit(4)
    97 except LookupError, msg:
    97 except LookupError as msg:
    98     w(u"not found: " + u(msg) + u"\n")
    98     w(u"not found: " + u(msg) + u"\n")
    99     sys.exit(4)
    99     sys.exit(4)
   100 except Exception, msg:
   100 except Exception as msg:
   101     w(msg)
   101     w(msg)
   102     sys.exit(5)
   102     sys.exit(5)