yml2c
changeset 25 cb4a7f8b230d
parent 23 f2e8837da4e9
--- a/yml2c	Tue Nov 20 22:35:38 2018 +0100
+++ b/yml2c	Fri Jan 25 23:31:57 2019 +0100
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
 # vim: set fileencoding=utf-8 :
 
 """\
@@ -11,21 +11,17 @@
 import fileinput, unicodedata
 from optparse import OptionParser
 
-from pyPEG import parse, u
+from pyPEG import parse
 from yml2 import ymlCStyle, comment, oldSyntax
 import backend
 
 def printInfo(option, opt_str, value, parser):
     sys.stdout.write(__doc__)
+    sys.exit(0)
 
 def w(msg):
     if isinstance(msg, BaseException):
-        try:
-            msg = str(msg) + "\n"
-        except:
-            msg = u(msg) + u"\n"
-    if type(msg) is unicode:
-        msg = codecs.encode(msg, sys.stderr.encoding)
+        msg = str(msg) + "\n"
     sys.stderr.write(msg)
 
 optParser = OptionParser()
@@ -86,10 +82,10 @@
     w("\n")
     sys.exit(1)
 except KeyError as msg:
-    w(u"not found: " + u(msg) + u"\n")
+    w("not found: " + msg + "\n")
     sys.exit(4)
 except LookupError as msg:
-    w(u"not found: " + u(msg) + u"\n")
+    w("not found: " + msg + "\n")
     sys.exit(4)
 except Exception as msg:
     w(msg)