# HG changeset patch # User Rémi Cardona # Date 1442239387 -7200 # Node ID 84468b90e9c1c0134b06274dc4718cdd059f58c4 # Parent f4dec0cca9a172e076103df4861631d96131d861 [py3k] basestring → six.string_types diff -r f4dec0cca9a1 -r 84468b90e9c1 dataimport/csv.py --- a/dataimport/csv.py Wed Sep 16 11:23:51 2015 +0200 +++ b/dataimport/csv.py Mon Sep 14 16:03:07 2015 +0200 @@ -22,11 +22,13 @@ import warnings import os.path as osp +from six import string_types + from logilab.common import shellutils def count_lines(stream_or_filename): - if isinstance(stream_or_filename, basestring): + if isinstance(stream_or_filename, string_types): f = open(stream_or_filename) else: f = stream_or_filename @@ -47,7 +49,7 @@ if quote is not None: quotechar = quote warnings.warn("[3.20] 'quote' kwarg is deprecated, use 'quotechar' instead") - if isinstance(stream_or_path, basestring): + if isinstance(stream_or_path, string_types): if not osp.exists(stream_or_path): raise Exception("file doesn't exists: %s" % stream_or_path) stream = open(stream_or_path) diff -r f4dec0cca9a1 -r 84468b90e9c1 dataimport/pgstore.py --- a/dataimport/pgstore.py Wed Sep 16 11:23:51 2015 +0200 +++ b/dataimport/pgstore.py Mon Sep 14 16:03:07 2015 +0200 @@ -27,6 +27,7 @@ from collections import defaultdict from base64 import b64encode +from six import string_types from six.moves import cPickle as pickle, range from cubicweb.utils import make_uid @@ -166,7 +167,7 @@ _COPYFROM_BUFFER_CONVERTERS = [ (type(None), _copyfrom_buffer_convert_None), ((long, int, float), _copyfrom_buffer_convert_number), - (basestring, _copyfrom_buffer_convert_string), + (string_types, _copyfrom_buffer_convert_string), (datetime, _copyfrom_buffer_convert_datetime), (date, _copyfrom_buffer_convert_date), (time, _copyfrom_buffer_convert_time), diff -r f4dec0cca9a1 -r 84468b90e9c1 devtools/fake.py --- a/devtools/fake.py Wed Sep 16 11:23:51 2015 +0200 +++ b/devtools/fake.py Mon Sep 14 16:03:07 2015 +0200 @@ -22,6 +22,8 @@ from contextlib import contextmanager +from six import string_types + from logilab.database import get_db_helper from cubicweb.req import RequestSessionBase @@ -91,7 +93,7 @@ def set_request_header(self, header, value, raw=False): """set an incoming HTTP header (for test purpose only)""" - if isinstance(value, basestring): + if isinstance(value, string_types): value = [value] if raw: # adding encoded header is important, else page content diff -r f4dec0cca9a1 -r 84468b90e9c1 devtools/testlib.py --- a/devtools/testlib.py Wed Sep 16 11:23:51 2015 +0200 +++ b/devtools/testlib.py Mon Sep 14 16:03:07 2015 +0200 @@ -28,6 +28,7 @@ from warnings import warn from itertools import chain +from six import string_types from six.moves import range from six.moves.urllib.parse import urlparse, parse_qs, unquote as urlunquote @@ -521,7 +522,7 @@ """ torestore = [] for erschema, etypeperms in chain(perm_overrides, perm_kwoverrides.iteritems()): - if isinstance(erschema, basestring): + if isinstance(erschema, string_types): erschema = self.schema[erschema] for action, actionperms in etypeperms.iteritems(): origperms = erschema.permissions[action] diff -r f4dec0cca9a1 -r 84468b90e9c1 entities/__init__.py --- a/entities/__init__.py Wed Sep 16 11:23:51 2015 +0200 +++ b/entities/__init__.py Mon Sep 14 16:03:07 2015 +0200 @@ -19,6 +19,7 @@ __docformat__ = "restructuredtext en" +from six import string_types from logilab.common.decorators import classproperty @@ -134,7 +135,7 @@ return self.dc_title().lower() value = self.cw_attr_value(rtype) # do not restrict to `unicode` because Bytes will return a `str` value - if isinstance(value, basestring): + if isinstance(value, string_types): return self.printable_value(rtype, format='text/plain').lower() return value diff -r f4dec0cca9a1 -r 84468b90e9c1 entities/authobjs.py --- a/entities/authobjs.py Wed Sep 16 11:23:51 2015 +0200 +++ b/entities/authobjs.py Mon Sep 14 16:03:07 2015 +0200 @@ -19,6 +19,8 @@ __docformat__ = "restructuredtext en" +from six import string_types + from logilab.common.decorators import cached from cubicweb import Unauthorized @@ -126,7 +128,7 @@ :type groups: str or iterable(str) :param groups: a group name or an iterable on group names """ - if isinstance(groups, basestring): + if isinstance(groups, string_types): groups = frozenset((groups,)) elif isinstance(groups, (tuple, list)): groups = frozenset(groups) diff -r f4dec0cca9a1 -r 84468b90e9c1 entities/wfobjs.py --- a/entities/wfobjs.py Wed Sep 16 11:23:51 2015 +0200 +++ b/entities/wfobjs.py Mon Sep 14 16:03:07 2015 +0200 @@ -25,6 +25,7 @@ __docformat__ = "restructuredtext en" +from six import string_types from logilab.common.decorators import cached, clear_cache from logilab.common.deprecation import deprecated @@ -259,10 +260,10 @@ 'WHERE T eid %(x)s, G name %(gn)s', {'x': self.eid, 'gn': unicode(gname)}) assert rset, '%s is not a known group' % gname - if isinstance(conditions, basestring): + if isinstance(conditions, string_types): conditions = (conditions,) for expr in conditions: - if isinstance(expr, basestring): + if isinstance(expr, string_types): kwargs = {'expr': unicode(expr)} else: assert isinstance(expr, dict) @@ -529,7 +530,7 @@ def _get_transition(self, tr): assert self.current_workflow - if isinstance(tr, basestring): + if isinstance(tr, string_types): _tr = self.current_workflow.transition_by_name(tr) assert _tr is not None, 'not a %s transition: %s' % ( self.__regid__, tr) diff -r f4dec0cca9a1 -r 84468b90e9c1 entity.py --- a/entity.py Wed Sep 16 11:23:51 2015 +0200 +++ b/entity.py Mon Sep 14 16:03:07 2015 +0200 @@ -22,6 +22,7 @@ from warnings import warn from functools import partial +from six import string_types from six.moves import range from logilab.common.decorators import cached @@ -281,7 +282,7 @@ select = Select() mainvar = select.get_variable(mainvar) select.add_selected(mainvar) - elif isinstance(mainvar, basestring): + elif isinstance(mainvar, string_types): assert mainvar in select.defined_vars mainvar = select.get_variable(mainvar) # eases string -> syntax tree test transition: please remove once stable @@ -697,7 +698,7 @@ attr = str(attr) if value is _marker: value = getattr(self, attr) - if isinstance(value, basestring): + if isinstance(value, string_types): value = value.strip() if value is None or value == '': # don't use "not", 0 is an acceptable value return u'' diff -r f4dec0cca9a1 -r 84468b90e9c1 migration.py --- a/migration.py Wed Sep 16 11:23:51 2015 +0200 +++ b/migration.py Mon Sep 14 16:03:07 2015 +0200 @@ -27,6 +27,8 @@ from os.path import exists, join, basename, splitext from itertools import chain +from six import string_types + from logilab.common import IGNORED_EXTENSIONS from logilab.common.decorators import cached from logilab.common.configuration import REQUIRED, read_old_config @@ -397,7 +399,7 @@ """modify the list of used cubes in the in-memory config returns newly inserted cubes, including dependencies """ - if isinstance(cubes, basestring): + if isinstance(cubes, string_types): cubes = (cubes,) origcubes = self.config.cubes() newcubes = [p for p in self.config.expand_cubes(cubes) diff -r f4dec0cca9a1 -r 84468b90e9c1 predicates.py --- a/predicates.py Wed Sep 16 11:23:51 2015 +0200 +++ b/predicates.py Mon Sep 14 16:03:07 2015 +0200 @@ -24,6 +24,7 @@ from warnings import warn from operator import eq +from six import string_types from six.moves import range from logilab.common.deprecation import deprecated @@ -613,7 +614,7 @@ super(is_instance, self).__init__(**kwargs) self.expected_etypes = expected_etypes for etype in self.expected_etypes: - assert isinstance(etype, basestring), etype + assert isinstance(etype, string_types), etype def __str__(self): return '%s(%s)' % (self.__class__.__name__, @@ -1093,7 +1094,7 @@ """ if from_state_name is not None: warn("on_fire_transition's from_state_name argument is unused", DeprecationWarning) - if isinstance(tr_names, basestring): + if isinstance(tr_names, string_types): tr_names = set((tr_names,)) def match_etype_and_transition(trinfo): # take care trinfo.transition is None when calling change_state @@ -1293,7 +1294,7 @@ raise ValueError("match_form_params() can't be called with both " "positional and named arguments") if expected: - if len(expected) == 1 and not isinstance(expected[0], basestring): + if len(expected) == 1 and not isinstance(expected[0], string_types): raise ValueError("match_form_params() positional arguments " "must be strings") super(match_form_params, self).__init__(*expected) diff -r f4dec0cca9a1 -r 84468b90e9c1 rqlrewrite.py --- a/rqlrewrite.py Wed Sep 16 11:23:51 2015 +0200 +++ b/rqlrewrite.py Mon Sep 14 16:03:07 2015 +0200 @@ -22,6 +22,8 @@ """ __docformat__ = "restructuredtext en" +from six import string_types + from rql import nodes as n, stmts, TypeResolverException from rql.utils import common_parent @@ -883,7 +885,7 @@ return n.Constant(vi['const'], 'Int') return n.VariableRef(stmt.get_variable(selectvar)) vname_or_term = self._get_varname_or_term(node.name) - if isinstance(vname_or_term, basestring): + if isinstance(vname_or_term, string_types): return n.VariableRef(stmt.get_variable(vname_or_term)) # shared term return vname_or_term.copy(stmt) diff -r f4dec0cca9a1 -r 84468b90e9c1 rtags.py --- a/rtags.py Wed Sep 16 11:23:51 2015 +0200 +++ b/rtags.py Mon Sep 14 16:03:07 2015 +0200 @@ -40,6 +40,8 @@ import logging from warnings import warn +from six import string_types + from logilab.common.logging_ext import set_log_methods from logilab.common.registry import RegistrableInstance, yes @@ -145,7 +147,7 @@ return tag def _tag_etype_attr(self, etype, attr, desttype='*', *args, **kwargs): - if isinstance(attr, basestring): + if isinstance(attr, string_types): attr, role = attr, 'subject' else: attr, role = attr diff -r f4dec0cca9a1 -r 84468b90e9c1 schema.py --- a/schema.py Wed Sep 16 11:23:51 2015 +0200 +++ b/schema.py Mon Sep 14 16:03:07 2015 +0200 @@ -26,6 +26,7 @@ from logging import getLogger from warnings import warn +from six import string_types from six.moves import range from logilab.common import tempattr @@ -207,7 +208,7 @@ """ self.eid = eid # eid of the entity representing this rql expression assert mainvars, 'bad mainvars %s' % mainvars - if isinstance(mainvars, basestring): + if isinstance(mainvars, string_types): mainvars = set(splitstrip(mainvars)) elif not isinstance(mainvars, set): mainvars = set(mainvars) @@ -579,7 +580,7 @@ assert action in self.ACTIONS, action #assert action in self._groups, '%s %s' % (self, action) try: - return frozenset(g for g in self.permissions[action] if isinstance(g, basestring)) + return frozenset(g for g in self.permissions[action] if isinstance(g, string_types)) except KeyError: return () PermissionMixIn.get_groups = get_groups @@ -598,7 +599,7 @@ assert action in self.ACTIONS, action #assert action in self._rqlexprs, '%s %s' % (self, action) try: - return tuple(g for g in self.permissions[action] if not isinstance(g, basestring)) + return tuple(g for g in self.permissions[action] if not isinstance(g, string_types)) except KeyError: return () PermissionMixIn.get_rqlexprs = get_rqlexprs diff -r f4dec0cca9a1 -r 84468b90e9c1 selectors.py --- a/selectors.py Wed Sep 16 11:23:51 2015 +0200 +++ b/selectors.py Mon Sep 14 16:03:07 2015 +0200 @@ -18,6 +18,8 @@ from warnings import warn +from six import string_types + from logilab.common.deprecation import deprecated, class_renamed from cubicweb.predicates import * @@ -84,7 +86,7 @@ See `EntityPredicate` documentation for behaviour when row is not specified. - :param *etypes: entity types (`basestring`) which should be refused + :param *etypes: entity types (`string_types`) which should be refused """ def __init__(self, *etypes): super(_but_etype, self).__init__() diff -r f4dec0cca9a1 -r 84468b90e9c1 server/__init__.py --- a/server/__init__.py Wed Sep 16 11:23:51 2015 +0200 +++ b/server/__init__.py Mon Sep 14 16:03:07 2015 +0200 @@ -29,6 +29,8 @@ from glob import glob from contextlib import contextmanager +from six import string_types + from logilab.common.modutils import LazyObject from logilab.common.textutils import splitstrip from logilab.common.registry import yes @@ -139,7 +141,7 @@ if not debugmode: DEBUG = 0 return - if isinstance(debugmode, basestring): + if isinstance(debugmode, string_types): for mode in splitstrip(debugmode, sep='|'): DEBUG |= globals()[mode] else: diff -r f4dec0cca9a1 -r 84468b90e9c1 server/querier.py --- a/server/querier.py Wed Sep 16 11:23:51 2015 +0200 +++ b/server/querier.py Mon Sep 14 16:03:07 2015 +0200 @@ -24,6 +24,7 @@ from itertools import repeat +from six import string_types from six.moves import range from rql import RQLSyntaxError, CoercionError @@ -450,11 +451,11 @@ relations = {} for subj, rtype, obj in self.relation_defs(): # if a string is given into args instead of an int, we get it here - if isinstance(subj, basestring): + if isinstance(subj, string_types): subj = int(subj) elif not isinstance(subj, (int, long)): subj = subj.entity.eid - if isinstance(obj, basestring): + if isinstance(obj, string_types): obj = int(obj) elif not isinstance(obj, (int, long)): obj = obj.entity.eid diff -r f4dec0cca9a1 -r 84468b90e9c1 server/schemaserial.py --- a/server/schemaserial.py Wed Sep 16 11:23:51 2015 +0200 +++ b/server/schemaserial.py Mon Sep 14 16:03:07 2015 +0200 @@ -24,6 +24,8 @@ import json import sys +from six import string_types + from logilab.common.shellutils import ProgressBar, DummyProgressBar from yams import BadSchemaDefinition, schema as schemamod, buildobjs as ybo @@ -614,7 +616,7 @@ # may occurs when modifying persistent schema continue for group_or_rqlexpr in grantedto: - if isinstance(group_or_rqlexpr, basestring): + if isinstance(group_or_rqlexpr, string_types): # group try: yield ('SET X %s_permission Y WHERE Y eid %%(g)s, X eid %%(x)s' % action, diff -r f4dec0cca9a1 -r 84468b90e9c1 server/serverctl.py --- a/server/serverctl.py Wed Sep 16 11:23:51 2015 +0200 +++ b/server/serverctl.py Mon Sep 14 16:03:07 2015 +0200 @@ -29,6 +29,8 @@ import logging import subprocess +from six import string_types + from logilab.common import nullobject from logilab.common.configuration import Configuration, merge_options from logilab.common.shellutils import ASK, generate_password @@ -1020,7 +1022,7 @@ for p in ('read', 'add', 'update', 'delete'): rule = perms.get(p) if rule: - perms[p] = tuple(str(x) if isinstance(x, basestring) else x + perms[p] = tuple(str(x) if isinstance(x, string_types) else x for x in rule) return perms, perms in defaultrelperms or perms in defaulteperms diff -r f4dec0cca9a1 -r 84468b90e9c1 server/sources/ldapfeed.py --- a/server/sources/ldapfeed.py Wed Sep 16 11:23:51 2015 +0200 +++ b/server/sources/ldapfeed.py Mon Sep 14 16:03:07 2015 +0200 @@ -21,6 +21,8 @@ from datetime import datetime +from six import string_types + import ldap from ldap.ldapobject import ReconnectLDAPObject from ldap.filter import filter_format @@ -376,7 +378,7 @@ itemdict[key] = value # we expect memberUid to be a list of user ids, make sure of it member = self.group_rev_attrs['member'] - if isinstance(itemdict.get(member), basestring): + if isinstance(itemdict.get(member), string_types): itemdict[member] = [itemdict[member]] return itemdict diff -r f4dec0cca9a1 -r 84468b90e9c1 server/sources/native.py --- a/server/sources/native.py Wed Sep 16 11:23:51 2015 +0200 +++ b/server/sources/native.py Mon Sep 14 16:03:07 2015 +0200 @@ -38,6 +38,7 @@ import logging import sys +from six import string_types from six.moves import range, cPickle as pickle from logilab.common.decorators import cached, clear_cache @@ -558,7 +559,7 @@ sql, qargs, cbs = self._rql_sqlgen.generate(union, args, varmap) self._cache[cachekey] = sql, qargs, cbs args = self.merge_args(args, qargs) - assert isinstance(sql, basestring), repr(sql) + assert isinstance(sql, string_types), repr(sql) cursor = self.doexec(cnx, sql, args) results = self.process_result(cursor, cnx, cbs) assert dbg_results(results) diff -r f4dec0cca9a1 -r 84468b90e9c1 server/sqlutils.py --- a/server/sqlutils.py Wed Sep 16 11:23:51 2015 +0200 +++ b/server/sqlutils.py Mon Sep 14 16:03:07 2015 +0200 @@ -27,6 +27,7 @@ from os.path import abspath from logging import getLogger +from six import string_types from six.moves import filter from logilab import database as db, common as lgc @@ -70,7 +71,7 @@ else: execute = cursor_or_execute sqlstmts_as_string = False - if isinstance(sqlstmts, basestring): + if isinstance(sqlstmts, string_types): sqlstmts_as_string = True sqlstmts = sqlstmts.split(delimiter) if withpb: diff -r f4dec0cca9a1 -r 84468b90e9c1 server/test/unittest_ldapsource.py --- a/server/test/unittest_ldapsource.py Wed Sep 16 11:23:51 2015 +0200 +++ b/server/test/unittest_ldapsource.py Mon Sep 14 16:03:07 2015 +0200 @@ -26,6 +26,7 @@ import subprocess import tempfile +from six import string_types from six.moves import range from logilab.common.testlib import TestCase, unittest_main, mock_object, Tags @@ -155,7 +156,7 @@ """ modcmd = ['dn: %s'%dn, 'changetype: add'] for key, values in mods.iteritems(): - if isinstance(values, basestring): + if isinstance(values, string_types): values = [values] for value in values: modcmd.append('%s: %s'%(key, value)) @@ -175,7 +176,7 @@ modcmd = ['dn: %s'%dn, 'changetype: modify'] for (kind, key), values in mods.iteritems(): modcmd.append('%s: %s' % (kind, key)) - if isinstance(values, basestring): + if isinstance(values, string_types): values = [values] for value in values: modcmd.append('%s: %s'%(key, value)) diff -r f4dec0cca9a1 -r 84468b90e9c1 test/unittest_rqlrewrite.py --- a/test/unittest_rqlrewrite.py Wed Sep 16 11:23:51 2015 +0200 +++ b/test/unittest_rqlrewrite.py Mon Sep 14 16:03:07 2015 +0200 @@ -16,6 +16,8 @@ # You should have received a copy of the GNU Lesser General Public License along # with CubicWeb. If not, see . +from six import string_types + from logilab.common.testlib import unittest_main, TestCase from logilab.common.testlib import mock_object from yams import BadSchemaDefinition @@ -67,7 +69,7 @@ rewriter = _prepare_rewriter(rqlrewrite.RQLRewriter, kwargs) snippets = [] for v, exprs in sorted(snippets_map.items()): - rqlexprs = [isinstance(snippet, basestring) + rqlexprs = [isinstance(snippet, string_types) and mock_object(snippet_rqlst=parse('Any X WHERE '+snippet).children[0], expression='Any X WHERE '+snippet) or snippet diff -r f4dec0cca9a1 -r 84468b90e9c1 test/unittest_rset.py --- a/test/unittest_rset.py Wed Sep 16 11:23:51 2015 +0200 +++ b/test/unittest_rset.py Mon Sep 14 16:03:07 2015 +0200 @@ -18,6 +18,7 @@ # with CubicWeb. If not, see . """unit tests for module cubicweb.utils""" +from six import string_types from six.moves import cPickle as pickle from six.moves.urllib.parse import urlsplit @@ -552,17 +553,17 @@ def test_str(self): with self.admin_access.web_request() as req: rset = req.execute('(Any X,N WHERE X is CWGroup, X name N)') - self.assertIsInstance(str(rset), basestring) + self.assertIsInstance(str(rset), string_types) self.assertEqual(len(str(rset).splitlines()), 1) def test_repr(self): with self.admin_access.web_request() as req: rset = req.execute('(Any X,N WHERE X is CWGroup, X name N)') - self.assertIsInstance(repr(rset), basestring) + self.assertIsInstance(repr(rset), string_types) self.assertTrue(len(repr(rset).splitlines()) > 1) rset = req.execute('(Any X WHERE X is CWGroup, X name "managers")') - self.assertIsInstance(str(rset), basestring) + self.assertIsInstance(str(rset), string_types) self.assertEqual(len(str(rset).splitlines()), 1) def test_nonregr_symmetric_relation(self): diff -r f4dec0cca9a1 -r 84468b90e9c1 uilib.py --- a/uilib.py Wed Sep 16 11:23:51 2015 +0200 +++ b/uilib.py Mon Sep 14 16:03:07 2015 +0200 @@ -28,6 +28,8 @@ import re from StringIO import StringIO +from six import string_types + from logilab.mtconverter import xml_escape, html_unescape from logilab.common.date import ustrftime from logilab.common.deprecation import deprecated @@ -559,7 +561,7 @@ def __call__(self, function): def newfunc(*args, **kwargs): ret = function(*args, **kwargs) - if isinstance(ret, basestring): + if isinstance(ret, string_types): return ret[:self.maxsize] return ret return newfunc @@ -568,6 +570,6 @@ def htmlescape(function): def newfunc(*args, **kwargs): ret = function(*args, **kwargs) - assert isinstance(ret, basestring) + assert isinstance(ret, string_types) return xml_escape(ret) return newfunc diff -r f4dec0cca9a1 -r 84468b90e9c1 web/facet.py --- a/web/facet.py Wed Sep 16 11:23:51 2015 +0200 +++ b/web/facet.py Mon Sep 14 16:03:07 2015 +0200 @@ -57,6 +57,8 @@ from copy import deepcopy from datetime import datetime, timedelta +from six import string_types + from logilab.mtconverter import xml_escape from logilab.common.graph import has_path from logilab.common.decorators import cached, cachedproperty @@ -754,7 +756,7 @@ # XXX handle rel is None case in RQLPathFacet? if self.restr_attr != 'eid': self.select.set_distinct(True) - if isinstance(value, basestring): + if isinstance(value, string_types): # only one value selected if value: self.select.add_constant_restriction( @@ -1071,7 +1073,7 @@ assert self.path and isinstance(self.path, (list, tuple)), \ 'path should be a list of 3-uples, not %s' % self.path for part in self.path: - if isinstance(part, basestring): + if isinstance(part, string_types): part = part.split() assert len(part) == 3, \ 'path should be a list of 3-uples, not %s' % part @@ -1147,7 +1149,7 @@ varmap = {'X': self.filtered_variable} actual_filter_variable = None for part in self.path: - if isinstance(part, basestring): + if isinstance(part, string_types): part = part.split() subject, rtype, object = part if skiplabel and object == self.label_variable: @@ -1390,7 +1392,7 @@ skiplabel=True, skipattrfilter=True) restrel = None for part in self.path: - if isinstance(part, basestring): + if isinstance(part, string_types): part = part.split() subject, rtype, object = part if object == self.filter_variable: diff -r f4dec0cca9a1 -r 84468b90e9c1 web/formfields.py --- a/web/formfields.py Wed Sep 16 11:23:51 2015 +0200 +++ b/web/formfields.py Mon Sep 14 16:03:07 2015 +0200 @@ -66,6 +66,8 @@ from warnings import warn from datetime import datetime, timedelta +from six import string_types + from logilab.mtconverter import xml_escape from logilab.common import nullobject from logilab.common.date import ustrftime @@ -842,7 +844,7 @@ self.widget.attrs.setdefault('size', self.default_text_input_size) def _ensure_correctly_typed(self, form, value): - if isinstance(value, basestring): + if isinstance(value, string_types): value = value.strip() if not value: return None @@ -924,7 +926,7 @@ return self.format_single_value(req, 1.234) def _ensure_correctly_typed(self, form, value): - if isinstance(value, basestring): + if isinstance(value, string_types): value = value.strip() if not value: return None @@ -956,7 +958,7 @@ return u'20s, 10min, 24h, 4d' def _ensure_correctly_typed(self, form, value): - if isinstance(value, basestring): + if isinstance(value, string_types): value = value.strip() if not value: return None @@ -986,7 +988,7 @@ return self.format_single_value(req, datetime.now()) def _ensure_correctly_typed(self, form, value): - if isinstance(value, basestring): + if isinstance(value, string_types): value = value.strip() if not value: return None diff -r f4dec0cca9a1 -r 84468b90e9c1 web/formwidgets.py --- a/web/formwidgets.py Wed Sep 16 11:23:51 2015 +0200 +++ b/web/formwidgets.py Mon Sep 14 16:03:07 2015 +0200 @@ -99,6 +99,8 @@ from datetime import date from warnings import warn +from six import string_types + from logilab.mtconverter import xml_escape from logilab.common.deprecation import deprecated from logilab.common.date import todatetime @@ -282,7 +284,7 @@ """ posted = form._cw.form val = posted.get(field.input_name(form, self.suffix)) - if isinstance(val, basestring): + if isinstance(val, string_types): val = val.strip() return val @@ -993,12 +995,12 @@ req = form._cw values = {} path = req.form.get(field.input_name(form, 'path')) - if isinstance(path, basestring): + if isinstance(path, string_types): path = path.strip() if path is None: path = u'' fqs = req.form.get(field.input_name(form, 'fqs')) - if isinstance(fqs, basestring): + if isinstance(fqs, string_types): fqs = fqs.strip() or None if fqs: for i, line in enumerate(fqs.split('\n')): diff -r f4dec0cca9a1 -r 84468b90e9c1 web/http_headers.py --- a/web/http_headers.py Wed Sep 16 11:23:51 2015 +0200 +++ b/web/http_headers.py Mon Sep 14 16:03:07 2015 +0200 @@ -7,6 +7,7 @@ import base64 import re +from six import string_types from six.moves.urllib.parse import urlparse @@ -382,7 +383,7 @@ def unique(seq): '''if seq is not a string, check it's a sequence of one element and return it''' - if isinstance(seq, basestring): + if isinstance(seq, string_types): return seq if len(seq) != 1: raise ValueError('single value required, not %s' % seq) @@ -454,10 +455,10 @@ """ if (value in (True, 1) or - isinstance(value, basestring) and value.lower() == 'true'): + isinstance(value, string_types) and value.lower() == 'true'): return 'true' if (value in (False, 0) or - isinstance(value, basestring) and value.lower() == 'false'): + isinstance(value, string_types) and value.lower() == 'false'): return 'false' raise ValueError("Invalid true/false header value: %s" % value) diff -r f4dec0cca9a1 -r 84468b90e9c1 web/request.py --- a/web/request.py Wed Sep 16 11:23:51 2015 +0200 +++ b/web/request.py Mon Sep 14 16:03:07 2015 +0200 @@ -28,6 +28,7 @@ from datetime import date, datetime from warnings import warn +from six import string_types from six.moves import http_client from six.moves.urllib.parse import urlsplit, quote as urlquote from six.moves.http_cookies import SimpleCookie @@ -437,7 +438,7 @@ eids = form['eid'] except KeyError: raise NothingToEdit(self._('no selected entities')) - if isinstance(eids, basestring): + if isinstance(eids, string_types): eids = (eids,) for peid in eids: if withtype: @@ -596,7 +597,7 @@ :param localfile: if True, the default data dir prefix is added to the JS filename """ - if isinstance(jsfiles, basestring): + if isinstance(jsfiles, string_types): jsfiles = (jsfiles,) for jsfile in jsfiles: if localfile: @@ -616,7 +617,7 @@ the css inclusion. cf: http://msdn.microsoft.com/en-us/library/ms537512(VS.85).aspx """ - if isinstance(cssfiles, basestring): + if isinstance(cssfiles, string_types): cssfiles = (cssfiles,) if ieonly: if self.ie_browser(): diff -r f4dec0cca9a1 -r 84468b90e9c1 web/schemaviewer.py --- a/web/schemaviewer.py Wed Sep 16 11:23:51 2015 +0200 +++ b/web/schemaviewer.py Mon Sep 14 16:03:07 2015 +0200 @@ -20,6 +20,8 @@ __docformat__ = "restructuredtext en" _ = unicode +from six import string_types + from logilab.common.ureports import Section, Title, Table, Link, Span, Text from yams.schema2dot import CARD_MAP @@ -226,7 +228,7 @@ elif isinstance(val, (list, tuple)): val = sorted(val) val = ', '.join(str(v) for v in val) - elif val and isinstance(val, basestring): + elif val and isinstance(val, string_types): val = _(val) else: val = str(val) diff -r f4dec0cca9a1 -r 84468b90e9c1 web/views/tableview.py --- a/web/views/tableview.py Wed Sep 16 11:23:51 2015 +0200 +++ b/web/views/tableview.py Mon Sep 14 16:03:07 2015 +0200 @@ -67,6 +67,7 @@ from copy import copy from types import MethodType +from six import string_types from six.moves import range from logilab.mtconverter import xml_escape @@ -286,7 +287,7 @@ attrs = renderer.attributes.copy() if renderer.sortable: sortvalue = renderer.sortvalue(rownum) - if isinstance(sortvalue, basestring): + if isinstance(sortvalue, string_types): sortvalue = sortvalue[:self.sortvalue_limit] if sortvalue is not None: attrs[u'cubicweb:sortvalue'] = js_dumps(sortvalue) diff -r f4dec0cca9a1 -r 84468b90e9c1 web/views/tabs.py --- a/web/views/tabs.py Wed Sep 16 11:23:51 2015 +0200 +++ b/web/views/tabs.py Mon Sep 14 16:03:07 2015 +0200 @@ -20,6 +20,8 @@ __docformat__ = "restructuredtext en" _ = unicode +from six import string_types + from logilab.common.deprecation import class_renamed from logilab.mtconverter import xml_escape @@ -114,7 +116,7 @@ active_tab = uilib.domid(default_tab) viewsvreg = self._cw.vreg['views'] for tab in tabs: - if isinstance(tab, basestring): + if isinstance(tab, string_types): tabid, tabkwargs = tab, {} else: tabid, tabkwargs = tab diff -r f4dec0cca9a1 -r 84468b90e9c1 web/views/uicfg.py --- a/web/views/uicfg.py Wed Sep 16 11:23:51 2015 +0200 +++ b/web/views/uicfg.py Mon Sep 14 16:03:07 2015 +0200 @@ -57,6 +57,8 @@ from warnings import warn +from six import string_types + from cubicweb import neg_role from cubicweb.rtags import (RelationTags, RelationTagsBool, RelationTagsSet, RelationTagsDict, NoTargetRelationTagsDict, @@ -650,7 +652,7 @@ self.tag_relation((sschema, rschema, oschema, role), True) def _tag_etype_attr(self, etype, attr, desttype='*', *args, **kwargs): - if isinstance(attr, basestring): + if isinstance(attr, string_types): attr, role = attr, 'subject' else: attr, role = attr diff -r f4dec0cca9a1 -r 84468b90e9c1 web/views/urlrewrite.py --- a/web/views/urlrewrite.py Wed Sep 16 11:23:51 2015 +0200 +++ b/web/views/urlrewrite.py Mon Sep 14 16:03:07 2015 +0200 @@ -19,6 +19,8 @@ import re +from six import string_types + from cubicweb.uilib import domid from cubicweb.appobject import AppObject @@ -122,14 +124,14 @@ required_groups = None if required_groups and not req.user.matching_groups(required_groups): continue - if isinstance(inputurl, basestring): + if isinstance(inputurl, string_types): if inputurl == uri: req.form.update(infos) break elif inputurl.match(uri): # it's a regexp # XXX what about i18n? (vtitle for instance) for param, value in infos.items(): - if isinstance(value, basestring): + if isinstance(value, string_types): req.form[param] = inputurl.sub(value, uri) else: req.form[param] = value @@ -222,7 +224,7 @@ required_groups = None if required_groups and not req.user.matching_groups(required_groups): continue - if isinstance(inputurl, basestring): + if isinstance(inputurl, string_types): if inputurl == uri: return callback(inputurl, uri, req, self._cw.vreg.schema) elif inputurl.match(uri): # it's a regexp