diff options
author | Erik Rose <grinch@grinchcentral.com> | 2018-06-19 11:31:44 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-06-19 11:31:44 -0400 |
commit | ed91a3581ade2aa0ec7ba41ce81851e28559c659 (patch) | |
tree | 5d60cbce8c1552e249d9bda0cf89ada5fea9d711 | |
parent | d77de4d5fd2f10c3f6802979711198285ff9dc2a (diff) | |
parent | 86765e22fa730cb23d756fa62f6a06f949a9b5ed (diff) | |
download | blessings-ed91a3581ade2aa0ec7ba41ce81851e28559c659.tar.gz |
Switch from 2to3 to six. Close #132.
-rw-r--r-- | .travis.yml | 1 | ||||
-rw-r--r-- | blessings/__init__.py | 15 | ||||
-rw-r--r-- | blessings/tests.py | 11 | ||||
-rw-r--r-- | setup.py | 6 | ||||
-rw-r--r-- | tox.ini | 8 |
5 files changed, 19 insertions, 22 deletions
diff --git a/.travis.yml b/.travis.yml index d6fa6a5..9132c4d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -3,6 +3,7 @@ language: python python: - 2.7 - 3.4 + - 3.5 - 3.6 - pypy diff --git a/blessings/__init__.py b/blessings/__init__.py index 9e10ebc..388cece 100644 --- a/blessings/__init__.py +++ b/blessings/__init__.py @@ -5,6 +5,7 @@ from contextlib import contextmanager import curses from curses import setupterm, tigetnum, tigetstr, tparm from fcntl import ioctl +from six import text_type, string_types try: from io import UnsupportedOperation as IOUnsupportedOperation @@ -420,7 +421,7 @@ COMPOUNDABLES = (COLORS | 'shadow', 'standout', 'subscript', 'superscript'])) -class ParametrizingString(unicode): +class ParametrizingString(text_type): """A Unicode string which can be called to parametrize it as a terminal capability""" @@ -432,7 +433,7 @@ class ParametrizingString(unicode): "normal" capability. """ - new = unicode.__new__(cls, formatting) + new = text_type.__new__(cls, formatting) new._normal = normal return new @@ -461,7 +462,7 @@ class ParametrizingString(unicode): except TypeError: # If the first non-int (i.e. incorrect) arg was a string, suggest # something intelligent: - if len(args) == 1 and isinstance(args[0], basestring): + if len(args) == 1 and isinstance(args[0], string_types): raise TypeError( 'A native or nonexistent capability template received ' '%r when it was expecting ints. You probably misspelled a ' @@ -472,12 +473,12 @@ class ParametrizingString(unicode): raise -class FormattingString(unicode): +class FormattingString(text_type): """A Unicode string which can be called upon a piece of text to wrap it in formatting""" def __new__(cls, formatting, normal): - new = unicode.__new__(cls, formatting) + new = text_type.__new__(cls, formatting) new._normal = normal return new @@ -492,7 +493,7 @@ class FormattingString(unicode): return self + text + self._normal -class NullCallableString(unicode): +class NullCallableString(text_type): """A dummy callable Unicode to stand in for ``FormattingString`` and ``ParametrizingString`` @@ -500,7 +501,7 @@ class NullCallableString(unicode): """ def __new__(cls): - new = unicode.__new__(cls, u'') + new = text_type.__new__(cls, u'') return new def __call__(self, *args): diff --git a/blessings/tests.py b/blessings/tests.py index aff3a2f..a03eb8d 100644 --- a/blessings/tests.py +++ b/blessings/tests.py @@ -9,14 +9,13 @@ All we require from the host machine is that a standard terminfo definition of xterm-256color exists. """ -from __future__ import with_statement # Make 2.5-compatible from curses import tigetstr, tparm from functools import partial -from StringIO import StringIO import sys from nose import SkipTest from nose.tools import eq_ +from six import StringIO # This tests that __all__ is correct, since we use below everything that should # be imported: @@ -229,22 +228,22 @@ def test_nice_formatting_errors(): t = TestTerminal() try: t.bold_misspelled('hey') - except TypeError, e: + except TypeError as e: assert 'probably misspelled' in e.args[0] try: t.bold_misspelled(u'hey') # unicode - except TypeError, e: + except TypeError as e: assert 'probably misspelled' in e.args[0] try: t.bold_misspelled(None) # an arbitrary non-string - except TypeError, e: + except TypeError as e: assert 'probably misspelled' not in e.args[0] try: t.bold_misspelled('a', 'b') # >1 string arg - except TypeError, e: + except TypeError as e: assert 'probably misspelled' not in e.args[0] @@ -10,10 +10,6 @@ except ImportError: from setuptools import setup, find_packages -extra_setup = {} -if sys.version_info >= (3,): - extra_setup['use_2to3'] = True - setup( name='blessings', version='1.6.1', @@ -23,6 +19,7 @@ setup( author_email='erikrose@grinchcentral.com', license='MIT', packages=find_packages(exclude=['ez_setup']), + install_requires=['six'], tests_require=['nose'], test_suite='nose.collector', url='https://github.com/erikrose/blessings', @@ -49,5 +46,4 @@ setup( 'Topic :: Terminals' ], keywords=['terminal', 'tty', 'curses', 'ncurses', 'formatting', 'style', 'color', 'console'], - **extra_setup ) @@ -1,8 +1,8 @@ [tox] -envlist = py27, py34, py36 +envlist = py{27,34,35,36,py} [testenv] commands = nosetests blessings -deps = nose -# So Python 3 runs don't pick up incompatible, un-2to3'd source from the cwd: -changedir = .tox
\ No newline at end of file +deps = + nose + six |