dirtywords

portable text interface framework  https://pypi.python.org/pypi/dirtywords
git clone https://git.ce9e.org/dirtywords.git

commit
21479df8bdcc0a8a856b2360f587bc7fc8f4d1ae
parent
0fa6294a6c48214b92e99b376c53b553f407fdb5
Author
Tobias Bengfort <tobias.bengfort@gmx.net>
Date
2015-03-22 22:34
py3: do not depend on unicode class

Diffstat

M dirtywords/base.py 11 ++++++++---

1 files changed, 8 insertions, 3 deletions


diff --git a/dirtywords/base.py b/dirtywords/base.py

@@ -23,8 +23,13 @@ import string
   23    23 
   24    24 from .constants import KEYS
   25    25 
   -1    26 try:
   -1    27     ustr = unicode
   -1    28 except NameError:
   -1    29     ustr = str
   26    30 
   27    -1 class AttrString(unicode):
   -1    31 
   -1    32 class AttrString(ustr):
   28    33     """Unicode string with additional attributes.
   29    34 
   30    35     Rather than specifying formatting information with :py:meth:`Core.putstr`,
@@ -92,7 +97,7 @@ class AttrString(unicode):
   92    97         return (self[i] for i in range(len(self)))
   93    98 
   94    99     def __getitem__(self, i):
   95    -1         ch = unicode.__getitem__(self, i)
   -1   100         ch = ustr.__getitem__(self, i)
   96   101         return AttrString(ch, **self.get_attrs())
   97   102 
   98   103 
@@ -226,7 +231,7 @@ class Screen(Core):
  226   231                 return s.decode('utf8')
  227   232 
  228   233             elif ch < 256 and chr(ch) in string.printable:
  229    -1                 return unicode(chr(ch))
   -1   234                 return ustr(chr(ch))
  230   235 
  231   236         if blocking:
  232   237             return self.getkey(blocking=blocking)