py3: remove use of pyramid.compat
This commit is contained in:
parent
afbf679a60
commit
dbf975898e
44 changed files with 73 additions and 119 deletions
|
|
@ -22,8 +22,6 @@ import logging
|
|||
import itertools
|
||||
import base64
|
||||
|
||||
from pyramid import compat
|
||||
|
||||
from rhodecode.api import (
|
||||
jsonrpc_method, JSONRPCError, JSONRPCForbidden, find_methods)
|
||||
|
||||
|
|
|
|||
|
|
@ -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, username, email, password=Optional(''),
|
|||
# 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)
|
||||
|
|
|
|||
|
|
@ -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:
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
||||
|
|
|
|||
|
|
@ -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='', html_body='', email_config=None,
|
|||
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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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.schema.SchemaItem):
|
|||
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.schema.SchemaItem):
|
|||
"""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.schema.SchemaItem):
|
|||
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)
|
||||
|
||||
|
|
|
|||
|
|
@ -9,7 +9,6 @@ from sqlalchemy import (Table, Column, MetaData, String, Text, Integer,
|
|||
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(
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -49,7 +49,6 @@ from sqlalchemy.exc import IntegrityError # pragma: no cover
|
|||
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, BaseModel):
|
|||
@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
|
||||
|
||||
|
|
|
|||
|
|
@ -49,7 +49,6 @@ from sqlalchemy.exc import IntegrityError # pragma: no cover
|
|||
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, BaseModel):
|
|||
@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
|
||||
|
||||
|
|
|
|||
|
|
@ -48,7 +48,6 @@ from sqlalchemy.ext.hybrid import hybrid_property
|
|||
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, BaseModel):
|
|||
@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
|
||||
|
||||
|
|
|
|||
|
|
@ -48,7 +48,6 @@ from sqlalchemy.ext.hybrid import hybrid_property
|
|||
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, BaseModel):
|
|||
@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
|
||||
|
||||
|
|
|
|||
|
|
@ -48,7 +48,6 @@ from sqlalchemy.ext.hybrid import hybrid_property
|
|||
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, BaseModel):
|
|||
@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
|
||||
|
||||
|
|
|
|||
|
|
@ -50,7 +50,6 @@ from sqlalchemy.ext.hybrid import hybrid_property
|
|||
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, BaseModel):
|
|||
@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
|
||||
|
||||
|
|
|
|||
|
|
@ -50,7 +50,6 @@ from sqlalchemy.ext.hybrid import hybrid_property
|
|||
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, BaseModel):
|
|||
@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
|
||||
|
||||
|
|
|
|||
|
|
@ -50,7 +50,6 @@ from sqlalchemy.ext.hybrid import hybrid_property
|
|||
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, BaseModel):
|
|||
@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
|
||||
|
||||
|
|
|
|||
|
|
@ -50,7 +50,6 @@ from sqlalchemy.ext.hybrid import hybrid_property
|
|||
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, BaseModel):
|
|||
@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
|
||||
|
||||
|
|
|
|||
|
|
@ -44,7 +44,6 @@ from sqlalchemy.sql.expression import true
|
|||
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
|
||||
|
|
|
|||
|
|
@ -44,7 +44,6 @@ from sqlalchemy.sql.expression import true
|
|||
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
|
||||
|
|
|
|||
|
|
@ -44,7 +44,6 @@ from sqlalchemy.sql.expression import true
|
|||
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
|
||||
|
|
|
|||
|
|
@ -45,7 +45,6 @@ from sqlalchemy.sql.expression import true
|
|||
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
|
||||
|
|
|
|||
|
|
@ -45,7 +45,6 @@ from sqlalchemy.sql.expression import true
|
|||
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, BaseModel):
|
|||
@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
|
||||
|
||||
|
|
|
|||
|
|
@ -43,7 +43,6 @@ from sqlalchemy.sql.expression import true
|
|||
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, BaseModel):
|
|||
@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
|
||||
|
||||
|
|
|
|||
|
|
@ -43,7 +43,6 @@ from sqlalchemy.sql.expression import true
|
|||
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, BaseModel):
|
|||
@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
|
||||
|
||||
|
|
|
|||
|
|
@ -43,7 +43,6 @@ from sqlalchemy.sql.expression import true
|
|||
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, BaseModel):
|
|||
@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
|
||||
|
||||
|
|
|
|||
|
|
@ -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:
|
||||
|
|
|
|||
|
|
@ -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.
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -190,7 +190,7 @@ def get_default_cache_settings(settings, prefixes=None):
|
|||
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
|
||||
|
|
|
|||
|
|
@ -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, use_chardet=False):
|
|||
"""
|
||||
|
||||
# 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:
|
||||
|
|
|
|||
|
|
@ -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]
|
||||
|
|
|
|||
|
|
@ -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'
|
||||
|
|
|
|||
|
|
@ -50,7 +50,6 @@ from sqlalchemy.ext.hybrid import hybrid_property
|
|||
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, BaseModel):
|
|||
@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
|
||||
|
||||
|
|
|
|||
|
|
@ -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}
|
||||
|
|
|
|||
|
|
@ -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):
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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']
|
||||
|
|
|
|||
|
|
@ -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:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue