# HG changeset patch # User RhodeCode Admin # Date 2023-03-06 14:52:51 # Node ID 04e2d7da308ab8df6e679f9a24f4b8ec7d0a842a # Parent 6f3e1915735078975a14ced807da6c14d005f26c py3: remove use of pyramid.compat diff --git a/rhodecode/api/views/server_api.py b/rhodecode/api/views/server_api.py --- a/rhodecode/api/views/server_api.py +++ b/rhodecode/api/views/server_api.py @@ -22,8 +22,6 @@ import logging import itertools import base64 -from pyramid import compat - from rhodecode.api import ( jsonrpc_method, JSONRPCError, JSONRPCForbidden, find_methods) 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,7 +19,6 @@ # 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) @@ -245,7 +244,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, compat.string_types): + if isinstance(create_repo_group, str): 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,7 +22,6 @@ 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, rc_cache @@ -531,7 +530,7 @@ class DataGridAppView(object): return draw, start, length def _get_order_col(self, order_by, model): - if isinstance(order_by, compat.string_types): + if isinstance(order_by, str): 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 @@ -19,7 +19,6 @@ # and proprietary license terms, please see https://rhodecode.com/licenses/ import os import logging -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. @@ -67,7 +66,7 @@ def _append_path_sep(path): """ Append the path separator if missing. """ - if isinstance(path, compat.string_types) and not path.endswith(os.path.sep): + if isinstance(path, str) 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,7 +26,6 @@ by celery daemon import os import time -from pyramid import compat from pyramid_mailer.mailer import Mailer from pyramid_mailer.message import Message from email.utils import formatdate @@ -70,7 +69,7 @@ def send_email(recipients, subject, body subject = "%s %s" % (email_config.get('email_prefix', ''), subject) if recipients: - if isinstance(recipients, compat.string_types): + if isinstance(recipients, str): 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,7 +26,6 @@ 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) @@ -712,7 +711,7 @@ class DiffSet(object): filenode = None filename = None - if isinstance(input_file, compat.string_types): + if isinstance(input_file, str): 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,15 +18,13 @@ # 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, compat.string_types): + if isinstance(value, str): 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 @@ -12,7 +12,6 @@ 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 @@ -233,7 +232,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], compat.string_types): + if not len(p) or not isinstance(p[0], str): raise ValueError("First argument must be column name") diffs = self.compare_parameters(*p, **kw) @@ -342,7 +341,7 @@ class ColumnDelta(DictMixin, sqlalchemy. """Extracts data from p and modifies diffs""" p = list(p) while len(p): - if isinstance(p[0], compat.string_types): + if isinstance(p[0], str): k.setdefault('name', p.pop(0)) elif isinstance(p[0], sqlalchemy.types.TypeEngine): k.setdefault('type', p.pop(0)) @@ -380,7 +379,7 @@ class ColumnDelta(DictMixin, sqlalchemy. return getattr(self, '_table', None) def _set_table(self, table): - if isinstance(table, compat.string_types): + if isinstance(table, str): if self.alter_metadata: if not self.meta: raise ValueError("metadata must be specified for table" @@ -597,7 +596,7 @@ populated with defaults if isinstance(cons,(ForeignKeyConstraint, UniqueConstraint)): for col_name in cons.columns: - if not isinstance(col_name, compat.string_types): + if not isinstance(col_name, str): col_name = col_name.name if self.name==col_name: to_drop.add(cons) @@ -632,7 +631,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, compat.string_types) and obj is not None: + if not isinstance(obj, str) 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,7 +9,6 @@ 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 @@ -26,7 +25,7 @@ class ControlledSchema(object): """A database under version control""" def __init__(self, engine, repository): - if isinstance(repository, compat.string_types): + if isinstance(repository, str): repository = Repository(repository) self.engine = engine self.repository = repository @@ -135,7 +134,7 @@ class ControlledSchema(object): """ # Confirm that the version # is valid: positive, integer, # exists in repos - if isinstance(repository, compat.string_types): + if isinstance(repository, str): repository = Repository(repository) version = cls._validate_version(repository, version) table = cls._create_table_version(engine, repository, version) @@ -200,7 +199,7 @@ class ControlledSchema(object): """ Compare the current model against the current database. """ - if isinstance(repository, compat.string_types): + if isinstance(repository, str): repository = Repository(repository) model = load_model(model) @@ -213,7 +212,7 @@ class ControlledSchema(object): """ Dump the current database as a Python model. """ - if isinstance(repository, compat.string_types): + if isinstance(repository, str): 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,7 +7,6 @@ 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 @@ -52,7 +51,7 @@ class PythonScript(base.BaseScript): :rtype: string """ - if isinstance(repository, compat.string_types): + if isinstance(repository, str): # 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,7 +11,6 @@ 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 @@ -28,7 +27,7 @@ def load_model(dotted_name): .. versionchanged:: 0.5.4 """ - if isinstance(dotted_name, compat.string_types): + if isinstance(dotted_name, str): if ':' not in dotted_name: # backwards compatibility warnings.warn('model should be in form of module.model:User ' @@ -41,7 +40,7 @@ def load_model(dotted_name): def asbool(obj): """Do everything to use object as bool""" - if isinstance(obj, compat.string_types): + if isinstance(obj, str): obj = obj.strip().lower() if obj in ['true', 'yes', 'on', 'y', 't', '1']: return True @@ -114,7 +113,7 @@ def construct_engine(engine, **opts): """ if isinstance(engine, Engine): return engine - elif not isinstance(engine, compat.string_types): + elif not isinstance(engine, str): 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,7 +28,6 @@ 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 @@ -414,7 +413,7 @@ class UserGroup(Base, BaseModel): Session.flush() members_list = [] if v: - v = [v] if isinstance(v, compat.string_types) else v + v = [v] if isinstance(v, str) 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,6 @@ 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 +2109,7 @@ class Repository(Base, BaseModel): warnings.warn("Use get_commit", DeprecationWarning) commit_id = None commit_idx = None - if isinstance(rev, compat.string_types): + if isinstance(rev, str): commit_id = rev else: commit_idx = rev @@ -3725,7 +3724,7 @@ class PullRequestReviewers(Base, BaseMod @reasons.setter def reasons(self, val): val = val or [] - if any(not isinstance(x, compat.string_types) for x in val): + if any(not isinstance(x, str) 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,6 @@ 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 +2175,7 @@ class Repository(Base, BaseModel): warnings.warn("Use get_commit", DeprecationWarning) commit_id = None commit_idx = None - if isinstance(rev, compat.string_types): + if isinstance(rev, str): commit_id = rev else: commit_idx = rev @@ -3808,7 +3807,7 @@ class PullRequestReviewers(Base, BaseMod @reasons.setter def reasons(self, val): val = val or [] - if any(not isinstance(x, compat.string_types) for x in val): + if any(not isinstance(x, str) 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,6 @@ 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 +2216,7 @@ class Repository(Base, BaseModel): warnings.warn("Use get_commit", DeprecationWarning) commit_id = None commit_idx = None - if isinstance(rev, compat.string_types): + if isinstance(rev, str): commit_id = rev else: commit_idx = rev @@ -3956,7 +3955,7 @@ class PullRequestReviewers(Base, BaseMod @reasons.setter def reasons(self, val): val = val or [] - if any(not isinstance(x, compat.string_types) for x in val): + if any(not isinstance(x, str) 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,6 @@ 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 +2239,7 @@ class Repository(Base, BaseModel): warnings.warn("Use get_commit", DeprecationWarning) commit_id = None commit_idx = None - if isinstance(rev, compat.string_types): + if isinstance(rev, str): commit_id = rev else: commit_idx = rev @@ -4030,7 +4029,7 @@ class PullRequestReviewers(Base, BaseMod @reasons.setter def reasons(self, val): val = val or [] - if any(not isinstance(x, compat.string_types) for x in val): + if any(not isinstance(x, str) 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_2.py b/rhodecode/lib/dbmigrate/schema/db_4_16_0_2.py --- a/rhodecode/lib/dbmigrate/schema/db_4_16_0_2.py +++ b/rhodecode/lib/dbmigrate/schema/db_4_16_0_2.py @@ -48,7 +48,6 @@ 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 +2239,7 @@ class Repository(Base, BaseModel): warnings.warn("Use get_commit", DeprecationWarning) commit_id = None commit_idx = None - if isinstance(rev, compat.string_types): + if isinstance(rev, str): commit_id = rev else: commit_idx = rev @@ -4031,7 +4030,7 @@ class PullRequestReviewers(Base, BaseMod @reasons.setter def reasons(self, val): val = val or [] - if any(not isinstance(x, compat.string_types) for x in val): + if any(not isinstance(x, str) 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_18_0_1.py b/rhodecode/lib/dbmigrate/schema/db_4_18_0_1.py --- a/rhodecode/lib/dbmigrate/schema/db_4_18_0_1.py +++ b/rhodecode/lib/dbmigrate/schema/db_4_18_0_1.py @@ -50,7 +50,6 @@ 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 webhelpers2.text import collapse, remove_formatting @@ -2281,7 +2280,7 @@ class Repository(Base, BaseModel): warnings.warn("Use get_commit", DeprecationWarning) commit_id = None commit_idx = None - if isinstance(rev, compat.string_types): + if isinstance(rev, str): commit_id = rev else: commit_idx = rev @@ -4276,7 +4275,7 @@ class PullRequestReviewers(Base, BaseMod @reasons.setter def reasons(self, val): val = val or [] - if any(not isinstance(x, compat.string_types) for x in val): + if any(not isinstance(x, str) 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_19_0_0.py b/rhodecode/lib/dbmigrate/schema/db_4_19_0_0.py --- a/rhodecode/lib/dbmigrate/schema/db_4_19_0_0.py +++ b/rhodecode/lib/dbmigrate/schema/db_4_19_0_0.py @@ -50,7 +50,6 @@ 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 webhelpers2.text import remove_formatting @@ -2348,7 +2347,7 @@ class Repository(Base, BaseModel): warnings.warn("Use get_commit", DeprecationWarning) commit_id = None commit_idx = None - if isinstance(rev, compat.string_types): + if isinstance(rev, str): commit_id = rev else: commit_idx = rev @@ -4391,7 +4390,7 @@ class PullRequestReviewers(Base, BaseMod @reasons.setter def reasons(self, val): val = val or [] - if any(not isinstance(x, compat.string_types) for x in val): + if any(not isinstance(x, str) 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_19_0_2.py b/rhodecode/lib/dbmigrate/schema/db_4_19_0_2.py --- a/rhodecode/lib/dbmigrate/schema/db_4_19_0_2.py +++ b/rhodecode/lib/dbmigrate/schema/db_4_19_0_2.py @@ -50,7 +50,6 @@ 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 webhelpers2.text import remove_formatting @@ -2354,7 +2353,7 @@ class Repository(Base, BaseModel): warnings.warn("Use get_commit", DeprecationWarning) commit_id = None commit_idx = None - if isinstance(rev, compat.string_types): + if isinstance(rev, str): commit_id = rev else: commit_idx = rev @@ -4440,7 +4439,7 @@ class PullRequestReviewers(Base, BaseMod @reasons.setter def reasons(self, val): val = val or [] - if any(not isinstance(x, compat.string_types) for x in val): + if any(not isinstance(x, str) 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_20_0_0.py b/rhodecode/lib/dbmigrate/schema/db_4_20_0_0.py --- a/rhodecode/lib/dbmigrate/schema/db_4_20_0_0.py +++ b/rhodecode/lib/dbmigrate/schema/db_4_20_0_0.py @@ -50,7 +50,6 @@ 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 webhelpers2.text import remove_formatting @@ -2385,7 +2384,7 @@ class Repository(Base, BaseModel): warnings.warn("Use get_commit", DeprecationWarning) commit_id = None commit_idx = None - if isinstance(rev, compat.string_types): + if isinstance(rev, str): commit_id = rev else: commit_idx = rev @@ -4502,7 +4501,7 @@ class PullRequestReviewers(Base, BaseMod @reasons.setter def reasons(self, val): val = val or [] - if any(not isinstance(x, compat.string_types) for x in val): + if any(not isinstance(x, str) 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 @@ -44,7 +44,6 @@ 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 +1810,7 @@ class Repository(Base, BaseModel): warnings.warn("Use get_commit", DeprecationWarning) commit_id = None commit_idx = None - if isinstance(rev, compat.string_types): + if isinstance(rev, str): 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 @@ -44,7 +44,6 @@ 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 +1813,7 @@ class Repository(Base, BaseModel): warnings.warn("Use get_commit", DeprecationWarning) commit_id = None commit_idx = None - if isinstance(rev, compat.string_types): + if isinstance(rev, str): 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 @@ -44,7 +44,6 @@ 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 _ @@ -1813,7 +1812,7 @@ class Repository(Base, BaseModel): warnings.warn("Use get_commit", DeprecationWarning) commit_id = None commit_idx = None - if isinstance(rev, compat.string_types): + if isinstance(rev, str): 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 @@ -45,7 +45,6 @@ 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 _ @@ -1815,7 +1814,7 @@ class Repository(Base, BaseModel): warnings.warn("Use get_commit", DeprecationWarning) commit_id = None commit_idx = None - if isinstance(rev, compat.string_types): + if isinstance(rev, str): 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 @@ -45,7 +45,6 @@ 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 _ @@ -1815,7 +1814,7 @@ class Repository(Base, BaseModel): warnings.warn("Use get_commit", DeprecationWarning) commit_id = None commit_idx = None - if isinstance(rev, compat.string_types): + if isinstance(rev, str): commit_id = rev else: commit_idx = rev @@ -3178,7 +3177,7 @@ class PullRequestReviewers(Base, BaseMod @reasons.setter def reasons(self, val): val = val or [] - if any(not isinstance(x, compat.string_types) for x in val): + if any(not isinstance(x, str) 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 @@ -43,7 +43,6 @@ 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 +1857,7 @@ class Repository(Base, BaseModel): warnings.warn("Use get_commit", DeprecationWarning) commit_id = None commit_idx = None - if isinstance(rev, compat.string_types): + if isinstance(rev, str): commit_id = rev else: commit_idx = rev @@ -3406,7 +3405,7 @@ class PullRequestReviewers(Base, BaseMod @reasons.setter def reasons(self, val): val = val or [] - if any(not isinstance(x, compat.string_types) for x in val): + if any(not isinstance(x, str) 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 @@ -43,7 +43,6 @@ 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 +1858,7 @@ class Repository(Base, BaseModel): warnings.warn("Use get_commit", DeprecationWarning) commit_id = None commit_idx = None - if isinstance(rev, compat.string_types): + if isinstance(rev, str): commit_id = rev else: commit_idx = rev @@ -3407,7 +3406,7 @@ class PullRequestReviewers(Base, BaseMod @reasons.setter def reasons(self, val): val = val or [] - if any(not isinstance(x, compat.string_types) for x in val): + if any(not isinstance(x, str) 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 @@ -43,7 +43,6 @@ 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 _ @@ -2046,7 +2045,7 @@ class Repository(Base, BaseModel): warnings.warn("Use get_commit", DeprecationWarning) commit_id = None commit_idx = None - if isinstance(rev, compat.string_types): + if isinstance(rev, str): commit_id = rev else: commit_idx = rev @@ -3660,7 +3659,7 @@ class PullRequestReviewers(Base, BaseMod @reasons.setter def reasons(self, val): val = val or [] - if any(not isinstance(x, compat.string_types) for x in val): + if any(not isinstance(x, str) 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,7 +2,6 @@ import logging import datetime from sqlalchemy import * -from pyramid import compat from rhodecode.lib.utils2 import safe_str from rhodecode.model import meta @@ -13,7 +12,7 @@ log = logging.getLogger(__name__) def time_to_datetime(tm): if tm: - if isinstance(tm, compat.string_types): + if isinstance(tm, str): 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 @@ -32,7 +32,6 @@ import re import sys import time import urllib -from pyramid import compat class diff_match_patch: @@ -1439,7 +1438,7 @@ class diff_match_patch: text1 = None diffs = None # Note that texts may arrive as 'str' or 'unicode'. - if isinstance(a, compat.string_types) and isinstance(b, compat.string_types) and c is None: + if isinstance(a, str) and isinstance(b, str) and c is None: # Method 1: text1, text2 # Compute diffs from text1 and text2. text1 = a @@ -1452,11 +1451,11 @@ class diff_match_patch: # Compute text1 from diffs. diffs = a text1 = self.diff_text1(diffs) - elif isinstance(a, compat.string_types) and isinstance(b, list) and c is None: + elif isinstance(a, str) and isinstance(b, list) and c is None: # Method 3: text1, diffs text1 = a diffs = b - elif (isinstance(a, compat.string_types) and isinstance(b, compat.string_types) and + elif (isinstance(a, str) and isinstance(b, str) 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 @@ -47,7 +47,6 @@ 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 @@ -190,7 +190,7 @@ def get_default_cache_settings(settings, if key.startswith(prefix): name = key.split(prefix)[1].strip() val = settings[key] - if isinstance(val, compat.string_types): + if isinstance(val, str): 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 @@ -48,7 +48,6 @@ import sqlalchemy.exc import sqlalchemy.sql import webob import pyramid.threadlocal -from pyramid import compat from pyramid.settings import asbool import rhodecode @@ -269,7 +268,7 @@ def safe_str(unicode_, to_encoding=None, """ # if it's not basestr cast to str - if not isinstance(unicode_, compat.string_types): + if not isinstance(unicode_, str): return str(unicode_) if isinstance(unicode_, str): @@ -712,7 +711,7 @@ def datetime_to_time(dt): def time_to_datetime(tm): if tm: - if isinstance(tm, compat.string_types): + if isinstance(tm, str): try: tm = float(tm) except ValueError: @@ -722,7 +721,7 @@ def time_to_datetime(tm): def time_to_utcdatetime(tm): if tm: - if isinstance(tm, compat.string_types): + if isinstance(tm, str): 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 @@ -34,7 +34,6 @@ import warnings from zope.cachedescriptors.property import Lazy as LazyProperty -from pyramid import compat import rhodecode from rhodecode.translation import lazy_ugettext @@ -785,7 +784,7 @@ class BaseRepository(object): (commit, self, commit.repository)) def _validate_commit_id(self, commit_id): - if not isinstance(commit_id, compat.string_types): + if not isinstance(commit_id, str): raise TypeError("commit_id must be a string value got {} instead".format(type(commit_id))) def _validate_commit_idx(self, commit_idx): @@ -822,7 +821,7 @@ class BaseRepository(object): warnings.warn("Use get_commit instead", DeprecationWarning) commit_id = None commit_idx = None - if isinstance(revision, compat.string_types): + if isinstance(revision, str): commit_id = revision else: commit_idx = revision @@ -849,7 +848,7 @@ class BaseRepository(object): if revision is None: return revision - if isinstance(revision, compat.string_types): + if isinstance(revision, str): 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,7 +25,6 @@ import logging import functools import urllib2 import rhodecode -from pyramid import compat log = logging.getLogger(__name__) @@ -196,7 +195,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, compat.string_types): + if isinstance(remote_tb, str): 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 @@ -50,7 +50,6 @@ 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 webhelpers2.text import remove_formatting @@ -2407,7 +2406,7 @@ class Repository(Base, BaseModel): warnings.warn("Use get_commit", DeprecationWarning) commit_id = None commit_idx = None - if isinstance(rev, compat.string_types): + if isinstance(rev, str): commit_id = rev else: commit_idx = rev @@ -4604,7 +4603,7 @@ class PullRequestReviewers(Base, BaseMod @reasons.setter def reasons(self, val): val = val or [] - if any(not isinstance(x, compat.string_types) for x in val): + if any(not isinstance(x, str) 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 @@ -32,7 +32,6 @@ import datetime import urllib import collections -from pyramid import compat from pyramid.threadlocal import get_current_request from rhodecode.lib.vcs.nodes import FileNode @@ -1426,7 +1425,7 @@ class PullRequestModel(BaseModel): reviewers = {} for user_id, reasons, mandatory, role, rules in reviewer_data: - if isinstance(user_id, (int, compat.string_types)): + if isinstance(user_id, (int, str)): user_id = self._get_user(user_id).user_id reviewers[user_id] = { 'reasons': reasons, 'mandatory': mandatory, 'role': role} @@ -1508,7 +1507,7 @@ class PullRequestModel(BaseModel): observers = {} for user_id, reasons, mandatory, role, rules in observer_data: - if isinstance(user_id, (int, compat.string_types)): + if isinstance(user_id, (int, str)): user_id = self._get_user(user_id).user_id observers[user_id] = { 'reasons': reasons, 'observers': mandatory, 'role': role} 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,7 +20,6 @@ import logging import traceback -from pyramid import compat from rhodecode.lib.utils2 import safe_str, safe_unicode from rhodecode.lib.exceptions import ( @@ -248,7 +247,7 @@ class UserGroupModel(BaseModel): # handle owner change if 'user' in form_data: owner = form_data['user'] - if isinstance(owner, compat.string_types): + if isinstance(owner, str): 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,7 +19,6 @@ # and proprietary license terms, please see https://rhodecode.com/licenses/ import unicodedata -from pyramid import compat def strip_preparer(value): @@ -84,6 +83,6 @@ def unique_list_from_str_preparer(value) """ from rhodecode.lib.utils2 import aslist - if isinstance(value, compat.string_types): + if isinstance(value, str): 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 @@ -19,9 +19,7 @@ # and proprietary license terms, please see https://rhodecode.com/licenses/ import re - import colander -from pyramid import compat from rhodecode.model.validation_schema import preparers from rhodecode.model.db import User, UserGroup @@ -108,7 +106,7 @@ class StringBooleanType(colander.String) if isinstance(cstruct, bool): return cstruct - if not isinstance(cstruct, compat.string_types): + if not isinstance(cstruct, str): raise colander.Invalid(node, '%r is not a string' % cstruct) value = cstruct.lower() @@ -192,7 +190,7 @@ class UserGroupType(UserOrUserGroupType) class StrOrIntType(colander.String): def deserialize(self, node, cstruct): - if isinstance(cstruct, compat.string_types): + if isinstance(cstruct, str): 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,7 +37,6 @@ 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) @@ -126,7 +125,7 @@ def UniqueListFromString(localizer): class _validator(UniqueList(localizer)): def _to_python(self, value, state): - if isinstance(value, compat.string_types): + if isinstance(value, str): value = aslist(value, ',') return super(_validator, self)._to_python(value, state) return _validator 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,7 +19,6 @@ # and proprietary license terms, please see https://rhodecode.com/licenses/ import pytest -from pyramid import compat from rhodecode.config.utils import set_instance_id @@ -32,6 +31,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'], compat.string_types) + assert isinstance(config['instance_id'], str) 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,6 @@ 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 +76,7 @@ urllib2.install_opener(o) def _get_repo(proj): - if isinstance(proj, compat.string_types): + if isinstance(proj, str): repo = vcs.get_repo(jn(PROJECT_PATH, proj)) proj = proj else: