summaryrefslogtreecommitdiff
path: root/utils.py
diff options
context:
space:
mode:
authormikeos <mike.osipov@gmail.com>2013-09-30 04:36:57 +0400
committermikeos <mike.osipov@gmail.com>2013-09-30 04:36:57 +0400
commit0ae5a430e4f92ee7bf9e458cf584a0a12fd5c25a (patch)
treeda2f685caf97a8c51991360b97b852466f7ca765 /utils.py
parent5fb3e2f167ba4a742dc84ed58ddd68c8374a1195 (diff)
refactoring
Diffstat (limited to 'utils.py')
-rw-r--r--utils.py44
1 files changed, 0 insertions, 44 deletions
diff --git a/utils.py b/utils.py
deleted file mode 100644
index ffae410..0000000
--- a/utils.py
+++ /dev/null
@@ -1,44 +0,0 @@
-import sys
-
-if sys.version_info.major == 2:
- def is_python_v2():
- return True
-
- def to_unicode(buf):
- if type(buf) is unicode:
- return buf
- return buf.decode("utf-8")
-
- def to_bytes(buf):
- if type(buf) is unicode:
- return buf.encode("utf-8")
- return buf
-
- class Encoded:
- def __init__(self, stream):
- self.stream = stream
-
- def write(self, msg):
- if type(msg) is unicode:
- self.stream.write(msg.encode("utf-8"))
- else:
- self.stream.write(msg)
-
- def __getattr__(self, attr):
- return getattr(self.stream, attr)
-
- sys.stdout = Encoded(sys.stdout)
- sys.stderr = Encoded(sys.stderr)
-else:
- def is_python_v2():
- return False
-
- def to_unicode(buf):
- if type(buf) is bytes:
- return buf.decode("utf-8")
- return buf
-
- def to_bytes(buf):
- if type(buf) is bytes:
- return buf
- return bytes(buf, "utf-8")