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.
This commit is contained in:
Elrond 2013-04-18 15:53:09 +02:00
parent 4c7b9420ab
commit bc92ff9d3c
3 changed files with 6 additions and 3 deletions

View File

@ -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)

View File

@ -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

View File

@ -62,6 +62,7 @@ setup(
'mock',
'itsdangerous',
'pytz',
'six',
## This is optional!
# 'translitcodec',
## For now we're expecting that users will install this from