# HG changeset patch # User RhodeCode Admin # Date 2023-03-07 08:56:40 # Node ID 0d6cd34491e650e71feb43e391f40b83519402d4 # Parent 18be5f3a16f09bb6026471d4c9ded19b9fba4c15 python3: fixed usage of .next() and .func_name diff --git a/rhodecode/apps/admin/views/permissions.py b/rhodecode/apps/admin/views/permissions.py --- a/rhodecode/apps/admin/views/permissions.py +++ b/rhodecode/apps/admin/views/permissions.py @@ -348,7 +348,7 @@ class AdminPermissionsView(BaseAppView, if 'route_name' in intr and intr['attr']: view_intr[intr['route_name']] = '{}:{}'.format( - str(intr['derived_callable'].func_name), intr['attr'] + str(intr['derived_callable'].__name__), intr['attr'] ) c.whitelist_key = 'api_access_controllers_whitelist' diff --git a/rhodecode/authentication/registry.py b/rhodecode/authentication/registry.py --- a/rhodecode/authentication/registry.py +++ b/rhodecode/authentication/registry.py @@ -109,7 +109,7 @@ class AuthenticationPluginRegistry(objec plugins = _get_auth_plugins('rhodecode_auth_plugins', 'v1', self._fallback_plugin) compute_time = time.time() - start - log.debug('cached method:%s took %.4fs', _get_auth_plugins.func_name, compute_time) + log.debug('cached method:%s took %.4fs', _get_auth_plugins.__name__, compute_time) statsd = StatsdClient.statsd if statsd: diff --git a/rhodecode/config/rcextensions/utils.py b/rhodecode/config/rcextensions/utils.py --- a/rhodecode/config/rcextensions/utils.py +++ b/rhodecode/config/rcextensions/utils.py @@ -137,10 +137,10 @@ def has_kwargs(required_args): """ def wrap(func): def wrapper(*args, **kwargs): - _verify_kwargs(func.func_name, required_args.keys(), kwargs) + _verify_kwargs(func.__name__, required_args.keys(), kwargs) # in case there's `calls` defined on module we store the data - maybe_log_call(func.func_name, args, kwargs) - log.debug('Calling rcextensions function %s', func.func_name) + maybe_log_call(func.__name__, args, kwargs) + log.debug('Calling rcextensions function %s', func.__name__) return func(*args, **kwargs) return wrapper return wrap diff --git a/rhodecode/lib/_vendor/authomatic/six.py b/rhodecode/lib/_vendor/authomatic/six.py --- a/rhodecode/lib/_vendor/authomatic/six.py +++ b/rhodecode/lib/_vendor/authomatic/six.py @@ -505,7 +505,7 @@ try: advance_iterator = next except NameError: def advance_iterator(it): - return it.next() + return next(it) next = advance_iterator diff --git a/rhodecode/lib/helpers.py b/rhodecode/lib/helpers.py --- a/rhodecode/lib/helpers.py +++ b/rhodecode/lib/helpers.py @@ -615,7 +615,7 @@ def color_hasher(n=10000, saturation=0.1 if thing in color_dict: col = color_dict[thing] else: - col = color_dict[thing] = cgenerator.next() + col = color_dict[thing] = next(cgenerator) return "rgb(%s)" % (', '.join(col)) return get_color_string diff --git a/rhodecode/lib/middleware/simplevcs.py b/rhodecode/lib/middleware/simplevcs.py --- a/rhodecode/lib/middleware/simplevcs.py +++ b/rhodecode/lib/middleware/simplevcs.py @@ -98,7 +98,7 @@ def initialize_generator(factory): def wrapper(*args, **kwargs): gen = factory(*args, **kwargs) try: - init = gen.next() + init = next(gen) except StopIteration: raise ValueError('Generator must yield at least one element.') if init != "__init__": diff --git a/rhodecode/lib/vcs/client_http.py b/rhodecode/lib/vcs/client_http.py --- a/rhodecode/lib/vcs/client_http.py +++ b/rhodecode/lib/vcs/client_http.py @@ -388,12 +388,12 @@ class VcsHttpProxy(object): def _get_result(self, result): iterator = self._iterate(result) - error = iterator.next() + error = next(iterator) if error: self._deserialize_and_raise(error) - status = iterator.next() - headers = iterator.next() + status = next(iterator) + headers = next(iterator) return iterator, status, headers diff --git a/rhodecode/model/__init__.py b/rhodecode/model/__init__.py --- a/rhodecode/model/__init__.py +++ b/rhodecode/model/__init__.py @@ -85,7 +85,7 @@ class BaseModel(object): if instance: if callback is None: raise Exception( - 'given object must be int, long or Instance of %s ' + 'given object must be int or Instance of %s ' 'got %s, no callback provided' % (cls, type(instance)) ) else: diff --git a/rhodecode/model/db.py b/rhodecode/model/db.py --- a/rhodecode/model/db.py +++ b/rhodecode/model/db.py @@ -1907,7 +1907,7 @@ class Repository(Base, BaseModel): @classmethod def get_by_id_or_repo_name(cls, repoid): - if isinstance(repoid, (int, long)): + if isinstance(repoid, int): try: repo = cls.get(repoid) except ValueError: diff --git a/rhodecode/model/settings.py b/rhodecode/model/settings.py --- a/rhodecode/model/settings.py +++ b/rhodecode/model/settings.py @@ -253,7 +253,7 @@ class SettingsModel(BaseModel): start = time.time() result = _get_all_settings('rhodecode_settings', cache_key) compute_time = time.time() - start - log.debug('cached method:%s took %.4fs', _get_all_settings.func_name, compute_time) + log.debug('cached method:%s took %.4fs', _get_all_settings.__name__, compute_time) statsd = StatsdClient.statsd if statsd: diff --git a/rhodecode/tests/__init__.py b/rhodecode/tests/__init__.py --- a/rhodecode/tests/__init__.py +++ b/rhodecode/tests/__init__.py @@ -57,7 +57,7 @@ log = logging.getLogger(__name__) # SOME GLOBALS FOR TESTS TEST_DIR = tempfile.gettempdir() -TESTS_TMP_PATH = jn(TEST_DIR, 'rc_test_%s' % _RandomNameSequence().next()) +TESTS_TMP_PATH = jn(TEST_DIR, 'rc_test_{}'.format(next(_RandomNameSequence()))) TEST_USER_ADMIN_LOGIN = 'test_admin' TEST_USER_ADMIN_PASS = 'test12' TEST_USER_ADMIN_EMAIL = 'test_admin@mail.com' diff --git a/rhodecode/tests/scripts/test_concurency.py b/rhodecode/tests/scripts/test_concurency.py --- a/rhodecode/tests/scripts/test_concurency.py +++ b/rhodecode/tests/scripts/test_concurency.py @@ -146,7 +146,7 @@ def test_clone_with_credentials(repo=HG_ cwd = path = jn(TESTS_TMP_PATH, repo) if seq is None: - seq = _RandomNameSequence().next() + seq = next(_RandomNameSequence()) try: shutil.rmtree(path, ignore_errors=True) @@ -190,7 +190,7 @@ if __name__ == '__main__': backend = 'hg' if METHOD == 'pull': - seq = _RandomNameSequence().next() + seq = next(_RandomNameSequence()) test_clone_with_credentials(repo=sys.argv[1], method='clone', seq=seq, backend=backend) s = time.time() diff --git a/rhodecode/tests/vcs_operations/__init__.py b/rhodecode/tests/vcs_operations/__init__.py --- a/rhodecode/tests/vcs_operations/__init__.py +++ b/rhodecode/tests/vcs_operations/__init__.py @@ -83,7 +83,7 @@ def _add_files(vcs, dest, clone_url=None cwd = path = jn(dest) tags = tags or [] - added_file = jn(path, '%s_setup.py' % tempfile._RandomNameSequence().next()) + added_file = jn(path, '{}_setup.py'.format(next(tempfile._RandomNameSequence()))) Command(cwd).execute('touch %s' % added_file) Command(cwd).execute('%s add %s' % (vcs, added_file)) author_str = 'Marcin Kuźminski '