dirtywords

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

commit
b44f340d43716e40a650e97f205f7fc44f3fc38c
parent
b1014a7eb16ad0c26792e385fe754cbd0374f039
Author
Tobias Bengfort <tobias.bengfort@posteo.de>
Date
2018-08-03 11:50
use six for unicode

Diffstat

M dirtywords/base.py 15 ++++++---------
M dirtywords/stupid.py 4 +++-
M setup.py 3 +++

3 files changed, 12 insertions, 10 deletions


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

@@ -21,16 +21,13 @@ from __future__ import absolute_import
   21    21 from time import time
   22    22 import string
   23    23 
   24    -1 from .constants import KEYS
   -1    24 import six
   25    25 
   26    -1 try:
   27    -1     ustr = unicode
   28    -1 except NameError:
   29    -1     ustr = str
   -1    26 from .constants import KEYS
   30    27 
   31    28 
   32    -1 class AttrString(ustr):
   33    -1     """Unicode string with additional attributes.
   -1    29 class AttrString(six.text_type):
   -1    30     """String with additional attributes.
   34    31 
   35    32     Rather than specifying formatting information with :py:meth:`Core.putstr`,
   36    33     it is saved with the string object itself. This way the formatting can be
@@ -97,7 +94,7 @@ class AttrString(ustr):
   97    94         return (self[i] for i in range(len(self)))
   98    95 
   99    96     def __getitem__(self, i):
  100    -1         ch = ustr.__getitem__(self, i)
   -1    97         ch = super(AttrString, self).__getitem__(i)
  101    98         return AttrString(ch, **self.get_attrs())
  102    99 
  103   100 
@@ -231,7 +228,7 @@ class Screen(Core):
  231   228                 return s.decode('utf8')
  232   229 
  233   230             elif ch < 256 and chr(ch) in string.printable:
  234    -1                 return ustr(chr(ch))
   -1   231                 return six.text_type(chr(ch))
  235   232 
  236   233         if blocking:
  237   234             return self.getkey(blocking=blocking)

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

@@ -10,6 +10,8 @@ cross-platform.
   10    10 from __future__ import absolute_import
   11    11 from __future__ import print_function
   12    12 
   -1    13 import six
   -1    14 
   13    15 from . import base
   14    16 from .constants import KEYS
   15    17 
@@ -63,7 +65,7 @@ class Screen(base.Screen):
   63    65             '27, 91, 67': KEYS['Right'],
   64    66             '27, 91, 68': KEYS['Left'],
   65    67         }
   66    -1         key = ', '.join([str(i) for i in l])
   -1    68         key = ', '.join([six.text_type(i) for i in l])
   67    69         if key in codes:
   68    70             return codes[key]
   69    71         elif len(l) == 1:

diff --git a/setup.py b/setup.py

@@ -10,6 +10,9 @@ setup(
   10    10     author='Tobias Bengfort',
   11    11     author_email='tobias.bengfort@posteo.de',
   12    12     packages=['dirtywords'],
   -1    13     install_requires=[
   -1    14         'six',
   -1    15     ],
   13    16     extras_require={
   14    17         'curses_core': ['curses'],
   15    18         'pygame_core': ['pygame'],