From: Elrond Date: Thu, 18 Apr 2013 13:53:09 +0000 (+0200) Subject: Start to use six for basestring. X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=bc92ff9d3cc1e4b4aadbd7728f52f2829178e699;p=mediagoblin.git Start to use six for basestring. six allows us to smoothly get more forward compatible with py3. The idea is to change things over to use six, when/if we feel a need for it. --- diff --git a/mediagoblin/plugins/piwigo/tools.py b/mediagoblin/plugins/piwigo/tools.py index 85d77310..4d2e985a 100644 --- a/mediagoblin/plugins/piwigo/tools.py +++ b/mediagoblin/plugins/piwigo/tools.py @@ -16,6 +16,7 @@ import logging +import six import lxml.etree as ET from werkzeug.exceptions import MethodNotAllowed @@ -43,7 +44,7 @@ class PwgNamedArray(list): def _fill_element_dict(el, data, as_attr=()): for k, v in data.iteritems(): if k in as_attr: - if not isinstance(v, basestring): + if not isinstance(v, six.string_types): v = str(v) el.set(k, v) else: @@ -57,7 +58,7 @@ def _fill_element(el, data): el.text = "1" else: el.text = "0" - elif isinstance(data, basestring): + elif isinstance(data, six.string_types): el.text = data elif isinstance(data, int): el.text = str(data) diff --git a/mediagoblin/tools/routing.py b/mediagoblin/tools/routing.py index 791cd1e6..a15795fe 100644 --- a/mediagoblin/tools/routing.py +++ b/mediagoblin/tools/routing.py @@ -16,6 +16,7 @@ import logging +import six from werkzeug.routing import Map, Rule from mediagoblin.tools.common import import_component @@ -43,7 +44,7 @@ def endpoint_to_controller(rule): _log.debug('endpoint: {0} view_func: {1}'.format(endpoint, view_func)) # import the endpoint, or if it's already a callable, call that - if isinstance(view_func, basestring): + if isinstance(view_func, six.string_types): view_func = import_component(view_func) rule.gmg_controller = view_func diff --git a/setup.py b/setup.py index ce1e4102..312de2f8 100644 --- a/setup.py +++ b/setup.py @@ -62,6 +62,7 @@ setup( 'mock', 'itsdangerous', 'pytz', + 'six', ## This is optional! # 'translitcodec', ## For now we're expecting that users will install this from