py3: remove usage of basestring
dan -
r3425:d577b778 default
Not Reviewed
Show More
Add another comment
TODOs: 0 unresolved 0 Resolved
COMMENTS: 0 General 0 Inline
@@ -19,6 +19,7
19 19 # and proprietary license terms, please see https://rhodecode.com/licenses/
20 20
21 21 import logging
22 from pyramid import compat
22 23
23 24 from rhodecode.api import (
24 25 jsonrpc_method, JSONRPCError, JSONRPCForbidden, JSONRPCValidationError)
@@ -241,7 +242,7
241 242 # generate temporary password if user is external
242 243 password = PasswordGenerator().gen_password(length=16)
243 244 create_repo_group = Optional.extract(create_personal_repo_group)
244 if isinstance(create_repo_group, basestring):
245 if isinstance(create_repo_group, compat.string_types):
245 246 create_repo_group = str2bool(create_repo_group)
246 247
247 248 username = Optional.extract(username)
@@ -22,6 +22,7
22 22 import logging
23 23 import operator
24 24
25 from pyramid import compat
25 26 from pyramid.httpexceptions import HTTPFound, HTTPForbidden, HTTPBadRequest
26 27
27 28 from rhodecode.lib import helpers as h, diffs
@@ -395,7 +396,7
395 396 return draw, start, length
396 397
397 398 def _get_order_col(self, order_by, model):
398 if isinstance(order_by, basestring):
399 if isinstance(order_by, compat.string_types):
399 400 try:
400 401 return operator.attrgetter(order_by)(model)
401 402 except AttributeError:
@@ -17,10 +17,10
17 17 # This program is dual-licensed. If you wish to learn more about the
18 18 # RhodeCode Enterprise Edition, including its added features, Support services,
19 19 # and proprietary license terms, please see https://rhodecode.com/licenses/
20
20 import os
21 21 import logging
22 import os
23 22 import shlex
23 from pyramid import compat
24 24
25 25 # Do not use `from rhodecode import events` here, it will be overridden by the
26 26 # events module in this package due to pythons import mechanism.
@@ -85,6 +85,6
85 85 """
86 86 Append the path separator if missing.
87 87 """
88 if isinstance(path, basestring) and not path.endswith(os.path.sep):
88 if isinstance(path, compat.string_types) and not path.endswith(os.path.sep):
89 89 path += os.path.sep
90 90 return path
@@ -26,6 +26,7
26 26 import os
27 27 import time
28 28
29 from pyramid import compat
29 30 from pyramid_mailer.mailer import Mailer
30 31 from pyramid_mailer.message import Message
31 32
@@ -62,7 +63,7
62 63 subject = "%s %s" % (email_config.get('email_prefix', ''), subject)
63 64
64 65 if recipients:
65 if isinstance(recipients, basestring):
66 if isinstance(recipients, compat.string_types):
66 67 recipients = recipients.split(',')
67 68 else:
68 69 # if recipients are not defined we send to email_config + all admins
@@ -26,6 +26,7
26 26 from pygments.formatters.html import _get_ttype_class as pygment_token_class
27 27 from pygments.lexers.special import TextLexer, Token
28 28 from pygments.lexers import get_lexer_by_name
29 from pyramid import compat
29 30
30 31 from rhodecode.lib.helpers import (
31 32 get_lexer_for_filenode, html_escape, get_custom_lexer)
@@ -695,7 +696,7
695 696 filenode = None
696 697 filename = None
697 698
698 if isinstance(input_file, basestring):
699 if isinstance(input_file, compat.string_types):
699 700 filename = input_file
700 701 elif isinstance(input_file, FileNode):
701 702 filenode = input_file
@@ -18,13 +18,15
18 18 # RhodeCode Enterprise Edition, including its added features, Support services,
19 19 # and proprietary license terms, please see https://rhodecode.com/licenses/
20 20
21 from pyramid import compat
22
21 23
22 24 def strip_whitespace(value):
23 25 """
24 26 Removes leading/trailing whitespace, newlines, and tabs from the value.
25 27 Implements the `colander.interface.Preparer` interface.
26 28 """
27 if isinstance(value, basestring):
29 if isinstance(value, compat.string_types):
28 30 return value.strip(' \t\n\r')
29 31 else:
30 32 return value
@@ -9,6 +9,7
9 9
10 10 from sqlalchemy.schema import ForeignKeyConstraint
11 11 from sqlalchemy.schema import UniqueConstraint
12 from pyramid import compat
12 13
13 14 from rhodecode.lib.dbmigrate.migrate.exceptions import *
14 15 from rhodecode.lib.dbmigrate.migrate.changeset import SQLA_07, SQLA_08
@@ -229,7 +230,7
229 230 diffs = self.compare_1_column(*p, **kw)
230 231 else:
231 232 # Zero columns specified
232 if not len(p) or not isinstance(p[0], basestring):
233 if not len(p) or not isinstance(p[0], compat.string_types):
233 234 raise ValueError("First argument must be column name")
234 235 diffs = self.compare_parameters(*p, **kw)
235 236
@@ -338,7 +339,7
338 339 """Extracts data from p and modifies diffs"""
339 340 p = list(p)
340 341 while len(p):
341 if isinstance(p[0], basestring):
342 if isinstance(p[0], compat.string_types):
342 343 k.setdefault('name', p.pop(0))
343 344 elif isinstance(p[0], sqlalchemy.types.TypeEngine):
344 345 k.setdefault('type', p.pop(0))
@@ -376,7 +377,7
376 377 return getattr(self, '_table', None)
377 378
378 379 def _set_table(self, table):
379 if isinstance(table, basestring):
380 if isinstance(table, compat.string_types):
380 381 if self.alter_metadata:
381 382 if not self.meta:
382 383 raise ValueError("metadata must be specified for table"
@@ -593,7 +594,7
593 594 if isinstance(cons,(ForeignKeyConstraint,
594 595 UniqueConstraint)):
595 596 for col_name in cons.columns:
596 if not isinstance(col_name,basestring):
597 if not isinstance(col_name, compat.string_types):
597 598 col_name = col_name.name
598 599 if self.name==col_name:
599 600 to_drop.add(cons)
@@ -628,7 +629,7
628 629 if (getattr(self, name[:-5]) and not obj):
629 630 raise InvalidConstraintError("Column.create() accepts index_name,"
630 631 " primary_key_name and unique_name to generate constraints")
631 if not isinstance(obj, basestring) and obj is not None:
632 if not isinstance(obj, compat.string_types) and obj is not None:
632 633 raise InvalidConstraintError(
633 634 "%s argument for column must be constraint name" % name)
634 635
@@ -9,6 +9,7
9 9 from sqlalchemy.sql import and_
10 10 from sqlalchemy import exc as sa_exceptions
11 11 from sqlalchemy.sql import bindparam
12 from pyramid import compat
12 13
13 14 from rhodecode.lib.dbmigrate.migrate import exceptions
14 15 from rhodecode.lib.dbmigrate.migrate.changeset import SQLA_07
@@ -25,7 +26,7
25 26 """A database under version control"""
26 27
27 28 def __init__(self, engine, repository):
28 if isinstance(repository, basestring):
29 if isinstance(repository, compat.string_types):
29 30 repository = Repository(repository)
30 31 self.engine = engine
31 32 self.repository = repository
@@ -134,7 +135,7
134 135 """
135 136 # Confirm that the version # is valid: positive, integer,
136 137 # exists in repos
137 if isinstance(repository, basestring):
138 if isinstance(repository, compat.string_types):
138 139 repository = Repository(repository)
139 140 version = cls._validate_version(repository, version)
140 141 table = cls._create_table_version(engine, repository, version)
@@ -199,7 +200,7
199 200 """
200 201 Compare the current model against the current database.
201 202 """
202 if isinstance(repository, basestring):
203 if isinstance(repository, compat.string_types):
203 204 repository = Repository(repository)
204 205 model = load_model(model)
205 206
@@ -212,7 +213,7
212 213 """
213 214 Dump the current database as a Python model.
214 215 """
215 if isinstance(repository, basestring):
216 if isinstance(repository, compat.string_types):
216 217 repository = Repository(repository)
217 218
218 219 diff = schemadiff.getDiffOfModelAgainstDatabase(
@@ -7,6 +7,7
7 7 import inspect
8 8 from StringIO import StringIO
9 9
10 from pyramid import compat
10 11 from rhodecode.lib.dbmigrate import migrate
11 12 from rhodecode.lib.dbmigrate.migrate.versioning import genmodel, schemadiff
12 13 from rhodecode.lib.dbmigrate.migrate.versioning.config import operations
@@ -51,7 +52,7
51 52 :rtype: string
52 53 """
53 54
54 if isinstance(repository, basestring):
55 if isinstance(repository, compat.string_types):
55 56 # oh dear, an import cycle!
56 57 from rhodecode.lib.dbmigrate.migrate.versioning.repository import Repository
57 58 repository = Repository(repository)
@@ -11,6 +11,7
11 11 from sqlalchemy.engine import Engine
12 12 from sqlalchemy.pool import StaticPool
13 13
14 from pyramid import compat
14 15 from rhodecode.lib.dbmigrate.migrate import exceptions
15 16 from rhodecode.lib.dbmigrate.migrate.versioning.util.keyedinstance import KeyedInstance
16 17 from rhodecode.lib.dbmigrate.migrate.versioning.util.importpath import import_path
@@ -18,6 +19,7
18 19
19 20 log = logging.getLogger(__name__)
20 21
22
21 23 def load_model(dotted_name):
22 24 """Import module and use module-level variable".
23 25
@@ -26,7 +28,7
26 28 .. versionchanged:: 0.5.4
27 29
28 30 """
29 if isinstance(dotted_name, basestring):
31 if isinstance(dotted_name, compat.string_types):
30 32 if ':' not in dotted_name:
31 33 # backwards compatibility
32 34 warnings.warn('model should be in form of module.model:User '
@@ -39,7 +41,7
39 41
40 42 def asbool(obj):
41 43 """Do everything to use object as bool"""
42 if isinstance(obj, basestring):
44 if isinstance(obj, compat.string_types):
43 45 obj = obj.strip().lower()
44 46 if obj in ['true', 'yes', 'on', 'y', 't', '1']:
45 47 return True
@@ -112,7 +114,7
112 114 """
113 115 if isinstance(engine, Engine):
114 116 return engine
115 elif not isinstance(engine, basestring):
117 elif not isinstance(engine, compat.string_types):
116 118 raise ValueError("you need to pass either an existing engine or a database uri")
117 119
118 120 # get options for create_engine
@@ -28,6 +28,7
28 28 from sqlalchemy.ext.hybrid import hybrid_property
29 29 from sqlalchemy.orm import relationship, joinedload, class_mapper, validates
30 30 from beaker.cache import cache_region, region_invalidate
31 from pyramid import compat
31 32
32 33 from rhodecode.lib.vcs import get_backend
33 34 from rhodecode.lib.vcs.utils.helpers import get_scm
@@ -413,7 +414,7
413 414 Session.flush()
414 415 members_list = []
415 416 if v:
416 v = [v] if isinstance(v, basestring) else v
417 v = [v] if isinstance(v, compat.string_types) else v
417 418 for u_id in set(v):
418 419 member = UserGroupMember(users_group_id, u_id)
419 420 members_list.append(member)
@@ -49,7 +49,7
49 49 from sqlalchemy.dialects.mysql import LONGTEXT
50 50 from beaker.cache import cache_region
51 51 from zope.cachedescriptors.property import Lazy as LazyProperty
52
52 from pyramid import compat
53 53 from pyramid.threadlocal import get_current_request
54 54
55 55 from rhodecode.translation import _
@@ -2110,7 +2110,7
2110 2110 warnings.warn("Use get_commit", DeprecationWarning)
2111 2111 commit_id = None
2112 2112 commit_idx = None
2113 if isinstance(rev, basestring):
2113 if isinstance(rev, compat.string_types):
2114 2114 commit_id = rev
2115 2115 else:
2116 2116 commit_idx = rev
@@ -3726,7 +3726,7
3726 3726 @reasons.setter
3727 3727 def reasons(self, val):
3728 3728 val = val or []
3729 if any(not isinstance(x, basestring) for x in val):
3729 if any(not isinstance(x, compat.string_types) for x in val):
3730 3730 raise Exception('invalid reasons type, must be list of strings')
3731 3731 self._reasons = val
3732 3732
@@ -49,7 +49,7
49 49 from sqlalchemy.dialects.mysql import LONGTEXT
50 50 from beaker.cache import cache_region
51 51 from zope.cachedescriptors.property import Lazy as LazyProperty
52
52 from pyramid import compat
53 53 from pyramid.threadlocal import get_current_request
54 54
55 55 from rhodecode.translation import _
@@ -2176,7 +2176,7
2176 2176 warnings.warn("Use get_commit", DeprecationWarning)
2177 2177 commit_id = None
2178 2178 commit_idx = None
2179 if isinstance(rev, basestring):
2179 if isinstance(rev, compat.string_types):
2180 2180 commit_id = rev
2181 2181 else:
2182 2182 commit_idx = rev
@@ -3809,7 +3809,7
3809 3809 @reasons.setter
3810 3810 def reasons(self, val):
3811 3811 val = val or []
3812 if any(not isinstance(x, basestring) for x in val):
3812 if any(not isinstance(x, compat.string_types) for x in val):
3813 3813 raise Exception('invalid reasons type, must be list of strings')
3814 3814 self._reasons = val
3815 3815
@@ -48,7 +48,7
48 48 from sqlalchemy.exc import IntegrityError # pragma: no cover
49 49 from sqlalchemy.dialects.mysql import LONGTEXT
50 50 from zope.cachedescriptors.property import Lazy as LazyProperty
51
51 from pyramid import compat
52 52 from pyramid.threadlocal import get_current_request
53 53
54 54 from rhodecode.translation import _
@@ -2217,7 +2217,7
2217 2217 warnings.warn("Use get_commit", DeprecationWarning)
2218 2218 commit_id = None
2219 2219 commit_idx = None
2220 if isinstance(rev, basestring):
2220 if isinstance(rev, compat.string_types):
2221 2221 commit_id = rev
2222 2222 else:
2223 2223 commit_idx = rev
@@ -3957,7 +3957,7
3957 3957 @reasons.setter
3958 3958 def reasons(self, val):
3959 3959 val = val or []
3960 if any(not isinstance(x, basestring) for x in val):
3960 if any(not isinstance(x, compat.string_types) for x in val):
3961 3961 raise Exception('invalid reasons type, must be list of strings')
3962 3962 self._reasons = val
3963 3963
@@ -48,7 +48,7
48 48 from sqlalchemy.exc import IntegrityError # pragma: no cover
49 49 from sqlalchemy.dialects.mysql import LONGTEXT
50 50 from zope.cachedescriptors.property import Lazy as LazyProperty
51
51 from pyramid import compat
52 52 from pyramid.threadlocal import get_current_request
53 53
54 54 from rhodecode.translation import _
@@ -2240,7 +2240,7
2240 2240 warnings.warn("Use get_commit", DeprecationWarning)
2241 2241 commit_id = None
2242 2242 commit_idx = None
2243 if isinstance(rev, basestring):
2243 if isinstance(rev, compat.string_types):
2244 2244 commit_id = rev
2245 2245 else:
2246 2246 commit_idx = rev
@@ -4031,7 +4031,7
4031 4031 @reasons.setter
4032 4032 def reasons(self, val):
4033 4033 val = val or []
4034 if any(not isinstance(x, basestring) for x in val):
4034 if any(not isinstance(x, compat.string_types) for x in val):
4035 4035 raise Exception('invalid reasons type, must be list of strings')
4036 4036 self._reasons = val
4037 4037
@@ -34,7 +34,6
34 34 import traceback
35 35 import collections
36 36
37
38 37 from sqlalchemy import *
39 38 from sqlalchemy.exc import IntegrityError
40 39 from sqlalchemy.ext.declarative import declared_attr
@@ -45,6 +44,7
45 44 from beaker.cache import cache_region, region_invalidate
46 45 from webob.exc import HTTPNotFound
47 46 from zope.cachedescriptors.property import Lazy as LazyProperty
47 from pyramid import compat
48 48
49 49 # replace pylons with fake url for migration
50 50 from rhodecode.lib.dbmigrate.schema import url
@@ -1811,7 +1811,7
1811 1811 warnings.warn("Use get_commit", DeprecationWarning)
1812 1812 commit_id = None
1813 1813 commit_idx = None
1814 if isinstance(rev, basestring):
1814 if isinstance(rev, compat.string_types):
1815 1815 commit_id = rev
1816 1816 else:
1817 1817 commit_idx = rev
@@ -34,7 +34,6
34 34 import traceback
35 35 import collections
36 36
37
38 37 from sqlalchemy import *
39 38 from sqlalchemy.exc import IntegrityError
40 39 from sqlalchemy.ext.declarative import declared_attr
@@ -45,6 +44,7
45 44 from beaker.cache import cache_region, region_invalidate
46 45 from webob.exc import HTTPNotFound
47 46 from zope.cachedescriptors.property import Lazy as LazyProperty
47 from pyramid import compat
48 48
49 49 # replace pylons with fake url for migration
50 50 from rhodecode.lib.dbmigrate.schema import url
@@ -1814,7 +1814,7
1814 1814 warnings.warn("Use get_commit", DeprecationWarning)
1815 1815 commit_id = None
1816 1816 commit_idx = None
1817 if isinstance(rev, basestring):
1817 if isinstance(rev, compat.string_types):
1818 1818 commit_id = rev
1819 1819 else:
1820 1820 commit_idx = rev
@@ -34,7 +34,6
34 34 import traceback
35 35 import collections
36 36
37
38 37 from sqlalchemy import *
39 38 from sqlalchemy.exc import IntegrityError
40 39 from sqlalchemy.ext.declarative import declared_attr
@@ -45,7 +44,7
45 44 from beaker.cache import cache_region, region_invalidate
46 45 from webob.exc import HTTPNotFound
47 46 from zope.cachedescriptors.property import Lazy as LazyProperty
48
47 from pyramid import compat
49 48 # replace pylons with fake url for migration
50 49 from rhodecode.lib.dbmigrate.schema import url
51 50 from rhodecode.translation import _
@@ -1814,7 +1813,7
1814 1813 warnings.warn("Use get_commit", DeprecationWarning)
1815 1814 commit_id = None
1816 1815 commit_idx = None
1817 if isinstance(rev, basestring):
1816 if isinstance(rev, compat.string_types):
1818 1817 commit_id = rev
1819 1818 else:
1820 1819 commit_idx = rev
@@ -35,7 +35,6
35 35 import traceback
36 36 import collections
37 37
38
39 38 from sqlalchemy import *
40 39 from sqlalchemy.exc import IntegrityError
41 40 from sqlalchemy.ext.declarative import declared_attr
@@ -46,7 +45,7
46 45 from beaker.cache import cache_region, region_invalidate
47 46 from webob.exc import HTTPNotFound
48 47 from zope.cachedescriptors.property import Lazy as LazyProperty
49
48 from pyramid import compat
50 49 # replace pylons with fake url for migration
51 50 from rhodecode.lib.dbmigrate.schema import url
52 51 from rhodecode.translation import _
@@ -1816,7 +1815,7
1816 1815 warnings.warn("Use get_commit", DeprecationWarning)
1817 1816 commit_id = None
1818 1817 commit_idx = None
1819 if isinstance(rev, basestring):
1818 if isinstance(rev, compat.string_types):
1820 1819 commit_id = rev
1821 1820 else:
1822 1821 commit_idx = rev
@@ -35,7 +35,6
35 35 import traceback
36 36 import collections
37 37
38
39 38 from sqlalchemy import *
40 39 from sqlalchemy.exc import IntegrityError
41 40 from sqlalchemy.ext.declarative import declared_attr
@@ -46,7 +45,7
46 45 from beaker.cache import cache_region, region_invalidate
47 46 from webob.exc import HTTPNotFound
48 47 from zope.cachedescriptors.property import Lazy as LazyProperty
49
48 from pyramid import compat
50 49 # replace pylons with fake url for migration
51 50 from rhodecode.lib.dbmigrate.schema import url
52 51 from rhodecode.translation import _
@@ -1816,7 +1815,7
1816 1815 warnings.warn("Use get_commit", DeprecationWarning)
1817 1816 commit_id = None
1818 1817 commit_idx = None
1819 if isinstance(rev, basestring):
1818 if isinstance(rev, compat.string_types):
1820 1819 commit_id = rev
1821 1820 else:
1822 1821 commit_idx = rev
@@ -3180,7 +3179,7
3180 3179 @reasons.setter
3181 3180 def reasons(self, val):
3182 3181 val = val or []
3183 if any(not isinstance(x, basestring) for x in val):
3182 if any(not isinstance(x, compat.string_types) for x in val):
3184 3183 raise Exception('invalid reasons type, must be list of strings')
3185 3184 self._reasons = val
3186 3185
@@ -34,7 +34,6
34 34 import traceback
35 35 import collections
36 36
37
38 37 from sqlalchemy import *
39 38 from sqlalchemy.ext.declarative import declared_attr
40 39 from sqlalchemy.ext.hybrid import hybrid_property
@@ -44,6 +43,7
44 43 from beaker.cache import cache_region
45 44 from webob.exc import HTTPNotFound
46 45 from zope.cachedescriptors.property import Lazy as LazyProperty
46 from pyramid import compat
47 47
48 48 # replace pylons with fake url for migration
49 49 from rhodecode.lib.dbmigrate.schema import url
@@ -1858,7 +1858,7
1858 1858 warnings.warn("Use get_commit", DeprecationWarning)
1859 1859 commit_id = None
1860 1860 commit_idx = None
1861 if isinstance(rev, basestring):
1861 if isinstance(rev, compat.string_types):
1862 1862 commit_id = rev
1863 1863 else:
1864 1864 commit_idx = rev
@@ -3407,7 +3407,7
3407 3407 @reasons.setter
3408 3408 def reasons(self, val):
3409 3409 val = val or []
3410 if any(not isinstance(x, basestring) for x in val):
3410 if any(not isinstance(x, compat.string_types) for x in val):
3411 3411 raise Exception('invalid reasons type, must be list of strings')
3412 3412 self._reasons = val
3413 3413
@@ -34,7 +34,6
34 34 import traceback
35 35 import collections
36 36
37
38 37 from sqlalchemy import *
39 38 from sqlalchemy.ext.declarative import declared_attr
40 39 from sqlalchemy.ext.hybrid import hybrid_property
@@ -44,6 +43,7
44 43 from beaker.cache import cache_region
45 44 from webob.exc import HTTPNotFound
46 45 from zope.cachedescriptors.property import Lazy as LazyProperty
46 from pyramid import compat
47 47
48 48 # replace pylons with fake url for migration
49 49 from rhodecode.lib.dbmigrate.schema import url
@@ -1859,7 +1859,7
1859 1859 warnings.warn("Use get_commit", DeprecationWarning)
1860 1860 commit_id = None
1861 1861 commit_idx = None
1862 if isinstance(rev, basestring):
1862 if isinstance(rev, compat.string_types):
1863 1863 commit_id = rev
1864 1864 else:
1865 1865 commit_idx = rev
@@ -3408,7 +3408,7
3408 3408 @reasons.setter
3409 3409 def reasons(self, val):
3410 3410 val = val or []
3411 if any(not isinstance(x, basestring) for x in val):
3411 if any(not isinstance(x, compat.string_types) for x in val):
3412 3412 raise Exception('invalid reasons type, must be list of strings')
3413 3413 self._reasons = val
3414 3414
@@ -34,7 +34,6
34 34 import traceback
35 35 import collections
36 36
37
38 37 from sqlalchemy import *
39 38 from sqlalchemy.ext.declarative import declared_attr
40 39 from sqlalchemy.ext.hybrid import hybrid_property
@@ -44,7 +43,7
44 43 from sqlalchemy.sql.functions import coalesce, count # pragma: no cover
45 44 from beaker.cache import cache_region
46 45 from zope.cachedescriptors.property import Lazy as LazyProperty
47
46 from pyramid import compat
48 47 from pyramid.threadlocal import get_current_request
49 48
50 49 from rhodecode.translation import _
@@ -2047,7 +2046,7
2047 2046 warnings.warn("Use get_commit", DeprecationWarning)
2048 2047 commit_id = None
2049 2048 commit_idx = None
2050 if isinstance(rev, basestring):
2049 if isinstance(rev, compat.string_types):
2051 2050 commit_id = rev
2052 2051 else:
2053 2052 commit_idx = rev
@@ -3662,7 +3661,7
3662 3661 @reasons.setter
3663 3662 def reasons(self, val):
3664 3663 val = val or []
3665 if any(not isinstance(x, basestring) for x in val):
3664 if any(not isinstance(x, compat.string_types) for x in val):
3666 3665 raise Exception('invalid reasons type, must be list of strings')
3667 3666 self._reasons = val
3668 3667
@@ -2,6 +2,7
2 2 import datetime
3 3
4 4 from sqlalchemy import *
5 from pyramid import compat
5 6
6 7 from rhodecode.lib.utils2 import safe_str
7 8 from rhodecode.model import meta
@@ -12,7 +13,7
12 13
13 14 def time_to_datetime(tm):
14 15 if tm:
15 if isinstance(tm, basestring):
16 if isinstance(tm, compat.string_types):
16 17 try:
17 18 tm = float(tm)
18 19 except ValueError:
@@ -1,4 +1,3
1 #!/usr/bin/python2.4
2 1
3 2 from __future__ import division
4 3
@@ -33,6 +32,8
33 32 import sys
34 33 import time
35 34 import urllib
35 from pyramid import compat
36
36 37
37 38 class diff_match_patch:
38 39 """Class containing the diff, match and patch methods.
@@ -1438,7 +1439,7
1438 1439 text1 = None
1439 1440 diffs = None
1440 1441 # Note that texts may arrive as 'str' or 'unicode'.
1441 if isinstance(a, basestring) and isinstance(b, basestring) and c is None:
1442 if isinstance(a, compat.string_types) and isinstance(b, compat.string_types) and c is None:
1442 1443 # Method 1: text1, text2
1443 1444 # Compute diffs from text1 and text2.
1444 1445 text1 = a
@@ -1451,11 +1452,11
1451 1452 # Compute text1 from diffs.
1452 1453 diffs = a
1453 1454 text1 = self.diff_text1(diffs)
1454 elif isinstance(a, basestring) and isinstance(b, list) and c is None:
1455 elif isinstance(a, compat.string_types) and isinstance(b, list) and c is None:
1455 1456 # Method 3: text1, diffs
1456 1457 text1 = a
1457 1458 diffs = b
1458 elif (isinstance(a, basestring) and isinstance(b, basestring) and
1459 elif (isinstance(a, compat.string_types) and isinstance(b, compat.string_types) and
1459 1460 isinstance(c, list)):
1460 1461 # Method 4: text1, text2, diffs
1461 1462 # text2 is not used.
@@ -34,7 +34,6
34 34 import math
35 35 import logging
36 36 import re
37 import urlparse
38 37 import time
39 38 import string
40 39 import hashlib
@@ -45,6 +44,7
45 44 import fnmatch
46 45 import bleach
47 46
47 from pyramid import compat
48 48 from datetime import datetime
49 49 from functools import partial
50 50 from pygments.formatters.html import HtmlFormatter
@@ -120,7 +120,7
120 120 if key.startswith(prefix):
121 121 name = key.split(prefix)[1].strip()
122 122 val = settings[key]
123 if isinstance(val, basestring):
123 if isinstance(val, compat.string_types):
124 124 val = val.strip()
125 125 cache_settings[name] = val
126 126 return cache_settings
@@ -43,6 +43,7
43 43 import sqlalchemy.sql
44 44 import webob
45 45 import pyramid.threadlocal
46 from pyramid import compat
46 47 from pyramid.settings import asbool
47 48
48 49 import rhodecode
@@ -261,7 +262,7
261 262 """
262 263
263 264 # if it's not basestr cast to str
264 if not isinstance(unicode_, basestring):
265 if not isinstance(unicode_, compat.string_types):
265 266 return str(unicode_)
266 267
267 268 if isinstance(unicode_, str):
@@ -687,7 +688,7
687 688
688 689 def time_to_datetime(tm):
689 690 if tm:
690 if isinstance(tm, basestring):
691 if isinstance(tm, compat.string_types):
691 692 try:
692 693 tm = float(tm)
693 694 except ValueError:
@@ -697,7 +698,7
697 698
698 699 def time_to_utcdatetime(tm):
699 700 if tm:
700 if isinstance(tm, basestring):
701 if isinstance(tm, compat.string_types):
701 702 try:
702 703 tm = float(tm)
703 704 except ValueError:
@@ -33,6 +33,7
33 33 import warnings
34 34
35 35 from zope.cachedescriptors.property import Lazy as LazyProperty
36 from pyramid import compat
36 37
37 38 from rhodecode.translation import lazy_ugettext
38 39 from rhodecode.lib.utils2 import safe_str, safe_unicode
@@ -692,7 +693,7
692 693 (commit, self, commit.repository))
693 694
694 695 def _validate_commit_id(self, commit_id):
695 if not isinstance(commit_id, basestring):
696 if not isinstance(commit_id, compat.string_types):
696 697 raise TypeError("commit_id must be a string value")
697 698
698 699 def _validate_commit_idx(self, commit_idx):
@@ -729,7 +730,7
729 730 warnings.warn("Use get_commit instead", DeprecationWarning)
730 731 commit_id = None
731 732 commit_idx = None
732 if isinstance(revision, basestring):
733 if isinstance(revision, compat.string_types):
733 734 commit_id = revision
734 735 else:
735 736 commit_idx = revision
@@ -756,7 +757,7
756 757 if revision is None:
757 758 return revision
758 759
759 if isinstance(revision, basestring):
760 if isinstance(revision, compat.string_types):
760 761 commit_id = revision
761 762 else:
762 763 commit_id = self.commit_ids[revision]
@@ -25,6 +25,7
25 25 import functools
26 26 import urllib2
27 27 import rhodecode
28 from pyramid import compat
28 29
29 30 log = logging.getLogger(__name__)
30 31
@@ -191,7 +192,7
191 192 org_remote_tb = getattr(e, '_vcs_server_org_exc_tb', '')
192 193 __traceback_info__ = None
193 194 if remote_tb:
194 if isinstance(remote_tb, basestring):
195 if isinstance(remote_tb, compat.string_types):
195 196 remote_tb = [remote_tb]
196 197 __traceback_info__ = (
197 198 'Found VCSServer remote traceback information:\n'
@@ -48,7 +48,7
48 48 from sqlalchemy.exc import IntegrityError # pragma: no cover
49 49 from sqlalchemy.dialects.mysql import LONGTEXT
50 50 from zope.cachedescriptors.property import Lazy as LazyProperty
51
51 from pyramid import compat
52 52 from pyramid.threadlocal import get_current_request
53 53
54 54 from rhodecode.translation import _
@@ -2240,7 +2240,7
2240 2240 warnings.warn("Use get_commit", DeprecationWarning)
2241 2241 commit_id = None
2242 2242 commit_idx = None
2243 if isinstance(rev, basestring):
2243 if isinstance(rev, compat.string_types):
2244 2244 commit_id = rev
2245 2245 else:
2246 2246 commit_idx = rev
@@ -4031,7 +4031,7
4031 4031 @reasons.setter
4032 4032 def reasons(self, val):
4033 4033 val = val or []
4034 if any(not isinstance(x, basestring) for x in val):
4034 if any(