Start to use six for basestring.
authorElrond <elrond+mediagoblin.org@samba-tng.org>
Thu, 18 Apr 2013 13:53:09 +0000 (15:53 +0200)
committerElrond <elrond+mediagoblin.org@samba-tng.org>
Thu, 18 Apr 2013 14:14:16 +0000 (16:14 +0200)
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.

mediagoblin/plugins/piwigo/tools.py
mediagoblin/tools/routing.py
setup.py

index 85d77310ac93835a9487aa0645922727d5dc5903..4d2e985a6d4598aa1ca9972f8ff8d69e8345e149 100644 (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)
index 791cd1e6bc18f0fdfbb08cd5eedb7e8e74fbfa84..a15795fe199694a915576108eceb787933ab7170 100644 (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
 
index ce1e41029e83871bf20c06f882e0c99c71de3628..312de2f8a0148cee011ce7bdd20d0585fc45205a 100644 (file)
--- 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