# HG changeset patch # User Daniel Dourvaris # Date 2019-01-22 22:06:49 # Node ID d577b7786d035f6a8be38f5c253e68890de90998 # Parent c7ed0ba510680d32dc56e09a3cb9a5560bd8a0f2 py3: remove usage of basestring diff --git a/rhodecode/api/views/user_api.py b/rhodecode/api/views/user_api.py --- a/rhodecode/api/views/user_api.py +++ b/rhodecode/api/views/user_api.py @@ -19,6 +19,7 @@ # and proprietary license terms, please see https://rhodecode.com/licenses/ import logging +from pyramid import compat from rhodecode.api import ( jsonrpc_method, JSONRPCError, JSONRPCForbidden, JSONRPCValidationError) @@ -241,7 +242,7 @@ def create_user(request, apiuser, userna # generate temporary password if user is external password = PasswordGenerator().gen_password(length=16) create_repo_group = Optional.extract(create_personal_repo_group) - if isinstance(create_repo_group, basestring): + if isinstance(create_repo_group, compat.string_types): create_repo_group = str2bool(create_repo_group) username = Optional.extract(username) diff --git a/rhodecode/apps/_base/__init__.py b/rhodecode/apps/_base/__init__.py --- a/rhodecode/apps/_base/__init__.py +++ b/rhodecode/apps/_base/__init__.py @@ -22,6 +22,7 @@ import time import logging import operator +from pyramid import compat from pyramid.httpexceptions import HTTPFound, HTTPForbidden, HTTPBadRequest from rhodecode.lib import helpers as h, diffs @@ -395,7 +396,7 @@ class DataGridAppView(object): return draw, start, length def _get_order_col(self, order_by, model): - if isinstance(order_by, basestring): + if isinstance(order_by, compat.string_types): try: return operator.attrgetter(order_by)(model) except AttributeError: diff --git a/rhodecode/apps/svn_support/__init__.py b/rhodecode/apps/svn_support/__init__.py --- a/rhodecode/apps/svn_support/__init__.py +++ b/rhodecode/apps/svn_support/__init__.py @@ -17,10 +17,10 @@ # This program is dual-licensed. If you wish to learn more about the # RhodeCode Enterprise Edition, including its added features, Support services, # and proprietary license terms, please see https://rhodecode.com/licenses/ - +import os import logging -import os import shlex +from pyramid import compat # Do not use `from rhodecode import events` here, it will be overridden by the # events module in this package due to pythons import mechanism. @@ -85,6 +85,6 @@ def _append_path_sep(path): """ Append the path separator if missing. """ - if isinstance(path, basestring) and not path.endswith(os.path.sep): + if isinstance(path, compat.string_types) and not path.endswith(os.path.sep): path += os.path.sep return path diff --git a/rhodecode/lib/celerylib/tasks.py b/rhodecode/lib/celerylib/tasks.py --- a/rhodecode/lib/celerylib/tasks.py +++ b/rhodecode/lib/celerylib/tasks.py @@ -26,6 +26,7 @@ by celery daemon import os import time +from pyramid import compat from pyramid_mailer.mailer import Mailer from pyramid_mailer.message import Message @@ -62,7 +63,7 @@ def send_email(recipients, subject, body subject = "%s %s" % (email_config.get('email_prefix', ''), subject) if recipients: - if isinstance(recipients, basestring): + if isinstance(recipients, compat.string_types): recipients = recipients.split(',') else: # if recipients are not defined we send to email_config + all admins diff --git a/rhodecode/lib/codeblocks.py b/rhodecode/lib/codeblocks.py --- a/rhodecode/lib/codeblocks.py +++ b/rhodecode/lib/codeblocks.py @@ -26,6 +26,7 @@ from pygments import lex from pygments.formatters.html import _get_ttype_class as pygment_token_class from pygments.lexers.special import TextLexer, Token from pygments.lexers import get_lexer_by_name +from pyramid import compat from rhodecode.lib.helpers import ( get_lexer_for_filenode, html_escape, get_custom_lexer) @@ -695,7 +696,7 @@ class DiffSet(object): filenode = None filename = None - if isinstance(input_file, basestring): + if isinstance(input_file, compat.string_types): filename = input_file elif isinstance(input_file, FileNode): filenode = input_file diff --git a/rhodecode/lib/colander_utils.py b/rhodecode/lib/colander_utils.py --- a/rhodecode/lib/colander_utils.py +++ b/rhodecode/lib/colander_utils.py @@ -18,13 +18,15 @@ # RhodeCode Enterprise Edition, including its added features, Support services, # and proprietary license terms, please see https://rhodecode.com/licenses/ +from pyramid import compat + def strip_whitespace(value): """ Removes leading/trailing whitespace, newlines, and tabs from the value. Implements the `colander.interface.Preparer` interface. """ - if isinstance(value, basestring): + if isinstance(value, compat.string_types): return value.strip(' \t\n\r') else: return value diff --git a/rhodecode/lib/dbmigrate/migrate/changeset/schema.py b/rhodecode/lib/dbmigrate/migrate/changeset/schema.py --- a/rhodecode/lib/dbmigrate/migrate/changeset/schema.py +++ b/rhodecode/lib/dbmigrate/migrate/changeset/schema.py @@ -9,6 +9,7 @@ import sqlalchemy from sqlalchemy.schema import ForeignKeyConstraint from sqlalchemy.schema import UniqueConstraint +from pyramid import compat from rhodecode.lib.dbmigrate.migrate.exceptions import * from rhodecode.lib.dbmigrate.migrate.changeset import SQLA_07, SQLA_08 @@ -229,7 +230,7 @@ class ColumnDelta(DictMixin, sqlalchemy. diffs = self.compare_1_column(*p, **kw) else: # Zero columns specified - if not len(p) or not isinstance(p[0], basestring): + if not len(p) or not isinstance(p[0], compat.string_types): raise ValueError("First argument must be column name") diffs = self.compare_parameters(*p, **kw) @@ -338,7 +339,7 @@ class ColumnDelta(DictMixin, sqlalchemy. """Extracts data from p and modifies diffs""" p = list(p) while len(p): - if isinstance(p[0], basestring): + if isinstance(p[0], compat.string_types): k.setdefault('name', p.pop(0)) elif isinstance(p[0], sqlalchemy.types.TypeEngine): k.setdefault('type', p.pop(0)) @@ -376,7 +377,7 @@ class ColumnDelta(DictMixin, sqlalchemy. return getattr(self, '_table', None) def _set_table(self, table): - if isinstance(table, basestring): + if isinstance(table, compat.string_types): if self.alter_metadata: if not self.meta: raise ValueError("metadata must be specified for table" @@ -593,7 +594,7 @@ populated with defaults if isinstance(cons,(ForeignKeyConstraint, UniqueConstraint)): for col_name in cons.columns: - if not isinstance(col_name,basestring): + if not isinstance(col_name, compat.string_types): col_name = col_name.name if self.name==col_name: to_drop.add(cons) @@ -628,7 +629,7 @@ populated with defaults if (getattr(self, name[:-5]) and not obj): raise InvalidConstraintError("Column.create() accepts index_name," " primary_key_name and unique_name to generate constraints") - if not isinstance(obj, basestring) and obj is not None: + if not isinstance(obj, compat.string_types) and obj is not None: raise InvalidConstraintError( "%s argument for column must be constraint name" % name) diff --git a/rhodecode/lib/dbmigrate/migrate/versioning/schema.py b/rhodecode/lib/dbmigrate/migrate/versioning/schema.py --- a/rhodecode/lib/dbmigrate/migrate/versioning/schema.py +++ b/rhodecode/lib/dbmigrate/migrate/versioning/schema.py @@ -9,6 +9,7 @@ from sqlalchemy import (Table, Column, M from sqlalchemy.sql import and_ from sqlalchemy import exc as sa_exceptions from sqlalchemy.sql import bindparam +from pyramid import compat from rhodecode.lib.dbmigrate.migrate import exceptions from rhodecode.lib.dbmigrate.migrate.changeset import SQLA_07 @@ -25,7 +26,7 @@ class ControlledSchema(object): """A database under version control""" def __init__(self, engine, repository): - if isinstance(repository, basestring): + if isinstance(repository, compat.string_types): repository = Repository(repository) self.engine = engine self.repository = repository @@ -134,7 +135,7 @@ class ControlledSchema(object): """ # Confirm that the version # is valid: positive, integer, # exists in repos - if isinstance(repository, basestring): + if isinstance(repository, compat.string_types): repository = Repository(repository) version = cls._validate_version(repository, version) table = cls._create_table_version(engine, repository, version) @@ -199,7 +200,7 @@ class ControlledSchema(object): """ Compare the current model against the current database. """ - if isinstance(repository, basestring): + if isinstance(repository, compat.string_types): repository = Repository(repository) model = load_model(model) @@ -212,7 +213,7 @@ class ControlledSchema(object): """ Dump the current database as a Python model. """ - if isinstance(repository, basestring): + if isinstance(repository, compat.string_types): repository = Repository(repository) diff = schemadiff.getDiffOfModelAgainstDatabase( diff --git a/rhodecode/lib/dbmigrate/migrate/versioning/script/py.py b/rhodecode/lib/dbmigrate/migrate/versioning/script/py.py --- a/rhodecode/lib/dbmigrate/migrate/versioning/script/py.py +++ b/rhodecode/lib/dbmigrate/migrate/versioning/script/py.py @@ -7,6 +7,7 @@ import logging import inspect from StringIO import StringIO +from pyramid import compat from rhodecode.lib.dbmigrate import migrate from rhodecode.lib.dbmigrate.migrate.versioning import genmodel, schemadiff from rhodecode.lib.dbmigrate.migrate.versioning.config import operations @@ -51,7 +52,7 @@ class PythonScript(base.BaseScript): :rtype: string """ - if isinstance(repository, basestring): + if isinstance(repository, compat.string_types): # oh dear, an import cycle! from rhodecode.lib.dbmigrate.migrate.versioning.repository import Repository repository = Repository(repository) diff --git a/rhodecode/lib/dbmigrate/migrate/versioning/util/__init__.py b/rhodecode/lib/dbmigrate/migrate/versioning/util/__init__.py --- a/rhodecode/lib/dbmigrate/migrate/versioning/util/__init__.py +++ b/rhodecode/lib/dbmigrate/migrate/versioning/util/__init__.py @@ -11,6 +11,7 @@ from sqlalchemy import create_engine from sqlalchemy.engine import Engine from sqlalchemy.pool import StaticPool +from pyramid import compat from rhodecode.lib.dbmigrate.migrate import exceptions from rhodecode.lib.dbmigrate.migrate.versioning.util.keyedinstance import KeyedInstance from rhodecode.lib.dbmigrate.migrate.versioning.util.importpath import import_path @@ -18,6 +19,7 @@ from rhodecode.lib.dbmigrate.migrate.ver log = logging.getLogger(__name__) + def load_model(dotted_name): """Import module and use module-level variable". @@ -26,7 +28,7 @@ def load_model(dotted_name): .. versionchanged:: 0.5.4 """ - if isinstance(dotted_name, basestring): + if isinstance(dotted_name, compat.string_types): if ':' not in dotted_name: # backwards compatibility warnings.warn('model should be in form of module.model:User ' @@ -39,7 +41,7 @@ def load_model(dotted_name): def asbool(obj): """Do everything to use object as bool""" - if isinstance(obj, basestring): + if isinstance(obj, compat.string_types): obj = obj.strip().lower() if obj in ['true', 'yes', 'on', 'y', 't', '1']: return True @@ -112,7 +114,7 @@ def construct_engine(engine, **opts): """ if isinstance(engine, Engine): return engine - elif not isinstance(engine, basestring): + elif not isinstance(engine, compat.string_types): raise ValueError("you need to pass either an existing engine or a database uri") # get options for create_engine diff --git a/rhodecode/lib/dbmigrate/schema/db_1_2_0.py b/rhodecode/lib/dbmigrate/schema/db_1_2_0.py --- a/rhodecode/lib/dbmigrate/schema/db_1_2_0.py +++ b/rhodecode/lib/dbmigrate/schema/db_1_2_0.py @@ -28,6 +28,7 @@ from sqlalchemy import * from sqlalchemy.ext.hybrid import hybrid_property from sqlalchemy.orm import relationship, joinedload, class_mapper, validates from beaker.cache import cache_region, region_invalidate +from pyramid import compat from rhodecode.lib.vcs import get_backend from rhodecode.lib.vcs.utils.helpers import get_scm @@ -413,7 +414,7 @@ class UserGroup(Base, BaseModel): Session.flush() members_list = [] if v: - v = [v] if isinstance(v, basestring) else v + v = [v] if isinstance(v, compat.string_types) else v for u_id in set(v): member = UserGroupMember(users_group_id, u_id) members_list.append(member) diff --git a/rhodecode/lib/dbmigrate/schema/db_4_11_0_0.py b/rhodecode/lib/dbmigrate/schema/db_4_11_0_0.py --- a/rhodecode/lib/dbmigrate/schema/db_4_11_0_0.py +++ b/rhodecode/lib/dbmigrate/schema/db_4_11_0_0.py @@ -49,7 +49,7 @@ from sqlalchemy.exc import IntegrityErro from sqlalchemy.dialects.mysql import LONGTEXT from beaker.cache import cache_region from zope.cachedescriptors.property import Lazy as LazyProperty - +from pyramid import compat from pyramid.threadlocal import get_current_request from rhodecode.translation import _ @@ -2110,7 +2110,7 @@ class Repository(Base, BaseModel): warnings.warn("Use get_commit", DeprecationWarning) commit_id = None commit_idx = None - if isinstance(rev, basestring): + if isinstance(rev, compat.string_types): commit_id = rev else: commit_idx = rev @@ -3726,7 +3726,7 @@ class PullRequestReviewers(Base, BaseMod @reasons.setter def reasons(self, val): val = val or [] - if any(not isinstance(x, basestring) for x in val): + if any(not isinstance(x, compat.string_types) for x in val): raise Exception('invalid reasons type, must be list of strings') self._reasons = val diff --git a/rhodecode/lib/dbmigrate/schema/db_4_13_0_0.py b/rhodecode/lib/dbmigrate/schema/db_4_13_0_0.py --- a/rhodecode/lib/dbmigrate/schema/db_4_13_0_0.py +++ b/rhodecode/lib/dbmigrate/schema/db_4_13_0_0.py @@ -49,7 +49,7 @@ from sqlalchemy.exc import IntegrityErro from sqlalchemy.dialects.mysql import LONGTEXT from beaker.cache import cache_region from zope.cachedescriptors.property import Lazy as LazyProperty - +from pyramid import compat from pyramid.threadlocal import get_current_request from rhodecode.translation import _ @@ -2176,7 +2176,7 @@ class Repository(Base, BaseModel): warnings.warn("Use get_commit", DeprecationWarning) commit_id = None commit_idx = None - if isinstance(rev, basestring): + if isinstance(rev, compat.string_types): commit_id = rev else: commit_idx = rev @@ -3809,7 +3809,7 @@ class PullRequestReviewers(Base, BaseMod @reasons.setter def reasons(self, val): val = val or [] - if any(not isinstance(x, basestring) for x in val): + if any(not isinstance(x, compat.string_types) for x in val): raise Exception('invalid reasons type, must be list of strings') self._reasons = val diff --git a/rhodecode/lib/dbmigrate/schema/db_4_16_0_0.py b/rhodecode/lib/dbmigrate/schema/db_4_16_0_0.py --- a/rhodecode/lib/dbmigrate/schema/db_4_16_0_0.py +++ b/rhodecode/lib/dbmigrate/schema/db_4_16_0_0.py @@ -48,7 +48,7 @@ from sqlalchemy.ext.hybrid import hybrid from sqlalchemy.exc import IntegrityError # pragma: no cover from sqlalchemy.dialects.mysql import LONGTEXT from zope.cachedescriptors.property import Lazy as LazyProperty - +from pyramid import compat from pyramid.threadlocal import get_current_request from rhodecode.translation import _ @@ -2217,7 +2217,7 @@ class Repository(Base, BaseModel): warnings.warn("Use get_commit", DeprecationWarning) commit_id = None commit_idx = None - if isinstance(rev, basestring): + if isinstance(rev, compat.string_types): commit_id = rev else: commit_idx = rev @@ -3957,7 +3957,7 @@ class PullRequestReviewers(Base, BaseMod @reasons.setter def reasons(self, val): val = val or [] - if any(not isinstance(x, basestring) for x in val): + if any(not isinstance(x, compat.string_types) for x in val): raise Exception('invalid reasons type, must be list of strings') self._reasons = val diff --git a/rhodecode/lib/dbmigrate/schema/db_4_16_0_1.py b/rhodecode/lib/dbmigrate/schema/db_4_16_0_1.py --- a/rhodecode/lib/dbmigrate/schema/db_4_16_0_1.py +++ b/rhodecode/lib/dbmigrate/schema/db_4_16_0_1.py @@ -48,7 +48,7 @@ from sqlalchemy.ext.hybrid import hybrid from sqlalchemy.exc import IntegrityError # pragma: no cover from sqlalchemy.dialects.mysql import LONGTEXT from zope.cachedescriptors.property import Lazy as LazyProperty - +from pyramid import compat from pyramid.threadlocal import get_current_request from rhodecode.translation import _ @@ -2240,7 +2240,7 @@ class Repository(Base, BaseModel): warnings.warn("Use get_commit", DeprecationWarning) commit_id = None commit_idx = None - if isinstance(rev, basestring): + if isinstance(rev, compat.string_types): commit_id = rev else: commit_idx = rev @@ -4031,7 +4031,7 @@ class PullRequestReviewers(Base, BaseMod @reasons.setter def reasons(self, val): val = val or [] - if any(not isinstance(x, basestring) for x in val): + if any(not isinstance(x, compat.string_types) for x in val): raise Exception('invalid reasons type, must be list of strings') self._reasons = val diff --git a/rhodecode/lib/dbmigrate/schema/db_4_3_0_0.py b/rhodecode/lib/dbmigrate/schema/db_4_3_0_0.py --- a/rhodecode/lib/dbmigrate/schema/db_4_3_0_0.py +++ b/rhodecode/lib/dbmigrate/schema/db_4_3_0_0.py @@ -34,7 +34,6 @@ import functools import traceback import collections - from sqlalchemy import * from sqlalchemy.exc import IntegrityError from sqlalchemy.ext.declarative import declared_attr @@ -45,6 +44,7 @@ from sqlalchemy.sql.expression import tr from beaker.cache import cache_region, region_invalidate from webob.exc import HTTPNotFound from zope.cachedescriptors.property import Lazy as LazyProperty +from pyramid import compat # replace pylons with fake url for migration from rhodecode.lib.dbmigrate.schema import url @@ -1811,7 +1811,7 @@ class Repository(Base, BaseModel): warnings.warn("Use get_commit", DeprecationWarning) commit_id = None commit_idx = None - if isinstance(rev, basestring): + if isinstance(rev, compat.string_types): commit_id = rev else: commit_idx = rev diff --git a/rhodecode/lib/dbmigrate/schema/db_4_4_0_0.py b/rhodecode/lib/dbmigrate/schema/db_4_4_0_0.py --- a/rhodecode/lib/dbmigrate/schema/db_4_4_0_0.py +++ b/rhodecode/lib/dbmigrate/schema/db_4_4_0_0.py @@ -34,7 +34,6 @@ import functools import traceback import collections - from sqlalchemy import * from sqlalchemy.exc import IntegrityError from sqlalchemy.ext.declarative import declared_attr @@ -45,6 +44,7 @@ from sqlalchemy.sql.expression import tr from beaker.cache import cache_region, region_invalidate from webob.exc import HTTPNotFound from zope.cachedescriptors.property import Lazy as LazyProperty +from pyramid import compat # replace pylons with fake url for migration from rhodecode.lib.dbmigrate.schema import url @@ -1814,7 +1814,7 @@ class Repository(Base, BaseModel): warnings.warn("Use get_commit", DeprecationWarning) commit_id = None commit_idx = None - if isinstance(rev, basestring): + if isinstance(rev, compat.string_types): commit_id = rev else: commit_idx = rev diff --git a/rhodecode/lib/dbmigrate/schema/db_4_4_0_1.py b/rhodecode/lib/dbmigrate/schema/db_4_4_0_1.py --- a/rhodecode/lib/dbmigrate/schema/db_4_4_0_1.py +++ b/rhodecode/lib/dbmigrate/schema/db_4_4_0_1.py @@ -34,7 +34,6 @@ import functools import traceback import collections - from sqlalchemy import * from sqlalchemy.exc import IntegrityError from sqlalchemy.ext.declarative import declared_attr @@ -45,7 +44,7 @@ from sqlalchemy.sql.expression import tr from beaker.cache import cache_region, region_invalidate from webob.exc import HTTPNotFound from zope.cachedescriptors.property import Lazy as LazyProperty - +from pyramid import compat # replace pylons with fake url for migration from rhodecode.lib.dbmigrate.schema import url from rhodecode.translation import _ @@ -1814,7 +1813,7 @@ class Repository(Base, BaseModel): warnings.warn("Use get_commit", DeprecationWarning) commit_id = None commit_idx = None - if isinstance(rev, basestring): + if isinstance(rev, compat.string_types): commit_id = rev else: commit_idx = rev diff --git a/rhodecode/lib/dbmigrate/schema/db_4_4_0_2.py b/rhodecode/lib/dbmigrate/schema/db_4_4_0_2.py --- a/rhodecode/lib/dbmigrate/schema/db_4_4_0_2.py +++ b/rhodecode/lib/dbmigrate/schema/db_4_4_0_2.py @@ -35,7 +35,6 @@ import functools import traceback import collections - from sqlalchemy import * from sqlalchemy.exc import IntegrityError from sqlalchemy.ext.declarative import declared_attr @@ -46,7 +45,7 @@ from sqlalchemy.sql.expression import tr from beaker.cache import cache_region, region_invalidate from webob.exc import HTTPNotFound from zope.cachedescriptors.property import Lazy as LazyProperty - +from pyramid import compat # replace pylons with fake url for migration from rhodecode.lib.dbmigrate.schema import url from rhodecode.translation import _ @@ -1816,7 +1815,7 @@ class Repository(Base, BaseModel): warnings.warn("Use get_commit", DeprecationWarning) commit_id = None commit_idx = None - if isinstance(rev, basestring): + if isinstance(rev, compat.string_types): commit_id = rev else: commit_idx = rev diff --git a/rhodecode/lib/dbmigrate/schema/db_4_5_0_0.py b/rhodecode/lib/dbmigrate/schema/db_4_5_0_0.py --- a/rhodecode/lib/dbmigrate/schema/db_4_5_0_0.py +++ b/rhodecode/lib/dbmigrate/schema/db_4_5_0_0.py @@ -35,7 +35,6 @@ import functools import traceback import collections - from sqlalchemy import * from sqlalchemy.exc import IntegrityError from sqlalchemy.ext.declarative import declared_attr @@ -46,7 +45,7 @@ from sqlalchemy.sql.expression import tr from beaker.cache import cache_region, region_invalidate from webob.exc import HTTPNotFound from zope.cachedescriptors.property import Lazy as LazyProperty - +from pyramid import compat # replace pylons with fake url for migration from rhodecode.lib.dbmigrate.schema import url from rhodecode.translation import _ @@ -1816,7 +1815,7 @@ class Repository(Base, BaseModel): warnings.warn("Use get_commit", DeprecationWarning) commit_id = None commit_idx = None - if isinstance(rev, basestring): + if isinstance(rev, compat.string_types): commit_id = rev else: commit_idx = rev @@ -3180,7 +3179,7 @@ class PullRequestReviewers(Base, BaseMod @reasons.setter def reasons(self, val): val = val or [] - if any(not isinstance(x, basestring) for x in val): + if any(not isinstance(x, compat.string_types) for x in val): raise Exception('invalid reasons type, must be list of strings') self._reasons = val diff --git a/rhodecode/lib/dbmigrate/schema/db_4_7_0_0.py b/rhodecode/lib/dbmigrate/schema/db_4_7_0_0.py --- a/rhodecode/lib/dbmigrate/schema/db_4_7_0_0.py +++ b/rhodecode/lib/dbmigrate/schema/db_4_7_0_0.py @@ -34,7 +34,6 @@ import functools import traceback import collections - from sqlalchemy import * from sqlalchemy.ext.declarative import declared_attr from sqlalchemy.ext.hybrid import hybrid_property @@ -44,6 +43,7 @@ from sqlalchemy.sql.expression import tr from beaker.cache import cache_region from webob.exc import HTTPNotFound from zope.cachedescriptors.property import Lazy as LazyProperty +from pyramid import compat # replace pylons with fake url for migration from rhodecode.lib.dbmigrate.schema import url @@ -1858,7 +1858,7 @@ class Repository(Base, BaseModel): warnings.warn("Use get_commit", DeprecationWarning) commit_id = None commit_idx = None - if isinstance(rev, basestring): + if isinstance(rev, compat.string_types): commit_id = rev else: commit_idx = rev @@ -3407,7 +3407,7 @@ class PullRequestReviewers(Base, BaseMod @reasons.setter def reasons(self, val): val = val or [] - if any(not isinstance(x, basestring) for x in val): + if any(not isinstance(x, compat.string_types) for x in val): raise Exception('invalid reasons type, must be list of strings') self._reasons = val diff --git a/rhodecode/lib/dbmigrate/schema/db_4_7_0_1.py b/rhodecode/lib/dbmigrate/schema/db_4_7_0_1.py --- a/rhodecode/lib/dbmigrate/schema/db_4_7_0_1.py +++ b/rhodecode/lib/dbmigrate/schema/db_4_7_0_1.py @@ -34,7 +34,6 @@ import functools import traceback import collections - from sqlalchemy import * from sqlalchemy.ext.declarative import declared_attr from sqlalchemy.ext.hybrid import hybrid_property @@ -44,6 +43,7 @@ from sqlalchemy.sql.expression import tr from beaker.cache import cache_region from webob.exc import HTTPNotFound from zope.cachedescriptors.property import Lazy as LazyProperty +from pyramid import compat # replace pylons with fake url for migration from rhodecode.lib.dbmigrate.schema import url @@ -1859,7 +1859,7 @@ class Repository(Base, BaseModel): warnings.warn("Use get_commit", DeprecationWarning) commit_id = None commit_idx = None - if isinstance(rev, basestring): + if isinstance(rev, compat.string_types): commit_id = rev else: commit_idx = rev @@ -3408,7 +3408,7 @@ class PullRequestReviewers(Base, BaseMod @reasons.setter def reasons(self, val): val = val or [] - if any(not isinstance(x, basestring) for x in val): + if any(not isinstance(x, compat.string_types) for x in val): raise Exception('invalid reasons type, must be list of strings') self._reasons = val diff --git a/rhodecode/lib/dbmigrate/schema/db_4_9_0_0.py b/rhodecode/lib/dbmigrate/schema/db_4_9_0_0.py --- a/rhodecode/lib/dbmigrate/schema/db_4_9_0_0.py +++ b/rhodecode/lib/dbmigrate/schema/db_4_9_0_0.py @@ -34,7 +34,6 @@ import functools import traceback import collections - from sqlalchemy import * from sqlalchemy.ext.declarative import declared_attr from sqlalchemy.ext.hybrid import hybrid_property @@ -44,7 +43,7 @@ from sqlalchemy.sql.expression import tr from sqlalchemy.sql.functions import coalesce, count # pragma: no cover from beaker.cache import cache_region from zope.cachedescriptors.property import Lazy as LazyProperty - +from pyramid import compat from pyramid.threadlocal import get_current_request from rhodecode.translation import _ @@ -2047,7 +2046,7 @@ class Repository(Base, BaseModel): warnings.warn("Use get_commit", DeprecationWarning) commit_id = None commit_idx = None - if isinstance(rev, basestring): + if isinstance(rev, compat.string_types): commit_id = rev else: commit_idx = rev @@ -3662,7 +3661,7 @@ class PullRequestReviewers(Base, BaseMod @reasons.setter def reasons(self, val): val = val or [] - if any(not isinstance(x, basestring) for x in val): + if any(not isinstance(x, compat.string_types) for x in val): raise Exception('invalid reasons type, must be list of strings') self._reasons = val diff --git a/rhodecode/lib/dbmigrate/versions/070_version_4_7_0.py b/rhodecode/lib/dbmigrate/versions/070_version_4_7_0.py --- a/rhodecode/lib/dbmigrate/versions/070_version_4_7_0.py +++ b/rhodecode/lib/dbmigrate/versions/070_version_4_7_0.py @@ -2,6 +2,7 @@ import logging import datetime from sqlalchemy import * +from pyramid import compat from rhodecode.lib.utils2 import safe_str from rhodecode.model import meta @@ -12,7 +13,7 @@ log = logging.getLogger(__name__) def time_to_datetime(tm): if tm: - if isinstance(tm, basestring): + if isinstance(tm, compat.string_types): try: tm = float(tm) except ValueError: diff --git a/rhodecode/lib/diff_match_patch.py b/rhodecode/lib/diff_match_patch.py --- a/rhodecode/lib/diff_match_patch.py +++ b/rhodecode/lib/diff_match_patch.py @@ -1,4 +1,3 @@ -#!/usr/bin/python2.4 from __future__ import division @@ -33,6 +32,8 @@ import re import sys import time import urllib +from pyramid import compat + class diff_match_patch: """Class containing the diff, match and patch methods. @@ -1438,7 +1439,7 @@ class diff_match_patch: text1 = None diffs = None # Note that texts may arrive as 'str' or 'unicode'. - if isinstance(a, basestring) and isinstance(b, basestring) and c is None: + if isinstance(a, compat.string_types) and isinstance(b, compat.string_types) and c is None: # Method 1: text1, text2 # Compute diffs from text1 and text2. text1 = a @@ -1451,11 +1452,11 @@ class diff_match_patch: # Compute text1 from diffs. diffs = a text1 = self.diff_text1(diffs) - elif isinstance(a, basestring) and isinstance(b, list) and c is None: + elif isinstance(a, compat.string_types) and isinstance(b, list) and c is None: # Method 3: text1, diffs text1 = a diffs = b - elif (isinstance(a, basestring) and isinstance(b, basestring) and + elif (isinstance(a, compat.string_types) and isinstance(b, compat.string_types) and isinstance(c, list)): # Method 4: text1, text2, diffs # text2 is not used. diff --git a/rhodecode/lib/helpers.py b/rhodecode/lib/helpers.py --- a/rhodecode/lib/helpers.py +++ b/rhodecode/lib/helpers.py @@ -34,7 +34,6 @@ import urllib import math import logging import re -import urlparse import time import string import hashlib @@ -45,6 +44,7 @@ import itertools import fnmatch import bleach +from pyramid import compat from datetime import datetime from functools import partial from pygments.formatters.html import HtmlFormatter diff --git a/rhodecode/lib/rc_cache/utils.py b/rhodecode/lib/rc_cache/utils.py --- a/rhodecode/lib/rc_cache/utils.py +++ b/rhodecode/lib/rc_cache/utils.py @@ -120,7 +120,7 @@ def get_default_cache_settings(settings, if key.startswith(prefix): name = key.split(prefix)[1].strip() val = settings[key] - if isinstance(val, basestring): + if isinstance(val, compat.string_types): val = val.strip() cache_settings[name] = val return cache_settings diff --git a/rhodecode/lib/utils2.py b/rhodecode/lib/utils2.py --- a/rhodecode/lib/utils2.py +++ b/rhodecode/lib/utils2.py @@ -43,6 +43,7 @@ import sqlalchemy.exc import sqlalchemy.sql import webob import pyramid.threadlocal +from pyramid import compat from pyramid.settings import asbool import rhodecode @@ -261,7 +262,7 @@ def safe_str(unicode_, to_encoding=None) """ # if it's not basestr cast to str - if not isinstance(unicode_, basestring): + if not isinstance(unicode_, compat.string_types): return str(unicode_) if isinstance(unicode_, str): @@ -687,7 +688,7 @@ def datetime_to_time(dt): def time_to_datetime(tm): if tm: - if isinstance(tm, basestring): + if isinstance(tm, compat.string_types): try: tm = float(tm) except ValueError: @@ -697,7 +698,7 @@ def time_to_datetime(tm): def time_to_utcdatetime(tm): if tm: - if isinstance(tm, basestring): + if isinstance(tm, compat.string_types): try: tm = float(tm) except ValueError: diff --git a/rhodecode/lib/vcs/backends/base.py b/rhodecode/lib/vcs/backends/base.py --- a/rhodecode/lib/vcs/backends/base.py +++ b/rhodecode/lib/vcs/backends/base.py @@ -33,6 +33,7 @@ import collections import warnings from zope.cachedescriptors.property import Lazy as LazyProperty +from pyramid import compat from rhodecode.translation import lazy_ugettext from rhodecode.lib.utils2 import safe_str, safe_unicode @@ -692,7 +693,7 @@ class BaseRepository(object): (commit, self, commit.repository)) def _validate_commit_id(self, commit_id): - if not isinstance(commit_id, basestring): + if not isinstance(commit_id, compat.string_types): raise TypeError("commit_id must be a string value") def _validate_commit_idx(self, commit_idx): @@ -729,7 +730,7 @@ class BaseRepository(object): warnings.warn("Use get_commit instead", DeprecationWarning) commit_id = None commit_idx = None - if isinstance(revision, basestring): + if isinstance(revision, compat.string_types): commit_id = revision else: commit_idx = revision @@ -756,7 +757,7 @@ class BaseRepository(object): if revision is None: return revision - if isinstance(revision, basestring): + if isinstance(revision, compat.string_types): commit_id = revision else: commit_id = self.commit_ids[revision] diff --git a/rhodecode/lib/vcs/exceptions.py b/rhodecode/lib/vcs/exceptions.py --- a/rhodecode/lib/vcs/exceptions.py +++ b/rhodecode/lib/vcs/exceptions.py @@ -25,6 +25,7 @@ import logging import functools import urllib2 import rhodecode +from pyramid import compat log = logging.getLogger(__name__) @@ -191,7 +192,7 @@ def map_vcs_exceptions(func): org_remote_tb = getattr(e, '_vcs_server_org_exc_tb', '') __traceback_info__ = None if remote_tb: - if isinstance(remote_tb, basestring): + if isinstance(remote_tb, compat.string_types): remote_tb = [remote_tb] __traceback_info__ = ( 'Found VCSServer remote traceback information:\n' diff --git a/rhodecode/model/db.py b/rhodecode/model/db.py --- a/rhodecode/model/db.py +++ b/rhodecode/model/db.py @@ -48,7 +48,7 @@ from sqlalchemy.ext.hybrid import hybrid from sqlalchemy.exc import IntegrityError # pragma: no cover from sqlalchemy.dialects.mysql import LONGTEXT from zope.cachedescriptors.property import Lazy as LazyProperty - +from pyramid import compat from pyramid.threadlocal import get_current_request from rhodecode.translation import _ @@ -2240,7 +2240,7 @@ class Repository(Base, BaseModel): warnings.warn("Use get_commit", DeprecationWarning) commit_id = None commit_idx = None - if isinstance(rev, basestring): + if isinstance(rev, compat.string_types): commit_id = rev else: commit_idx = rev @@ -4031,7 +4031,7 @@ class PullRequestReviewers(Base, BaseMod @reasons.setter def reasons(self, val): val = val or [] - if any(not isinstance(x, basestring) for x in val): + if any(not isinstance(x, compat.string_types) for x in val): raise Exception('invalid reasons type, must be list of strings') self._reasons = val diff --git a/rhodecode/model/pull_request.py b/rhodecode/model/pull_request.py --- a/rhodecode/model/pull_request.py +++ b/rhodecode/model/pull_request.py @@ -30,6 +30,7 @@ import datetime import urllib import collections +from pyramid import compat from pyramid.threadlocal import get_current_request from rhodecode import events @@ -1001,7 +1002,7 @@ class PullRequestModel(BaseModel): reviewers = {} for user_id, reasons, mandatory, rules in reviewer_data: - if isinstance(user_id, (int, basestring)): + if isinstance(user_id, (int, compat.string_types)): user_id = self._get_user(user_id).user_id reviewers[user_id] = { 'reasons': reasons, 'mandatory': mandatory} diff --git a/rhodecode/model/user_group.py b/rhodecode/model/user_group.py --- a/rhodecode/model/user_group.py +++ b/rhodecode/model/user_group.py @@ -20,6 +20,7 @@ import logging import traceback +from pyramid import compat from rhodecode.lib.utils2 import safe_str, safe_unicode from rhodecode.lib.exceptions import ( @@ -247,7 +248,7 @@ class UserGroupModel(BaseModel): # handle owner change if 'user' in form_data: owner = form_data['user'] - if isinstance(owner, basestring): + if isinstance(owner, compat.string_types): owner = User.get_by_username(form_data['user']) if not isinstance(owner, User): diff --git a/rhodecode/model/validation_schema/preparers.py b/rhodecode/model/validation_schema/preparers.py --- a/rhodecode/model/validation_schema/preparers.py +++ b/rhodecode/model/validation_schema/preparers.py @@ -19,6 +19,7 @@ # and proprietary license terms, please see https://rhodecode.com/licenses/ import unicodedata +from pyramid import compat def strip_preparer(value): @@ -83,6 +84,6 @@ def unique_list_from_str_preparer(value) """ from rhodecode.lib.utils2 import aslist - if isinstance(value, basestring): + if isinstance(value, compat.string_types): value = aslist(value, ',') return unique_list_preparer(value) \ No newline at end of file diff --git a/rhodecode/model/validation_schema/types.py b/rhodecode/model/validation_schema/types.py --- a/rhodecode/model/validation_schema/types.py +++ b/rhodecode/model/validation_schema/types.py @@ -21,6 +21,8 @@ import re import colander +from pyramid import compat + from rhodecode.model.validation_schema import preparers from rhodecode.model.db import User, UserGroup @@ -106,7 +108,7 @@ class StringBooleanType(colander.String) if isinstance(cstruct, bool): return cstruct - if not isinstance(cstruct, basestring): + if not isinstance(cstruct, compat.string_types): raise colander.Invalid(node, '%r is not a string' % cstruct) value = cstruct.lower() @@ -190,7 +192,7 @@ class UserGroupType(UserOrUserGroupType) class StrOrIntType(colander.String): def deserialize(self, node, cstruct): - if isinstance(cstruct, basestring): + if isinstance(cstruct, compat.string_types): return super(StrOrIntType, self).deserialize(node, cstruct) else: return colander.Integer().deserialize(node, cstruct) diff --git a/rhodecode/model/validators.py b/rhodecode/model/validators.py --- a/rhodecode/model/validators.py +++ b/rhodecode/model/validators.py @@ -37,6 +37,7 @@ from formencode.validators import ( from sqlalchemy.sql.expression import true from sqlalchemy.util import OrderedSet +from pyramid import compat from rhodecode.authentication import ( legacy_plugin_prefix, _import_legacy_plugin) @@ -125,7 +126,7 @@ def UniqueListFromString(localizer): class _validator(UniqueList(localizer)): def _to_python(self, value, state): - if isinstance(value, basestring): + if isinstance(value, compat.string_types): value = aslist(value, ',') return super(_validator, self)._to_python(value, state) return _validator diff --git a/rhodecode/templates/codeblocks/diffs.mako b/rhodecode/templates/codeblocks/diffs.mako --- a/rhodecode/templates/codeblocks/diffs.mako +++ b/rhodecode/templates/codeblocks/diffs.mako @@ -520,7 +520,7 @@ def get_comments_for(diff_type, comments if hasattr(filename, 'unicode_path'): filename = filename.unicode_path - if not isinstance(filename, basestring): + if not isinstance(filename, (unicode, str)): return None line_key = '{}{}'.format(line_version, line_number) ## e.g o37, n12 diff --git a/rhodecode/tests/config/test_utils.py b/rhodecode/tests/config/test_utils.py --- a/rhodecode/tests/config/test_utils.py +++ b/rhodecode/tests/config/test_utils.py @@ -19,6 +19,7 @@ # and proprietary license terms, please see https://rhodecode.com/licenses/ import pytest +from pyramid import compat from rhodecode.config.utils import set_instance_id @@ -31,6 +32,6 @@ def test_set_instance_id(instance_id): if instance_id == 'custom-id': assert config['instance_id'] == instance_id else: - assert isinstance(config['instance_id'], basestring) + assert isinstance(config['instance_id'], compat.string_types) assert len(config['instance_id']) assert instance_id != config['instance_id'] diff --git a/rhodecode/tests/scripts/test_crawler.py b/rhodecode/tests/scripts/test_crawler.py --- a/rhodecode/tests/scripts/test_crawler.py +++ b/rhodecode/tests/scripts/test_crawler.py @@ -35,7 +35,7 @@ import os import sys from os.path import join as jn from os.path import dirname as dn - +from pyramid import compat from sqlalchemy.util import OrderedSet __here__ = os.path.abspath(__file__) @@ -77,7 +77,7 @@ urllib2.install_opener(o) def _get_repo(proj): - if isinstance(proj, basestring): + if isinstance(proj, compat.string_types): repo = vcs.get_repo(jn(PROJECT_PATH, proj)) proj = proj else: