|
@@ -16,6 +16,8 @@
|
|
|
|
|
|
# -*- coding: utf8 -*-
|
|
|
|
|
|
+from __future__ import unicode_literals, print_function
|
|
|
+
|
|
|
import sys
|
|
|
|
|
|
"""
|
|
@@ -27,35 +29,27 @@ using print to generate the output"""
|
|
|
def printf(string, outputlevel, descriptor="stdout", level="default"):
|
|
|
if descriptor == "stdout":
|
|
|
if level == "default" and outputlevel == "default":
|
|
|
- if isinstance(string, unicode):
|
|
|
- print string.encode("utf8")
|
|
|
- elif string is str:
|
|
|
- print string
|
|
|
+ if sys.version_info >= (3,0):
|
|
|
+ print(string)
|
|
|
else:
|
|
|
- print str(string)
|
|
|
+ print(string.encode("utf8"))
|
|
|
elif level == "verbose":
|
|
|
- if isinstance(string, unicode):
|
|
|
- print string.encode("utf8")
|
|
|
- elif string is str:
|
|
|
- print string
|
|
|
+ if sys.version_info >= (3,0):
|
|
|
+ print(string)
|
|
|
else:
|
|
|
- print str(string)
|
|
|
+ print(string.encode("utf8"))
|
|
|
elif level == "quiet":
|
|
|
pass
|
|
|
elif descriptor == "stderr":
|
|
|
if level == "default" and outputlevel == "default":
|
|
|
- if isinstance(string, unicode):
|
|
|
- print >> sys.stderr, string.encode("utf8")
|
|
|
- elif string is str:
|
|
|
- print >> sys.stderr, string
|
|
|
+ if sys.version_info >= (3,0):
|
|
|
+ print (string, file=sys.stderr)
|
|
|
else:
|
|
|
- print str(string)
|
|
|
+ print(string.encode("utf8"), file=sys.stderr)
|
|
|
elif level == "verbose":
|
|
|
- if isinstance(string, unicode):
|
|
|
- print >> sys.stderr, string.encode("utf8")
|
|
|
- elif string is str:
|
|
|
- print >> sys.stderr, string
|
|
|
+ if sys.version_info >= (3,0):
|
|
|
+ print (string, file=sys.stderr)
|
|
|
else:
|
|
|
- print >> sys.stderr, str(string)
|
|
|
+ print(string.encode("utf8"), file=sys.stderr)
|
|
|
elif level == "quiet":
|
|
|
pass
|