diff options
author | dol-sen <brian.dolbec@gmail.com> | 2011-09-18 23:22:15 -0700 |
---|---|---|
committer | dol-sen <brian.dolbec@gmail.com> | 2011-09-22 20:12:00 -0700 |
commit | f3e1976da8eeef942a95019669633255fa3b6c50 (patch) | |
tree | fd5abe96dd7a25684a81fd6508e7c5c86204f683 /layman/utils.py | |
parent | 2413c2f4d2c5eb09063f477bcd158244ab8d32ff (diff) | |
download | layman-f3e1976da8eeef942a95019669633255fa3b6c50.tar.gz layman-f3e1976da8eeef942a95019669633255fa3b6c50.tar.bz2 layman-f3e1976da8eeef942a95019669633255fa3b6c50.zip |
py2, py3 compatability changes so 2to3 will work correctly.
Diffstat (limited to 'layman/utils.py')
-rw-r--r-- | layman/utils.py | 16 |
1 files changed, 5 insertions, 11 deletions
diff --git a/layman/utils.py b/layman/utils.py index 6f144be..9ffdda0 100644 --- a/layman/utils.py +++ b/layman/utils.py @@ -43,6 +43,10 @@ from layman.debug import OUT # #------------------------------------------------------------------------------- +def encoder(text, _encoding_): + return codecs.encode(text, _encoding_, 'replace') + + def decode_selection(selection): '''utility function to decode a list of strings accoring to the filesystem encoding @@ -51,14 +55,10 @@ def decode_selection(selection): selection = selection or [] enc = sys.getfilesystemencoding() if enc is not None: - return [i.decode(enc) for i in selection] + return [encoder(i, enc) for i in selection] return selection -def encoder(unicode_text, _encoding_): - return codecs.encode(unicode_text, _encoding_, 'replace') - - def get_encoding(output): if hasattr(output, 'encoding') \ and output.encoding != None: @@ -104,12 +104,6 @@ def terminal_width(): return 80 -def ensure_unicode(obj, encoding='utf-8'): - if isinstance(obj, basestring): - if not isinstance(obj, unicode): - obj = unicode(obj, encoding) - return obj - # From <http://effbot.org/zone/element-lib.htm> # BEGIN def indent(elem, level=0): |