summaryrefslogtreecommitdiffstats
path: root/layman/output.py
diff options
context:
space:
mode:
authordol-sen <brian.dolbec@gmail.com>2011-09-18 23:22:15 -0700
committerdol-sen <brian.dolbec@gmail.com>2011-09-22 20:12:00 -0700
commitf3e1976da8eeef942a95019669633255fa3b6c50 (patch)
treefd5abe96dd7a25684a81fd6508e7c5c86204f683 /layman/output.py
parent2413c2f4d2c5eb09063f477bcd158244ab8d32ff (diff)
downloadlayman-f3e1976da8eeef942a95019669633255fa3b6c50.tar.gz
layman-f3e1976da8eeef942a95019669633255fa3b6c50.tar.bz2
layman-f3e1976da8eeef942a95019669633255fa3b6c50.zip
py2, py3 compatability changes so 2to3 will work correctly.
Diffstat (limited to 'layman/output.py')
-rw-r--r--layman/output.py25
1 files changed, 13 insertions, 12 deletions
diff --git a/layman/output.py b/layman/output.py
index 37da0c5..7b42b81 100644
--- a/layman/output.py
+++ b/layman/output.py
@@ -13,6 +13,7 @@ __version__ = "0.1"
import sys, types
from layman.constants import codes, INFO_LEVEL, WARN_LEVEL, DEBUG_LEVEL, OFF
+from layman.compatibility import encode
class MessageBase(object):
@@ -110,8 +111,8 @@ class Message(MessageBase):
"""empty debug function, does nothing,
declared here for compatibility with DebugMessage
"""
- if type(info) not in types.StringTypes:
- info = str(info)
+ if type(info) != str:#not in types.StringTypes:
+ info = encode(info)
if level > self.debug_lev:
return
@@ -126,8 +127,8 @@ class Message(MessageBase):
def info (self, info, level = INFO_LEVEL):
- if type(info) not in types.StringTypes:
- info = str(info)
+ if type(info) != str:#not in types.StringTypes:
+ info = encode(info)
if level > self.info_lev:
return
@@ -138,8 +139,8 @@ class Message(MessageBase):
def status (self, message, status, info = 'ignored'):
- if type(message) not in types.StringTypes:
- message = str(message)
+ if type(message) != str:#not in types.StringTypes:
+ message = encode(message)
lines = message.split('\n')
@@ -167,8 +168,8 @@ class Message(MessageBase):
def warn (self, warn, level = WARN_LEVEL):
- if type(warn) not in types.StringTypes:
- warn = str(warn)
+ if type(warn) != str:#not in types.StringTypes:
+ warn = encode(warn)
if level > self.warn_lev:
return
@@ -179,8 +180,8 @@ class Message(MessageBase):
def error (self, error):
- if type(error) not in types.StringTypes:
- error = str(error)
+ if type(error) != str:#not in types.StringTypes:
+ error = encode(error)
for i in error.split('\n'):
# NOTE: Forced flushing ensures that stdout and stderr
@@ -195,8 +196,8 @@ class Message(MessageBase):
def die (self, error):
- if type(error) not in types.StringTypes:
- error = str(error)
+ if type(error) != str:#not in types.StringTypes:
+ error = encode(error)
for i in error.split('\n'):
self.error(self.color_func('red', 'Fatal error: ') + i)