##// END OF EJS Templates
py3: remove use of pyramid.compat
super-admin -
r4908:04e2d7da default
parent child Browse files
Show More
@@ -22,8 +22,6 b' import logging'
22 import itertools
22 import itertools
23 import base64
23 import base64
24
24
25 from pyramid import compat
26
27 from rhodecode.api import (
25 from rhodecode.api import (
28 jsonrpc_method, JSONRPCError, JSONRPCForbidden, find_methods)
26 jsonrpc_method, JSONRPCError, JSONRPCForbidden, find_methods)
29
27
@@ -19,7 +19,6 b''
19 # and proprietary license terms, please see https://rhodecode.com/licenses/
19 # and proprietary license terms, please see https://rhodecode.com/licenses/
20
20
21 import logging
21 import logging
22 from pyramid import compat
23
22
24 from rhodecode.api import (
23 from rhodecode.api import (
25 jsonrpc_method, JSONRPCError, JSONRPCForbidden, JSONRPCValidationError)
24 jsonrpc_method, JSONRPCError, JSONRPCForbidden, JSONRPCValidationError)
@@ -245,7 +244,7 b' def create_user(request, apiuser, userna'
245 # generate temporary password if user is external
244 # generate temporary password if user is external
246 password = PasswordGenerator().gen_password(length=16)
245 password = PasswordGenerator().gen_password(length=16)
247 create_repo_group = Optional.extract(create_personal_repo_group)
246 create_repo_group = Optional.extract(create_personal_repo_group)
248 if isinstance(create_repo_group, compat.string_types):
247 if isinstance(create_repo_group, str):
249 create_repo_group = str2bool(create_repo_group)
248 create_repo_group = str2bool(create_repo_group)
250
249
251 username = Optional.extract(username)
250 username = Optional.extract(username)
@@ -22,7 +22,6 b' import time'
22 import logging
22 import logging
23 import operator
23 import operator
24
24
25 from pyramid import compat
26 from pyramid.httpexceptions import HTTPFound, HTTPForbidden, HTTPBadRequest
25 from pyramid.httpexceptions import HTTPFound, HTTPForbidden, HTTPBadRequest
27
26
28 from rhodecode.lib import helpers as h, diffs, rc_cache
27 from rhodecode.lib import helpers as h, diffs, rc_cache
@@ -531,7 +530,7 b' class DataGridAppView(object):'
531 return draw, start, length
530 return draw, start, length
532
531
533 def _get_order_col(self, order_by, model):
532 def _get_order_col(self, order_by, model):
534 if isinstance(order_by, compat.string_types):
533 if isinstance(order_by, str):
535 try:
534 try:
536 return operator.attrgetter(order_by)(model)
535 return operator.attrgetter(order_by)(model)
537 except AttributeError:
536 except AttributeError:
@@ -19,7 +19,6 b''
19 # and proprietary license terms, please see https://rhodecode.com/licenses/
19 # and proprietary license terms, please see https://rhodecode.com/licenses/
20 import os
20 import os
21 import logging
21 import logging
22 from pyramid import compat
23
22
24 # Do not use `from rhodecode import events` here, it will be overridden by the
23 # Do not use `from rhodecode import events` here, it will be overridden by the
25 # events module in this package due to pythons import mechanism.
24 # events module in this package due to pythons import mechanism.
@@ -67,7 +66,7 b' def _append_path_sep(path):'
67 """
66 """
68 Append the path separator if missing.
67 Append the path separator if missing.
69 """
68 """
70 if isinstance(path, compat.string_types) and not path.endswith(os.path.sep):
69 if isinstance(path, str) and not path.endswith(os.path.sep):
71 path += os.path.sep
70 path += os.path.sep
72 return path
71 return path
73
72
@@ -26,7 +26,6 b' by celery daemon'
26 import os
26 import os
27 import time
27 import time
28
28
29 from pyramid import compat
30 from pyramid_mailer.mailer import Mailer
29 from pyramid_mailer.mailer import Mailer
31 from pyramid_mailer.message import Message
30 from pyramid_mailer.message import Message
32 from email.utils import formatdate
31 from email.utils import formatdate
@@ -70,7 +69,7 b' def send_email(recipients, subject, body'
70 subject = "%s %s" % (email_config.get('email_prefix', ''), subject)
69 subject = "%s %s" % (email_config.get('email_prefix', ''), subject)
71
70
72 if recipients:
71 if recipients:
73 if isinstance(recipients, compat.string_types):
72 if isinstance(recipients, str):
74 recipients = recipients.split(',')
73 recipients = recipients.split(',')
75 else:
74 else:
76 # if recipients are not defined we send to email_config + all admins
75 # if recipients are not defined we send to email_config + all admins
@@ -26,7 +26,6 b' from pygments import lex'
26 from pygments.formatters.html import _get_ttype_class as pygment_token_class
26 from pygments.formatters.html import _get_ttype_class as pygment_token_class
27 from pygments.lexers.special import TextLexer, Token
27 from pygments.lexers.special import TextLexer, Token
28 from pygments.lexers import get_lexer_by_name
28 from pygments.lexers import get_lexer_by_name
29 from pyramid import compat
30
29
31 from rhodecode.lib.helpers import (
30 from rhodecode.lib.helpers import (
32 get_lexer_for_filenode, html_escape, get_custom_lexer)
31 get_lexer_for_filenode, html_escape, get_custom_lexer)
@@ -712,7 +711,7 b' class DiffSet(object):'
712 filenode = None
711 filenode = None
713 filename = None
712 filename = None
714
713
715 if isinstance(input_file, compat.string_types):
714 if isinstance(input_file, str):
716 filename = input_file
715 filename = input_file
717 elif isinstance(input_file, FileNode):
716 elif isinstance(input_file, FileNode):
718 filenode = input_file
717 filenode = input_file
@@ -18,15 +18,13 b''
18 # RhodeCode Enterprise Edition, including its added features, Support services,
18 # RhodeCode Enterprise Edition, including its added features, Support services,
19 # and proprietary license terms, please see https://rhodecode.com/licenses/
19 # and proprietary license terms, please see https://rhodecode.com/licenses/
20
20
21 from pyramid import compat
22
23
21
24 def strip_whitespace(value):
22 def strip_whitespace(value):
25 """
23 """
26 Removes leading/trailing whitespace, newlines, and tabs from the value.
24 Removes leading/trailing whitespace, newlines, and tabs from the value.
27 Implements the `colander.interface.Preparer` interface.
25 Implements the `colander.interface.Preparer` interface.
28 """
26 """
29 if isinstance(value, compat.string_types):
27 if isinstance(value, str):
30 return value.strip(' \t\n\r')
28 return value.strip(' \t\n\r')
31 else:
29 else:
32 return value
30 return value
@@ -12,7 +12,6 b' import sqlalchemy'
12
12
13 from sqlalchemy.schema import ForeignKeyConstraint
13 from sqlalchemy.schema import ForeignKeyConstraint
14 from sqlalchemy.schema import UniqueConstraint
14 from sqlalchemy.schema import UniqueConstraint
15 from pyramid import compat
16
15
17 from rhodecode.lib.dbmigrate.migrate.exceptions import *
16 from rhodecode.lib.dbmigrate.migrate.exceptions import *
18 from rhodecode.lib.dbmigrate.migrate.changeset import SQLA_07, SQLA_08
17 from rhodecode.lib.dbmigrate.migrate.changeset import SQLA_07, SQLA_08
@@ -233,7 +232,7 b' class ColumnDelta(DictMixin, sqlalchemy.'
233 diffs = self.compare_1_column(*p, **kw)
232 diffs = self.compare_1_column(*p, **kw)
234 else:
233 else:
235 # Zero columns specified
234 # Zero columns specified
236 if not len(p) or not isinstance(p[0], compat.string_types):
235 if not len(p) or not isinstance(p[0], str):
237 raise ValueError("First argument must be column name")
236 raise ValueError("First argument must be column name")
238 diffs = self.compare_parameters(*p, **kw)
237 diffs = self.compare_parameters(*p, **kw)
239
238
@@ -342,7 +341,7 b' class ColumnDelta(DictMixin, sqlalchemy.'
342 """Extracts data from p and modifies diffs"""
341 """Extracts data from p and modifies diffs"""
343 p = list(p)
342 p = list(p)
344 while len(p):
343 while len(p):
345 if isinstance(p[0], compat.string_types):
344 if isinstance(p[0], str):
346 k.setdefault('name', p.pop(0))
345 k.setdefault('name', p.pop(0))
347 elif isinstance(p[0], sqlalchemy.types.TypeEngine):
346 elif isinstance(p[0], sqlalchemy.types.TypeEngine):
348 k.setdefault('type', p.pop(0))
347 k.setdefault('type', p.pop(0))
@@ -380,7 +379,7 b' class ColumnDelta(DictMixin, sqlalchemy.'
380 return getattr(self, '_table', None)
379 return getattr(self, '_table', None)
381
380
382 def _set_table(self, table):
381 def _set_table(self, table):
383 if isinstance(table, compat.string_types):
382 if isinstance(table, str):
384 if self.alter_metadata:
383 if self.alter_metadata:
385 if not self.meta:
384 if not self.meta:
386 raise ValueError("metadata must be specified for table"
385 raise ValueError("metadata must be specified for table"
@@ -597,7 +596,7 b' populated with defaults'
597 if isinstance(cons,(ForeignKeyConstraint,
596 if isinstance(cons,(ForeignKeyConstraint,
598 UniqueConstraint)):
597 UniqueConstraint)):
599 for col_name in cons.columns:
598 for col_name in cons.columns:
600 if not isinstance(col_name, compat.string_types):
599 if not isinstance(col_name, str):
601 col_name = col_name.name
600 col_name = col_name.name
602 if self.name==col_name:
601 if self.name==col_name:
603 to_drop.add(cons)
602 to_drop.add(cons)
@@ -632,7 +631,7 b' populated with defaults'
632 if (getattr(self, name[:-5]) and not obj):
631 if (getattr(self, name[:-5]) and not obj):
633 raise InvalidConstraintError("Column.create() accepts index_name,"
632 raise InvalidConstraintError("Column.create() accepts index_name,"
634 " primary_key_name and unique_name to generate constraints")
633 " primary_key_name and unique_name to generate constraints")
635 if not isinstance(obj, compat.string_types) and obj is not None:
634 if not isinstance(obj, str) and obj is not None:
636 raise InvalidConstraintError(
635 raise InvalidConstraintError(
637 "%s argument for column must be constraint name" % name)
636 "%s argument for column must be constraint name" % name)
638
637
@@ -9,7 +9,6 b' from sqlalchemy import (Table, Column, M'
9 from sqlalchemy.sql import and_
9 from sqlalchemy.sql import and_
10 from sqlalchemy import exc as sa_exceptions
10 from sqlalchemy import exc as sa_exceptions
11 from sqlalchemy.sql import bindparam
11 from sqlalchemy.sql import bindparam
12 from pyramid import compat
13
12
14 from rhodecode.lib.dbmigrate.migrate import exceptions
13 from rhodecode.lib.dbmigrate.migrate import exceptions
15 from rhodecode.lib.dbmigrate.migrate.changeset import SQLA_07
14 from rhodecode.lib.dbmigrate.migrate.changeset import SQLA_07
@@ -26,7 +25,7 b' class ControlledSchema(object):'
26 """A database under version control"""
25 """A database under version control"""
27
26
28 def __init__(self, engine, repository):
27 def __init__(self, engine, repository):
29 if isinstance(repository, compat.string_types):
28 if isinstance(repository, str):
30 repository = Repository(repository)
29 repository = Repository(repository)
31 self.engine = engine
30 self.engine = engine
32 self.repository = repository
31 self.repository = repository
@@ -135,7 +134,7 b' class ControlledSchema(object):'
135 """
134 """
136 # Confirm that the version # is valid: positive, integer,
135 # Confirm that the version # is valid: positive, integer,
137 # exists in repos
136 # exists in repos
138 if isinstance(repository, compat.string_types):
137 if isinstance(repository, str):
139 repository = Repository(repository)
138 repository = Repository(repository)
140 version = cls._validate_version(repository, version)
139 version = cls._validate_version(repository, version)
141 table = cls._create_table_version(engine, repository, version)
140 table = cls._create_table_version(engine, repository, version)
@@ -200,7 +199,7 b' class ControlledSchema(object):'
200 """
199 """
201 Compare the current model against the current database.
200 Compare the current model against the current database.
202 """
201 """
203 if isinstance(repository, compat.string_types):
202 if isinstance(repository, str):
204 repository = Repository(repository)
203 repository = Repository(repository)
205 model = load_model(model)
204 model = load_model(model)
206
205
@@ -213,7 +212,7 b' class ControlledSchema(object):'
213 """
212 """
214 Dump the current database as a Python model.
213 Dump the current database as a Python model.
215 """
214 """
216 if isinstance(repository, compat.string_types):
215 if isinstance(repository, str):
217 repository = Repository(repository)
216 repository = Repository(repository)
218
217
219 diff = schemadiff.getDiffOfModelAgainstDatabase(
218 diff = schemadiff.getDiffOfModelAgainstDatabase(
@@ -7,7 +7,6 b' import logging'
7 import inspect
7 import inspect
8 from StringIO import StringIO
8 from StringIO import StringIO
9
9
10 from pyramid import compat
11 from rhodecode.lib.dbmigrate import migrate
10 from rhodecode.lib.dbmigrate import migrate
12 from rhodecode.lib.dbmigrate.migrate.versioning import genmodel, schemadiff
11 from rhodecode.lib.dbmigrate.migrate.versioning import genmodel, schemadiff
13 from rhodecode.lib.dbmigrate.migrate.versioning.config import operations
12 from rhodecode.lib.dbmigrate.migrate.versioning.config import operations
@@ -52,7 +51,7 b' class PythonScript(base.BaseScript):'
52 :rtype: string
51 :rtype: string
53 """
52 """
54
53
55 if isinstance(repository, compat.string_types):
54 if isinstance(repository, str):
56 # oh dear, an import cycle!
55 # oh dear, an import cycle!
57 from rhodecode.lib.dbmigrate.migrate.versioning.repository import Repository
56 from rhodecode.lib.dbmigrate.migrate.versioning.repository import Repository
58 repository = Repository(repository)
57 repository = Repository(repository)
@@ -11,7 +11,6 b' from sqlalchemy import create_engine'
11 from sqlalchemy.engine import Engine
11 from sqlalchemy.engine import Engine
12 from sqlalchemy.pool import StaticPool
12 from sqlalchemy.pool import StaticPool
13
13
14 from pyramid import compat
15 from rhodecode.lib.dbmigrate.migrate import exceptions
14 from rhodecode.lib.dbmigrate.migrate import exceptions
16 from rhodecode.lib.dbmigrate.migrate.versioning.util.keyedinstance import KeyedInstance
15 from rhodecode.lib.dbmigrate.migrate.versioning.util.keyedinstance import KeyedInstance
17 from rhodecode.lib.dbmigrate.migrate.versioning.util.importpath import import_path
16 from rhodecode.lib.dbmigrate.migrate.versioning.util.importpath import import_path
@@ -28,7 +27,7 b' def load_model(dotted_name):'
28 .. versionchanged:: 0.5.4
27 .. versionchanged:: 0.5.4
29
28
30 """
29 """
31 if isinstance(dotted_name, compat.string_types):
30 if isinstance(dotted_name, str):
32 if ':' not in dotted_name:
31 if ':' not in dotted_name:
33 # backwards compatibility
32 # backwards compatibility
34 warnings.warn('model should be in form of module.model:User '
33 warnings.warn('model should be in form of module.model:User '
@@ -41,7 +40,7 b' def load_model(dotted_name):'
41
40
42 def asbool(obj):
41 def asbool(obj):
43 """Do everything to use object as bool"""
42 """Do everything to use object as bool"""
44 if isinstance(obj, compat.string_types):
43 if isinstance(obj, str):
45 obj = obj.strip().lower()
44 obj = obj.strip().lower()
46 if obj in ['true', 'yes', 'on', 'y', 't', '1']:
45 if obj in ['true', 'yes', 'on', 'y', 't', '1']:
47 return True
46 return True
@@ -114,7 +113,7 b' def construct_engine(engine, **opts):'
114 """
113 """
115 if isinstance(engine, Engine):
114 if isinstance(engine, Engine):
116 return engine
115 return engine
117 elif not isinstance(engine, compat.string_types):
116 elif not isinstance(engine, str):
118 raise ValueError("you need to pass either an existing engine or a database uri")
117 raise ValueError("you need to pass either an existing engine or a database uri")
119
118
120 # get options for create_engine
119 # get options for create_engine
@@ -28,7 +28,6 b' from sqlalchemy import *'
28 from sqlalchemy.ext.hybrid import hybrid_property
28 from sqlalchemy.ext.hybrid import hybrid_property
29 from sqlalchemy.orm import relationship, joinedload, class_mapper, validates
29 from sqlalchemy.orm import relationship, joinedload, class_mapper, validates
30 from beaker.cache import cache_region, region_invalidate
30 from beaker.cache import cache_region, region_invalidate
31 from pyramid import compat
32
31
33 from rhodecode.lib.vcs import get_backend
32 from rhodecode.lib.vcs import get_backend
34 from rhodecode.lib.vcs.utils.helpers import get_scm
33 from rhodecode.lib.vcs.utils.helpers import get_scm
@@ -414,7 +413,7 b' class UserGroup(Base, BaseModel):'
414 Session.flush()
413 Session.flush()
415 members_list = []
414 members_list = []
416 if v:
415 if v:
417 v = [v] if isinstance(v, compat.string_types) else v
416 v = [v] if isinstance(v, str) else v
418 for u_id in set(v):
417 for u_id in set(v):
419 member = UserGroupMember(users_group_id, u_id)
418 member = UserGroupMember(users_group_id, u_id)
420 members_list.append(member)
419 members_list.append(member)
@@ -49,7 +49,6 b' from sqlalchemy.exc import IntegrityErro'
49 from sqlalchemy.dialects.mysql import LONGTEXT
49 from sqlalchemy.dialects.mysql import LONGTEXT
50 from beaker.cache import cache_region
50 from beaker.cache import cache_region
51 from zope.cachedescriptors.property import Lazy as LazyProperty
51 from zope.cachedescriptors.property import Lazy as LazyProperty
52 from pyramid import compat
53 from pyramid.threadlocal import get_current_request
52 from pyramid.threadlocal import get_current_request
54
53
55 from rhodecode.translation import _
54 from rhodecode.translation import _
@@ -2110,7 +2109,7 b' class Repository(Base, BaseModel):'
2110 warnings.warn("Use get_commit", DeprecationWarning)
2109 warnings.warn("Use get_commit", DeprecationWarning)
2111 commit_id = None
2110 commit_id = None
2112 commit_idx = None
2111 commit_idx = None
2113 if isinstance(rev, compat.string_types):
2112 if isinstance(rev, str):
2114 commit_id = rev
2113 commit_id = rev
2115 else:
2114 else:
2116 commit_idx = rev
2115 commit_idx = rev
@@ -3725,7 +3724,7 b' class PullRequestReviewers(Base, BaseMod'
3725 @reasons.setter
3724 @reasons.setter
3726 def reasons(self, val):
3725 def reasons(self, val):
3727 val = val or []
3726 val = val or []
3728 if any(not isinstance(x, compat.string_types) for x in val):
3727 if any(not isinstance(x, str) for x in val):
3729 raise Exception('invalid reasons type, must be list of strings')
3728 raise Exception('invalid reasons type, must be list of strings')
3730 self._reasons = val
3729 self._reasons = val
3731
3730
@@ -49,7 +49,6 b' from sqlalchemy.exc import IntegrityErro'
49 from sqlalchemy.dialects.mysql import LONGTEXT
49 from sqlalchemy.dialects.mysql import LONGTEXT
50 from beaker.cache import cache_region
50 from beaker.cache import cache_region
51 from zope.cachedescriptors.property import Lazy as LazyProperty
51 from zope.cachedescriptors.property import Lazy as LazyProperty
52 from pyramid import compat
53 from pyramid.threadlocal import get_current_request
52 from pyramid.threadlocal import get_current_request
54
53
55 from rhodecode.translation import _
54 from rhodecode.translation import _
@@ -2176,7 +2175,7 b' class Repository(Base, BaseModel):'
2176 warnings.warn("Use get_commit", DeprecationWarning)
2175 warnings.warn("Use get_commit", DeprecationWarning)
2177 commit_id = None
2176 commit_id = None
2178 commit_idx = None
2177 commit_idx = None
2179 if isinstance(rev, compat.string_types):
2178 if isinstance(rev, str):
2180 commit_id = rev
2179 commit_id = rev
2181 else:
2180 else:
2182 commit_idx = rev
2181 commit_idx = rev
@@ -3808,7 +3807,7 b' class PullRequestReviewers(Base, BaseMod'
3808 @reasons.setter
3807 @reasons.setter
3809 def reasons(self, val):
3808 def reasons(self, val):
3810 val = val or []
3809 val = val or []
3811 if any(not isinstance(x, compat.string_types) for x in val):
3810 if any(not isinstance(x, str) for x in val):
3812 raise Exception('invalid reasons type, must be list of strings')
3811 raise Exception('invalid reasons type, must be list of strings')
3813 self._reasons = val
3812 self._reasons = val
3814
3813
@@ -48,7 +48,6 b' from sqlalchemy.ext.hybrid import hybrid'
48 from sqlalchemy.exc import IntegrityError # pragma: no cover
48 from sqlalchemy.exc import IntegrityError # pragma: no cover
49 from sqlalchemy.dialects.mysql import LONGTEXT
49 from sqlalchemy.dialects.mysql import LONGTEXT
50 from zope.cachedescriptors.property import Lazy as LazyProperty
50 from zope.cachedescriptors.property import Lazy as LazyProperty
51 from pyramid import compat
52 from pyramid.threadlocal import get_current_request
51 from pyramid.threadlocal import get_current_request
53
52
54 from rhodecode.translation import _
53 from rhodecode.translation import _
@@ -2217,7 +2216,7 b' class Repository(Base, BaseModel):'
2217 warnings.warn("Use get_commit", DeprecationWarning)
2216 warnings.warn("Use get_commit", DeprecationWarning)
2218 commit_id = None
2217 commit_id = None
2219 commit_idx = None
2218 commit_idx = None
2220 if isinstance(rev, compat.string_types):
2219 if isinstance(rev, str):
2221 commit_id = rev
2220 commit_id = rev
2222 else:
2221 else:
2223 commit_idx = rev
2222 commit_idx = rev
@@ -3956,7 +3955,7 b' class PullRequestReviewers(Base, BaseMod'
3956 @reasons.setter
3955 @reasons.setter
3957 def reasons(self, val):
3956 def reasons(self, val):
3958 val = val or []
3957 val = val or []
3959 if any(not isinstance(x, compat.string_types) for x in val):
3958 if any(not isinstance(x, str) for x in val):
3960 raise Exception('invalid reasons type, must be list of strings')
3959 raise Exception('invalid reasons type, must be list of strings')
3961 self._reasons = val
3960 self._reasons = val
3962
3961
@@ -48,7 +48,6 b' from sqlalchemy.ext.hybrid import hybrid'
48 from sqlalchemy.exc import IntegrityError # pragma: no cover
48 from sqlalchemy.exc import IntegrityError # pragma: no cover
49 from sqlalchemy.dialects.mysql import LONGTEXT
49 from sqlalchemy.dialects.mysql import LONGTEXT
50 from zope.cachedescriptors.property import Lazy as LazyProperty
50 from zope.cachedescriptors.property import Lazy as LazyProperty
51 from pyramid import compat
52 from pyramid.threadlocal import get_current_request
51 from pyramid.threadlocal import get_current_request
53
52
54 from rhodecode.translation import _
53 from rhodecode.translation import _
@@ -2240,7 +2239,7 b' class Repository(Base, BaseModel):'
2240 warnings.warn("Use get_commit", DeprecationWarning)
2239 warnings.warn("Use get_commit", DeprecationWarning)
2241 commit_id = None
2240 commit_id = None
2242 commit_idx = None
2241 commit_idx = None
2243 if isinstance(rev, compat.string_types):
2242 if isinstance(rev, str):
2244 commit_id = rev
2243 commit_id = rev
2245 else:
2244 else:
2246 commit_idx = rev
2245 commit_idx = rev
@@ -4030,7 +4029,7 b' class PullRequestReviewers(Base, BaseMod'
4030 @reasons.setter
4029 @reasons.setter
4031 def reasons(self, val):
4030 def reasons(self, val):
4032 val = val or []
4031 val = val or []
4033 if any(not isinstance(x, compat.string_types) for x in val):
4032 if any(not isinstance(x, str) for x in val):
4034 raise Exception('invalid reasons type, must be list of strings')
4033 raise Exception('invalid reasons type, must be list of strings')
4035 self._reasons = val
4034 self._reasons = val
4036
4035
@@ -48,7 +48,6 b' from sqlalchemy.ext.hybrid import hybrid'
48 from sqlalchemy.exc import IntegrityError # pragma: no cover
48 from sqlalchemy.exc import IntegrityError # pragma: no cover
49 from sqlalchemy.dialects.mysql import LONGTEXT
49 from sqlalchemy.dialects.mysql import LONGTEXT
50 from zope.cachedescriptors.property import Lazy as LazyProperty
50 from zope.cachedescriptors.property import Lazy as LazyProperty
51 from pyramid import compat
52 from pyramid.threadlocal import get_current_request
51 from pyramid.threadlocal import get_current_request
53
52
54 from rhodecode.translation import _
53 from rhodecode.translation import _
@@ -2240,7 +2239,7 b' class Repository(Base, BaseModel):'
2240 warnings.warn("Use get_commit", DeprecationWarning)
2239 warnings.warn("Use get_commit", DeprecationWarning)
2241 commit_id = None
2240 commit_id = None
2242 commit_idx = None
2241 commit_idx = None
2243 if isinstance(rev, compat.string_types):
2242 if isinstance(rev, str):
2244 commit_id = rev
2243 commit_id = rev
2245 else:
2244 else:
2246 commit_idx = rev
2245 commit_idx = rev
@@ -4031,7 +4030,7 b' class PullRequestReviewers(Base, BaseMod'
4031 @reasons.setter
4030 @reasons.setter
4032 def reasons(self, val):
4031 def reasons(self, val):
4033 val = val or []
4032 val = val or []
4034 if any(not isinstance(x, compat.string_types) for x in val):
4033 if any(not isinstance(x, str) for x in val):
4035 raise Exception('invalid reasons type, must be list of strings')
4034 raise Exception('invalid reasons type, must be list of strings')
4036 self._reasons = val
4035 self._reasons = val
4037
4036
@@ -50,7 +50,6 b' from sqlalchemy.ext.hybrid import hybrid'
50 from sqlalchemy.exc import IntegrityError # pragma: no cover
50 from sqlalchemy.exc import IntegrityError # pragma: no cover
51 from sqlalchemy.dialects.mysql import LONGTEXT
51 from sqlalchemy.dialects.mysql import LONGTEXT
52 from zope.cachedescriptors.property import Lazy as LazyProperty
52 from zope.cachedescriptors.property import Lazy as LazyProperty
53 from pyramid import compat
54 from pyramid.threadlocal import get_current_request
53 from pyramid.threadlocal import get_current_request
55 from webhelpers2.text import collapse, remove_formatting
54 from webhelpers2.text import collapse, remove_formatting
56
55
@@ -2281,7 +2280,7 b' class Repository(Base, BaseModel):'
2281 warnings.warn("Use get_commit", DeprecationWarning)
2280 warnings.warn("Use get_commit", DeprecationWarning)
2282 commit_id = None
2281 commit_id = None
2283 commit_idx = None
2282 commit_idx = None
2284 if isinstance(rev, compat.string_types):
2283 if isinstance(rev, str):
2285 commit_id = rev
2284 commit_id = rev
2286 else:
2285 else:
2287 commit_idx = rev
2286 commit_idx = rev
@@ -4276,7 +4275,7 b' class PullRequestReviewers(Base, BaseMod'
4276 @reasons.setter
4275 @reasons.setter
4277 def reasons(self, val):
4276 def reasons(self, val):
4278 val = val or []
4277 val = val or []
4279 if any(not isinstance(x, compat.string_types) for x in val):
4278 if any(not isinstance(x, str) for x in val):
4280 raise Exception('invalid reasons type, must be list of strings')
4279 raise Exception('invalid reasons type, must be list of strings')
4281 self._reasons = val
4280 self._reasons = val
4282
4281
@@ -50,7 +50,6 b' from sqlalchemy.ext.hybrid import hybrid'
50 from sqlalchemy.exc import IntegrityError # pragma: no cover
50 from sqlalchemy.exc import IntegrityError # pragma: no cover
51 from sqlalchemy.dialects.mysql import LONGTEXT
51 from sqlalchemy.dialects.mysql import LONGTEXT
52 from zope.cachedescriptors.property import Lazy as LazyProperty
52 from zope.cachedescriptors.property import Lazy as LazyProperty
53 from pyramid import compat
54 from pyramid.threadlocal import get_current_request
53 from pyramid.threadlocal import get_current_request
55 from webhelpers2.text import remove_formatting
54 from webhelpers2.text import remove_formatting
56
55
@@ -2348,7 +2347,7 b' class Repository(Base, BaseModel):'
2348 warnings.warn("Use get_commit", DeprecationWarning)
2347 warnings.warn("Use get_commit", DeprecationWarning)
2349 commit_id = None
2348 commit_id = None
2350 commit_idx = None
2349 commit_idx = None
2351 if isinstance(rev, compat.string_types):
2350 if isinstance(rev, str):
2352 commit_id = rev
2351 commit_id = rev
2353 else:
2352 else:
2354 commit_idx = rev
2353 commit_idx = rev
@@ -4391,7 +4390,7 b' class PullRequestReviewers(Base, BaseMod'
4391 @reasons.setter
4390 @reasons.setter
4392 def reasons(self, val):
4391 def reasons(self, val):
4393 val = val or []
4392 val = val or []
4394 if any(not isinstance(x, compat.string_types) for x in val):
4393 if any(not isinstance(x, str) for x in val):
4395 raise Exception('invalid reasons type, must be list of strings')
4394 raise Exception('invalid reasons type, must be list of strings')
4396 self._reasons = val
4395 self._reasons = val
4397
4396
@@ -50,7 +50,6 b' from sqlalchemy.ext.hybrid import hybrid'
50 from sqlalchemy.exc import IntegrityError # pragma: no cover
50 from sqlalchemy.exc import IntegrityError # pragma: no cover
51 from sqlalchemy.dialects.mysql import LONGTEXT
51 from sqlalchemy.dialects.mysql import LONGTEXT
52 from zope.cachedescriptors.property import Lazy as LazyProperty
52 from zope.cachedescriptors.property import Lazy as LazyProperty
53 from pyramid import compat
54 from pyramid.threadlocal import get_current_request
53 from pyramid.threadlocal import get_current_request
55 from webhelpers2.text import remove_formatting
54 from webhelpers2.text import remove_formatting
56
55
@@ -2354,7 +2353,7 b' class Repository(Base, BaseModel):'
2354 warnings.warn("Use get_commit", DeprecationWarning)
2353 warnings.warn("Use get_commit", DeprecationWarning)
2355 commit_id = None
2354 commit_id = None
2356 commit_idx = None
2355 commit_idx = None
2357 if isinstance(rev, compat.string_types):
2356 if isinstance(rev, str):
2358 commit_id = rev
2357 commit_id = rev
2359 else:
2358 else:
2360 commit_idx = rev
2359 commit_idx = rev
@@ -4440,7 +4439,7 b' class PullRequestReviewers(Base, BaseMod'
4440 @reasons.setter
4439 @reasons.setter
4441 def reasons(self, val):
4440 def reasons(self, val):
4442 val = val or []
4441 val = val or []
4443 if any(not isinstance(x, compat.string_types) for x in val):
4442 if any(not isinstance(x, str) for x in val):
4444 raise Exception('invalid reasons type, must be list of strings')
4443 raise Exception('invalid reasons type, must be list of strings')
4445 self._reasons = val
4444 self._reasons = val
4446
4445
@@ -50,7 +50,6 b' from sqlalchemy.ext.hybrid import hybrid'
50 from sqlalchemy.exc import IntegrityError # pragma: no cover
50 from sqlalchemy.exc import IntegrityError # pragma: no cover
51 from sqlalchemy.dialects.mysql import LONGTEXT
51 from sqlalchemy.dialects.mysql import LONGTEXT
52 from zope.cachedescriptors.property import Lazy as LazyProperty
52 from zope.cachedescriptors.property import Lazy as LazyProperty
53 from pyramid import compat
54 from pyramid.threadlocal import get_current_request
53 from pyramid.threadlocal import get_current_request
55 from webhelpers2.text import remove_formatting
54 from webhelpers2.text import remove_formatting
56
55
@@ -2385,7 +2384,7 b' class Repository(Base, BaseModel):'
2385 warnings.warn("Use get_commit", DeprecationWarning)
2384 warnings.warn("Use get_commit", DeprecationWarning)
2386 commit_id = None
2385 commit_id = None
2387 commit_idx = None
2386 commit_idx = None
2388 if isinstance(rev, compat.string_types):
2387 if isinstance(rev, str):
2389 commit_id = rev
2388 commit_id = rev
2390 else:
2389 else:
2391 commit_idx = rev
2390 commit_idx = rev
@@ -4502,7 +4501,7 b' class PullRequestReviewers(Base, BaseMod'
4502 @reasons.setter
4501 @reasons.setter
4503 def reasons(self, val):
4502 def reasons(self, val):
4504 val = val or []
4503 val = val or []
4505 if any(not isinstance(x, compat.string_types) for x in val):
4504 if any(not isinstance(x, str) for x in val):
4506 raise Exception('invalid reasons type, must be list of strings')
4505 raise Exception('invalid reasons type, must be list of strings')
4507 self._reasons = val
4506 self._reasons = val
4508
4507
@@ -44,7 +44,6 b' from sqlalchemy.sql.expression import tr'
44 from beaker.cache import cache_region, region_invalidate
44 from beaker.cache import cache_region, region_invalidate
45 from webob.exc import HTTPNotFound
45 from webob.exc import HTTPNotFound
46 from zope.cachedescriptors.property import Lazy as LazyProperty
46 from zope.cachedescriptors.property import Lazy as LazyProperty
47 from pyramid import compat
48
47
49 # replace pylons with fake url for migration
48 # replace pylons with fake url for migration
50 from rhodecode.lib.dbmigrate.schema import url
49 from rhodecode.lib.dbmigrate.schema import url
@@ -1811,7 +1810,7 b' class Repository(Base, BaseModel):'
1811 warnings.warn("Use get_commit", DeprecationWarning)
1810 warnings.warn("Use get_commit", DeprecationWarning)
1812 commit_id = None
1811 commit_id = None
1813 commit_idx = None
1812 commit_idx = None
1814 if isinstance(rev, compat.string_types):
1813 if isinstance(rev, str):
1815 commit_id = rev
1814 commit_id = rev
1816 else:
1815 else:
1817 commit_idx = rev
1816 commit_idx = rev
@@ -44,7 +44,6 b' from sqlalchemy.sql.expression import tr'
44 from beaker.cache import cache_region, region_invalidate
44 from beaker.cache import cache_region, region_invalidate
45 from webob.exc import HTTPNotFound
45 from webob.exc import HTTPNotFound
46 from zope.cachedescriptors.property import Lazy as LazyProperty
46 from zope.cachedescriptors.property import Lazy as LazyProperty
47 from pyramid import compat
48
47
49 # replace pylons with fake url for migration
48 # replace pylons with fake url for migration
50 from rhodecode.lib.dbmigrate.schema import url
49 from rhodecode.lib.dbmigrate.schema import url
@@ -1814,7 +1813,7 b' class Repository(Base, BaseModel):'
1814 warnings.warn("Use get_commit", DeprecationWarning)
1813 warnings.warn("Use get_commit", DeprecationWarning)
1815 commit_id = None
1814 commit_id = None
1816 commit_idx = None
1815 commit_idx = None
1817 if isinstance(rev, compat.string_types):
1816 if isinstance(rev, str):
1818 commit_id = rev
1817 commit_id = rev
1819 else:
1818 else:
1820 commit_idx = rev
1819 commit_idx = rev
@@ -44,7 +44,6 b' from sqlalchemy.sql.expression import tr'
44 from beaker.cache import cache_region, region_invalidate
44 from beaker.cache import cache_region, region_invalidate
45 from webob.exc import HTTPNotFound
45 from webob.exc import HTTPNotFound
46 from zope.cachedescriptors.property import Lazy as LazyProperty
46 from zope.cachedescriptors.property import Lazy as LazyProperty
47 from pyramid import compat
48 # replace pylons with fake url for migration
47 # replace pylons with fake url for migration
49 from rhodecode.lib.dbmigrate.schema import url
48 from rhodecode.lib.dbmigrate.schema import url
50 from rhodecode.translation import _
49 from rhodecode.translation import _
@@ -1813,7 +1812,7 b' class Repository(Base, BaseModel):'
1813 warnings.warn("Use get_commit", DeprecationWarning)
1812 warnings.warn("Use get_commit", DeprecationWarning)
1814 commit_id = None
1813 commit_id = None
1815 commit_idx = None
1814 commit_idx = None
1816 if isinstance(rev, compat.string_types):
1815 if isinstance(rev, str):
1817 commit_id = rev
1816 commit_id = rev
1818 else:
1817 else:
1819 commit_idx = rev
1818 commit_idx = rev
@@ -45,7 +45,6 b' from sqlalchemy.sql.expression import tr'
45 from beaker.cache import cache_region, region_invalidate
45 from beaker.cache import cache_region, region_invalidate
46 from webob.exc import HTTPNotFound
46 from webob.exc import HTTPNotFound
47 from zope.cachedescriptors.property import Lazy as LazyProperty
47 from zope.cachedescriptors.property import Lazy as LazyProperty
48 from pyramid import compat
49 # replace pylons with fake url for migration
48 # replace pylons with fake url for migration
50 from rhodecode.lib.dbmigrate.schema import url
49 from rhodecode.lib.dbmigrate.schema import url
51 from rhodecode.translation import _
50 from rhodecode.translation import _
@@ -1815,7 +1814,7 b' class Repository(Base, BaseModel):'
1815 warnings.warn("Use get_commit", DeprecationWarning)
1814 warnings.warn("Use get_commit", DeprecationWarning)
1816 commit_id = None
1815 commit_id = None
1817 commit_idx = None
1816 commit_idx = None
1818 if isinstance(rev, compat.string_types):
1817 if isinstance(rev, str):
1819 commit_id = rev
1818 commit_id = rev
1820 else:
1819 else:
1821 commit_idx = rev
1820 commit_idx = rev
@@ -45,7 +45,6 b' from sqlalchemy.sql.expression import tr'
45 from beaker.cache import cache_region, region_invalidate
45 from beaker.cache import cache_region, region_invalidate
46 from webob.exc import HTTPNotFound
46 from webob.exc import HTTPNotFound
47 from zope.cachedescriptors.property import Lazy as LazyProperty
47 from zope.cachedescriptors.property import Lazy as LazyProperty
48 from pyramid import compat
49 # replace pylons with fake url for migration
48 # replace pylons with fake url for migration
50 from rhodecode.lib.dbmigrate.schema import url
49 from rhodecode.lib.dbmigrate.schema import url
51 from rhodecode.translation import _
50 from rhodecode.translation import _
@@ -1815,7 +1814,7 b' class Repository(Base, BaseModel):'
1815 warnings.warn("Use get_commit", DeprecationWarning)
1814 warnings.warn("Use get_commit", DeprecationWarning)
1816 commit_id = None
1815 commit_id = None
1817 commit_idx = None
1816 commit_idx = None
1818 if isinstance(rev, compat.string_types):
1817 if isinstance(rev, str):
1819 commit_id = rev
1818 commit_id = rev
1820 else:
1819 else:
1821 commit_idx = rev
1820 commit_idx = rev
@@ -3178,7 +3177,7 b' class PullRequestReviewers(Base, BaseMod'
3178 @reasons.setter
3177 @reasons.setter
3179 def reasons(self, val):
3178 def reasons(self, val):
3180 val = val or []
3179 val = val or []
3181 if any(not isinstance(x, compat.string_types) for x in val):
3180 if any(not isinstance(x, str) for x in val):
3182 raise Exception('invalid reasons type, must be list of strings')
3181 raise Exception('invalid reasons type, must be list of strings')
3183 self._reasons = val
3182 self._reasons = val
3184
3183
@@ -43,7 +43,6 b' from sqlalchemy.sql.expression import tr'
43 from beaker.cache import cache_region
43 from beaker.cache import cache_region
44 from webob.exc import HTTPNotFound
44 from webob.exc import HTTPNotFound
45 from zope.cachedescriptors.property import Lazy as LazyProperty
45 from zope.cachedescriptors.property import Lazy as LazyProperty
46 from pyramid import compat
47
46
48 # replace pylons with fake url for migration
47 # replace pylons with fake url for migration
49 from rhodecode.lib.dbmigrate.schema import url
48 from rhodecode.lib.dbmigrate.schema import url
@@ -1858,7 +1857,7 b' class Repository(Base, BaseModel):'
1858 warnings.warn("Use get_commit", DeprecationWarning)
1857 warnings.warn("Use get_commit", DeprecationWarning)
1859 commit_id = None
1858 commit_id = None
1860 commit_idx = None
1859 commit_idx = None
1861 if isinstance(rev, compat.string_types):
1860 if isinstance(rev, str):
1862 commit_id = rev
1861 commit_id = rev
1863 else:
1862 else:
1864 commit_idx = rev
1863 commit_idx = rev
@@ -3406,7 +3405,7 b' class PullRequestReviewers(Base, BaseMod'
3406 @reasons.setter
3405 @reasons.setter
3407 def reasons(self, val):
3406 def reasons(self, val):
3408 val = val or []
3407 val = val or []
3409 if any(not isinstance(x, compat.string_types) for x in val):
3408 if any(not isinstance(x, str) for x in val):
3410 raise Exception('invalid reasons type, must be list of strings')
3409 raise Exception('invalid reasons type, must be list of strings')
3411 self._reasons = val
3410 self._reasons = val
3412
3411
@@ -43,7 +43,6 b' from sqlalchemy.sql.expression import tr'
43 from beaker.cache import cache_region
43 from beaker.cache import cache_region
44 from webob.exc import HTTPNotFound
44 from webob.exc import HTTPNotFound
45 from zope.cachedescriptors.property import Lazy as LazyProperty
45 from zope.cachedescriptors.property import Lazy as LazyProperty
46 from pyramid import compat
47
46
48 # replace pylons with fake url for migration
47 # replace pylons with fake url for migration
49 from rhodecode.lib.dbmigrate.schema import url
48 from rhodecode.lib.dbmigrate.schema import url
@@ -1859,7 +1858,7 b' class Repository(Base, BaseModel):'
1859 warnings.warn("Use get_commit", DeprecationWarning)
1858 warnings.warn("Use get_commit", DeprecationWarning)
1860 commit_id = None
1859 commit_id = None
1861 commit_idx = None
1860 commit_idx = None
1862 if isinstance(rev, compat.string_types):
1861 if isinstance(rev, str):
1863 commit_id = rev
1862 commit_id = rev
1864 else:
1863 else:
1865 commit_idx = rev
1864 commit_idx = rev
@@ -3407,7 +3406,7 b' class PullRequestReviewers(Base, BaseMod'
3407 @reasons.setter
3406 @reasons.setter
3408 def reasons(self, val):
3407 def reasons(self, val):
3409 val = val or []
3408 val = val or []
3410 if any(not isinstance(x, compat.string_types) for x in val):
3409 if any(not isinstance(x, str) for x in val):
3411 raise Exception('invalid reasons type, must be list of strings')
3410 raise Exception('invalid reasons type, must be list of strings')
3412 self._reasons = val
3411 self._reasons = val
3413
3412
@@ -43,7 +43,6 b' from sqlalchemy.sql.expression import tr'
43 from sqlalchemy.sql.functions import coalesce, count # pragma: no cover
43 from sqlalchemy.sql.functions import coalesce, count # pragma: no cover
44 from beaker.cache import cache_region
44 from beaker.cache import cache_region
45 from zope.cachedescriptors.property import Lazy as LazyProperty
45 from zope.cachedescriptors.property import Lazy as LazyProperty
46 from pyramid import compat
47 from pyramid.threadlocal import get_current_request
46 from pyramid.threadlocal import get_current_request
48
47
49 from rhodecode.translation import _
48 from rhodecode.translation import _
@@ -2046,7 +2045,7 b' class Repository(Base, BaseModel):'
2046 warnings.warn("Use get_commit", DeprecationWarning)
2045 warnings.warn("Use get_commit", DeprecationWarning)
2047 commit_id = None
2046 commit_id = None
2048 commit_idx = None
2047 commit_idx = None
2049 if isinstance(rev, compat.string_types):
2048 if isinstance(rev, str):
2050 commit_id = rev
2049 commit_id = rev
2051 else:
2050 else:
2052 commit_idx = rev
2051 commit_idx = rev
@@ -3660,7 +3659,7 b' class PullRequestReviewers(Base, BaseMod'
3660 @reasons.setter
3659 @reasons.setter
3661 def reasons(self, val):
3660 def reasons(self, val):
3662 val = val or []
3661 val = val or []
3663 if any(not isinstance(x, compat.string_types) for x in val):
3662 if any(not isinstance(x, str) for x in val):
3664 raise Exception('invalid reasons type, must be list of strings')
3663 raise Exception('invalid reasons type, must be list of strings')
3665 self._reasons = val
3664 self._reasons = val
3666
3665
@@ -2,7 +2,6 b' import logging'
2 import datetime
2 import datetime
3
3
4 from sqlalchemy import *
4 from sqlalchemy import *
5 from pyramid import compat
6
5
7 from rhodecode.lib.utils2 import safe_str
6 from rhodecode.lib.utils2 import safe_str
8 from rhodecode.model import meta
7 from rhodecode.model import meta
@@ -13,7 +12,7 b' log = logging.getLogger(__name__)'
13
12
14 def time_to_datetime(tm):
13 def time_to_datetime(tm):
15 if tm:
14 if tm:
16 if isinstance(tm, compat.string_types):
15 if isinstance(tm, str):
17 try:
16 try:
18 tm = float(tm)
17 tm = float(tm)
19 except ValueError:
18 except ValueError:
@@ -32,7 +32,6 b' import re'
32 import sys
32 import sys
33 import time
33 import time
34 import urllib
34 import urllib
35 from pyramid import compat
36
35
37
36
38 class diff_match_patch:
37 class diff_match_patch:
@@ -1439,7 +1438,7 b' class diff_match_patch:'
1439 text1 = None
1438 text1 = None
1440 diffs = None
1439 diffs = None
1441 # Note that texts may arrive as 'str' or 'unicode'.
1440 # Note that texts may arrive as 'str' or 'unicode'.
1442 if isinstance(a, compat.string_types) and isinstance(b, compat.string_types) and c is None:
1441 if isinstance(a, str) and isinstance(b, str) and c is None:
1443 # Method 1: text1, text2
1442 # Method 1: text1, text2
1444 # Compute diffs from text1 and text2.
1443 # Compute diffs from text1 and text2.
1445 text1 = a
1444 text1 = a
@@ -1452,11 +1451,11 b' class diff_match_patch:'
1452 # Compute text1 from diffs.
1451 # Compute text1 from diffs.
1453 diffs = a
1452 diffs = a
1454 text1 = self.diff_text1(diffs)
1453 text1 = self.diff_text1(diffs)
1455 elif isinstance(a, compat.string_types) and isinstance(b, list) and c is None:
1454 elif isinstance(a, str) and isinstance(b, list) and c is None:
1456 # Method 3: text1, diffs
1455 # Method 3: text1, diffs
1457 text1 = a
1456 text1 = a
1458 diffs = b
1457 diffs = b
1459 elif (isinstance(a, compat.string_types) and isinstance(b, compat.string_types) and
1458 elif (isinstance(a, str) and isinstance(b, str) and
1460 isinstance(c, list)):
1459 isinstance(c, list)):
1461 # Method 4: text1, text2, diffs
1460 # Method 4: text1, text2, diffs
1462 # text2 is not used.
1461 # text2 is not used.
@@ -47,7 +47,6 b' import itertools'
47 import fnmatch
47 import fnmatch
48 import bleach
48 import bleach
49
49
50 from pyramid import compat
51 from datetime import datetime
50 from datetime import datetime
52 from functools import partial
51 from functools import partial
53 from pygments.formatters.html import HtmlFormatter
52 from pygments.formatters.html import HtmlFormatter
@@ -190,7 +190,7 b' def get_default_cache_settings(settings,'
190 if key.startswith(prefix):
190 if key.startswith(prefix):
191 name = key.split(prefix)[1].strip()
191 name = key.split(prefix)[1].strip()
192 val = settings[key]
192 val = settings[key]
193 if isinstance(val, compat.string_types):
193 if isinstance(val, str):
194 val = val.strip()
194 val = val.strip()
195 cache_settings[name] = val
195 cache_settings[name] = val
196 return cache_settings
196 return cache_settings
@@ -48,7 +48,6 b' import sqlalchemy.exc'
48 import sqlalchemy.sql
48 import sqlalchemy.sql
49 import webob
49 import webob
50 import pyramid.threadlocal
50 import pyramid.threadlocal
51 from pyramid import compat
52 from pyramid.settings import asbool
51 from pyramid.settings import asbool
53
52
54 import rhodecode
53 import rhodecode
@@ -269,7 +268,7 b' def safe_str(unicode_, to_encoding=None,'
269 """
268 """
270
269
271 # if it's not basestr cast to str
270 # if it's not basestr cast to str
272 if not isinstance(unicode_, compat.string_types):
271 if not isinstance(unicode_, str):
273 return str(unicode_)
272 return str(unicode_)
274
273
275 if isinstance(unicode_, str):
274 if isinstance(unicode_, str):
@@ -712,7 +711,7 b' def datetime_to_time(dt):'
712
711
713 def time_to_datetime(tm):
712 def time_to_datetime(tm):
714 if tm:
713 if tm:
715 if isinstance(tm, compat.string_types):
714 if isinstance(tm, str):
716 try:
715 try:
717 tm = float(tm)
716 tm = float(tm)
718 except ValueError:
717 except ValueError:
@@ -722,7 +721,7 b' def time_to_datetime(tm):'
722
721
723 def time_to_utcdatetime(tm):
722 def time_to_utcdatetime(tm):
724 if tm:
723 if tm:
725 if isinstance(tm, compat.string_types):
724 if isinstance(tm, str):
726 try:
725 try:
727 tm = float(tm)
726 tm = float(tm)
728 except ValueError:
727 except ValueError:
@@ -34,7 +34,6 b' import warnings'
34
34
35 from zope.cachedescriptors.property import Lazy as LazyProperty
35 from zope.cachedescriptors.property import Lazy as LazyProperty
36
36
37 from pyramid import compat
38
37
39 import rhodecode
38 import rhodecode
40 from rhodecode.translation import lazy_ugettext
39 from rhodecode.translation import lazy_ugettext
@@ -785,7 +784,7 b' class BaseRepository(object):'
785 (commit, self, commit.repository))
784 (commit, self, commit.repository))
786
785
787 def _validate_commit_id(self, commit_id):
786 def _validate_commit_id(self, commit_id):
788 if not isinstance(commit_id, compat.string_types):
787 if not isinstance(commit_id, str):
789 raise TypeError("commit_id must be a string value got {} instead".format(type(commit_id)))
788 raise TypeError("commit_id must be a string value got {} instead".format(type(commit_id)))
790
789
791 def _validate_commit_idx(self, commit_idx):
790 def _validate_commit_idx(self, commit_idx):
@@ -822,7 +821,7 b' class BaseRepository(object):'
822 warnings.warn("Use get_commit instead", DeprecationWarning)
821 warnings.warn("Use get_commit instead", DeprecationWarning)
823 commit_id = None
822 commit_id = None
824 commit_idx = None
823 commit_idx = None
825 if isinstance(revision, compat.string_types):
824 if isinstance(revision, str):
826 commit_id = revision
825 commit_id = revision
827 else:
826 else:
828 commit_idx = revision
827 commit_idx = revision
@@ -849,7 +848,7 b' class BaseRepository(object):'
849 if revision is None:
848 if revision is None:
850 return revision
849 return revision
851
850
852 if isinstance(revision, compat.string_types):
851 if isinstance(revision, str):
853 commit_id = revision
852 commit_id = revision
854 else:
853 else:
855 commit_id = self.commit_ids[revision]
854 commit_id = self.commit_ids[revision]
@@ -25,7 +25,6 b' import logging'
25 import functools
25 import functools
26 import urllib2
26 import urllib2
27 import rhodecode
27 import rhodecode
28 from pyramid import compat
29
28
30 log = logging.getLogger(__name__)
29 log = logging.getLogger(__name__)
31
30
@@ -196,7 +195,7 b' def map_vcs_exceptions(func):'
196 org_remote_tb = getattr(e, '_vcs_server_org_exc_tb', '')
195 org_remote_tb = getattr(e, '_vcs_server_org_exc_tb', '')
197 __traceback_info__ = None
196 __traceback_info__ = None
198 if remote_tb:
197 if remote_tb:
199 if isinstance(remote_tb, compat.string_types):
198 if isinstance(remote_tb, str):
200 remote_tb = [remote_tb]
199 remote_tb = [remote_tb]
201 __traceback_info__ = (
200 __traceback_info__ = (
202 'Found VCSServer remote traceback information:\n'
201 'Found VCSServer remote traceback information:\n'
@@ -50,7 +50,6 b' from sqlalchemy.ext.hybrid import hybrid'
50 from sqlalchemy.exc import IntegrityError # pragma: no cover
50 from sqlalchemy.exc import IntegrityError # pragma: no cover
51 from sqlalchemy.dialects.mysql import LONGTEXT
51 from sqlalchemy.dialects.mysql import LONGTEXT
52 from zope.cachedescriptors.property import Lazy as LazyProperty
52 from zope.cachedescriptors.property import Lazy as LazyProperty
53 from pyramid import compat
54 from pyramid.threadlocal import get_current_request
53 from pyramid.threadlocal import get_current_request
55 from webhelpers2.text import remove_formatting
54 from webhelpers2.text import remove_formatting
56
55
@@ -2407,7 +2406,7 b' class Repository(Base, BaseModel):'
2407 warnings.warn("Use get_commit", DeprecationWarning)
2406 warnings.warn("Use get_commit", DeprecationWarning)
2408 commit_id = None
2407 commit_id = None
2409 commit_idx = None
2408 commit_idx = None
2410 if isinstance(rev, compat.string_types):
2409 if isinstance(rev, str):
2411 commit_id = rev
2410 commit_id = rev
2412 else:
2411 else:
2413 commit_idx = rev
2412 commit_idx = rev
@@ -4604,7 +4603,7 b' class PullRequestReviewers(Base, BaseMod'
4604 @reasons.setter
4603 @reasons.setter
4605 def reasons(self, val):
4604 def reasons(self, val):
4606 val = val or []
4605 val = val or []
4607 if any(not isinstance(x, compat.string_types) for x in val):
4606 if any(not isinstance(x, str) for x in val):
4608 raise Exception('invalid reasons type, must be list of strings')
4607 raise Exception('invalid reasons type, must be list of strings')
4609 self._reasons = val
4608 self._reasons = val
4610
4609
@@ -32,7 +32,6 b' import datetime'
32 import urllib
32 import urllib
33 import collections
33 import collections
34
34
35 from pyramid import compat
36 from pyramid.threadlocal import get_current_request
35 from pyramid.threadlocal import get_current_request
37
36
38 from rhodecode.lib.vcs.nodes import FileNode
37 from rhodecode.lib.vcs.nodes import FileNode
@@ -1426,7 +1425,7 b' class PullRequestModel(BaseModel):'
1426
1425
1427 reviewers = {}
1426 reviewers = {}
1428 for user_id, reasons, mandatory, role, rules in reviewer_data:
1427 for user_id, reasons, mandatory, role, rules in reviewer_data:
1429 if isinstance(user_id, (int, compat.string_types)):
1428 if isinstance(user_id, (int, str)):
1430 user_id = self._get_user(user_id).user_id
1429 user_id = self._get_user(user_id).user_id
1431 reviewers[user_id] = {
1430 reviewers[user_id] = {
1432 'reasons': reasons, 'mandatory': mandatory, 'role': role}
1431 'reasons': reasons, 'mandatory': mandatory, 'role': role}
@@ -1508,7 +1507,7 b' class PullRequestModel(BaseModel):'
1508
1507
1509 observers = {}
1508 observers = {}
1510 for user_id, reasons, mandatory, role, rules in observer_data:
1509 for user_id, reasons, mandatory, role, rules in observer_data:
1511 if isinstance(user_id, (int, compat.string_types)):
1510 if isinstance(user_id, (int, str)):
1512 user_id = self._get_user(user_id).user_id
1511 user_id = self._get_user(user_id).user_id
1513 observers[user_id] = {
1512 observers[user_id] = {
1514 'reasons': reasons, 'observers': mandatory, 'role': role}
1513 'reasons': reasons, 'observers': mandatory, 'role': role}
@@ -20,7 +20,6 b''
20
20
21 import logging
21 import logging
22 import traceback
22 import traceback
23 from pyramid import compat
24
23
25 from rhodecode.lib.utils2 import safe_str, safe_unicode
24 from rhodecode.lib.utils2 import safe_str, safe_unicode
26 from rhodecode.lib.exceptions import (
25 from rhodecode.lib.exceptions import (
@@ -248,7 +247,7 b' class UserGroupModel(BaseModel):'
248 # handle owner change
247 # handle owner change
249 if 'user' in form_data:
248 if 'user' in form_data:
250 owner = form_data['user']
249 owner = form_data['user']
251 if isinstance(owner, compat.string_types):
250 if isinstance(owner, str):
252 owner = User.get_by_username(form_data['user'])
251 owner = User.get_by_username(form_data['user'])
253
252
254 if not isinstance(owner, User):
253 if not isinstance(owner, User):
@@ -19,7 +19,6 b''
19 # and proprietary license terms, please see https://rhodecode.com/licenses/
19 # and proprietary license terms, please see https://rhodecode.com/licenses/
20
20
21 import unicodedata
21 import unicodedata
22 from pyramid import compat
23
22
24
23
25 def strip_preparer(value):
24 def strip_preparer(value):
@@ -84,6 +83,6 b' def unique_list_from_str_preparer(value)'
84 """
83 """
85 from rhodecode.lib.utils2 import aslist
84 from rhodecode.lib.utils2 import aslist
86
85
87 if isinstance(value, compat.string_types):
86 if isinstance(value, str):
88 value = aslist(value, ',')
87 value = aslist(value, ',')
89 return unique_list_preparer(value) No newline at end of file
88 return unique_list_preparer(value)
@@ -19,9 +19,7 b''
19 # and proprietary license terms, please see https://rhodecode.com/licenses/
19 # and proprietary license terms, please see https://rhodecode.com/licenses/
20
20
21 import re
21 import re
22
23 import colander
22 import colander
24 from pyramid import compat
25
23
26 from rhodecode.model.validation_schema import preparers
24 from rhodecode.model.validation_schema import preparers
27 from rhodecode.model.db import User, UserGroup
25 from rhodecode.model.db import User, UserGroup
@@ -108,7 +106,7 b' class StringBooleanType(colander.String)'
108 if isinstance(cstruct, bool):
106 if isinstance(cstruct, bool):
109 return cstruct
107 return cstruct
110
108
111 if not isinstance(cstruct, compat.string_types):
109 if not isinstance(cstruct, str):
112 raise colander.Invalid(node, '%r is not a string' % cstruct)
110 raise colander.Invalid(node, '%r is not a string' % cstruct)
113
111
114 value = cstruct.lower()
112 value = cstruct.lower()
@@ -192,7 +190,7 b' class UserGroupType(UserOrUserGroupType)'
192
190
193 class StrOrIntType(colander.String):
191 class StrOrIntType(colander.String):
194 def deserialize(self, node, cstruct):
192 def deserialize(self, node, cstruct):
195 if isinstance(cstruct, compat.string_types):
193 if isinstance(cstruct, str):
196 return super(StrOrIntType, self).deserialize(node, cstruct)
194 return super(StrOrIntType, self).deserialize(node, cstruct)
197 else:
195 else:
198 return colander.Integer().deserialize(node, cstruct)
196 return colander.Integer().deserialize(node, cstruct)
@@ -37,7 +37,6 b' from formencode.validators import ('
37
37
38 from sqlalchemy.sql.expression import true
38 from sqlalchemy.sql.expression import true
39 from sqlalchemy.util import OrderedSet
39 from sqlalchemy.util import OrderedSet
40 from pyramid import compat
41
40
42 from rhodecode.authentication import (
41 from rhodecode.authentication import (
43 legacy_plugin_prefix, _import_legacy_plugin)
42 legacy_plugin_prefix, _import_legacy_plugin)
@@ -126,7 +125,7 b' def UniqueListFromString(localizer):'
126
125
127 class _validator(UniqueList(localizer)):
126 class _validator(UniqueList(localizer)):
128 def _to_python(self, value, state):
127 def _to_python(self, value, state):
129 if isinstance(value, compat.string_types):
128 if isinstance(value, str):
130 value = aslist(value, ',')
129 value = aslist(value, ',')
131 return super(_validator, self)._to_python(value, state)
130 return super(_validator, self)._to_python(value, state)
132 return _validator
131 return _validator
@@ -19,7 +19,6 b''
19 # and proprietary license terms, please see https://rhodecode.com/licenses/
19 # and proprietary license terms, please see https://rhodecode.com/licenses/
20
20
21 import pytest
21 import pytest
22 from pyramid import compat
23
22
24 from rhodecode.config.utils import set_instance_id
23 from rhodecode.config.utils import set_instance_id
25
24
@@ -32,6 +31,6 b' def test_set_instance_id(instance_id):'
32 if instance_id == 'custom-id':
31 if instance_id == 'custom-id':
33 assert config['instance_id'] == instance_id
32 assert config['instance_id'] == instance_id
34 else:
33 else:
35 assert isinstance(config['instance_id'], compat.string_types)
34 assert isinstance(config['instance_id'], str)
36 assert len(config['instance_id'])
35 assert len(config['instance_id'])
37 assert instance_id != config['instance_id']
36 assert instance_id != config['instance_id']
@@ -35,7 +35,6 b' import os'
35 import sys
35 import sys
36 from os.path import join as jn
36 from os.path import join as jn
37 from os.path import dirname as dn
37 from os.path import dirname as dn
38 from pyramid import compat
39 from sqlalchemy.util import OrderedSet
38 from sqlalchemy.util import OrderedSet
40
39
41 __here__ = os.path.abspath(__file__)
40 __here__ = os.path.abspath(__file__)
@@ -77,7 +76,7 b' urllib2.install_opener(o)'
77
76
78
77
79 def _get_repo(proj):
78 def _get_repo(proj):
80 if isinstance(proj, compat.string_types):
79 if isinstance(proj, str):
81 repo = vcs.get_repo(jn(PROJECT_PATH, proj))
80 repo = vcs.get_repo(jn(PROJECT_PATH, proj))
82 proj = proj
81 proj = proj
83 else:
82 else:
General Comments 0
You need to be logged in to leave comments. Login now