From c3c44c4f5504bc7a94d2c6d19425ebc15bf82068 Mon Sep 17 00:00:00 2001 From: Jacob-Mowat Date: Sun, 25 Nov 2018 17:15:40 +0000 Subject: [PATCH 1/2] Added check for , was missing before --- fabulous/image.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/fabulous/image.py b/fabulous/image.py index c94dae7..39567ee 100644 --- a/fabulous/image.py +++ b/fabulous/image.py @@ -28,9 +28,16 @@ import sys import itertools +from six import string_types + from fabulous import utils, xterm256, grapefruit from fabulous.compatibility import printy +try: + basestring = basestring +except: + basestring = (str, bytes) + class Image(object): """Printing image files to a terminal @@ -112,7 +119,7 @@ def resize(self, width=None): (iw, ih) = self.size if width is None: width = min(iw, utils.term.width) - elif isinstance(width, basestring): + elif isinstance(width, string_types): percents = dict([(pct, '%s%%' % (pct)) for pct in range(101)]) width = percents[width] height = int(float(ih) * (float(width) / float(iw))) From d30e12181b2aae09e442641db8e3f46236fda42b Mon Sep 17 00:00:00 2001 From: Jacob-Mowat Date: Sun, 25 Nov 2018 17:23:08 +0000 Subject: [PATCH 2/2] Revision of commit , removed import statement that was redundant (left behind by me), using basestring defined in commit instead of six.string_types. Future versions could use possibly Six.string_types or future.utils version of string_types --- fabulous/image.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/fabulous/image.py b/fabulous/image.py index 39567ee..b0dd248 100644 --- a/fabulous/image.py +++ b/fabulous/image.py @@ -28,8 +28,6 @@ import sys import itertools -from six import string_types - from fabulous import utils, xterm256, grapefruit from fabulous.compatibility import printy @@ -119,7 +117,7 @@ def resize(self, width=None): (iw, ih) = self.size if width is None: width = min(iw, utils.term.width) - elif isinstance(width, string_types): + elif isinstance(width, basestring): percents = dict([(pct, '%s%%' % (pct)) for pct in range(101)]) width = percents[width] height = int(float(ih) * (float(width) / float(iw)))