##// END OF EJS Templates
modernize: updates for python3
super-admin -
r5095:aa627a5f default
parent child Browse files
Show More
@@ -1,4 +1,3 b''
1
2 1 # Copyright (C) 2010-2023 RhodeCode GmbH
3 2 #
4 3 # This program is free software: you can redistribute it and/or modify
@@ -22,7 +21,7 b' import datetime'
22 21 import collections
23 22
24 23 now = datetime.datetime.now()
25 now = now.strftime("%Y-%m-%d %H:%M:%S") + '.' + "{:03d}".format(int(now.microsecond/1000))
24 now = now.strftime("%Y-%m-%d %H:%M:%S") + '.' + f"{int(now.microsecond/1000):03d}"
26 25
27 26 print(f'{now} Starting RhodeCode imports...')
28 27
@@ -355,7 +355,7 b' def setup_request(request):'
355 355 json_body = ext_json.json.loads(raw_body)
356 356 except ValueError as e:
357 357 # catch JSON errors Here
358 raise JSONRPCError("JSON parse error ERR:{} RAW:{!r}".format(e, raw_body))
358 raise JSONRPCError(f"JSON parse error ERR:{e} RAW:{raw_body!r}")
359 359
360 360 request.rpc_id = json_body.get('id')
361 361 request.rpc_method = json_body.get('method')
@@ -1,4 +1,3 b''
1
2 1 # Copyright (C) 2010-2023 RhodeCode GmbH
3 2 #
4 3 # This program is free software: you can redistribute it and/or modify
@@ -1,4 +1,3 b''
1
2 1 # Copyright (C) 2010-2023 RhodeCode GmbH
3 2 #
4 3 # This program is free software: you can redistribute it and/or modify
@@ -44,7 +43,7 b' def testuser_api(request, baseapp):'
44 43 # create TOKEN for user, if he doesn't have one
45 44 if not cls.test_user.api_key:
46 45 AuthTokenModel().create(
47 user=cls.test_user, description=u'TEST_USER_TOKEN')
46 user=cls.test_user, description='TEST_USER_TOKEN')
48 47
49 48 Session().commit()
50 49 cls.TEST_USER_LOGIN = cls.test_user.username
@@ -1,4 +1,3 b''
1
2 1 # Copyright (C) 2010-2023 RhodeCode GmbH
3 2 #
4 3 # This program is free software: you can redistribute it and/or modify
@@ -1,4 +1,3 b''
1
2 1 # Copyright (C) 2010-2023 RhodeCode GmbH
3 2 #
4 3 # This program is free software: you can redistribute it and/or modify
@@ -31,7 +30,7 b' class TestApi(object):'
31 30 def test_Optional_object(self):
32 31
33 32 option1 = Optional(None)
34 assert '<Optional:%s>' % (None,) == repr(option1)
33 assert '<Optional:{}>'.format(None) == repr(option1)
35 34 assert option1() is None
36 35
37 36 assert 1 == Optional.extract(Optional(1))
@@ -1,5 +1,3 b''
1
2
3 1 # Copyright (C) 2017-2023 RhodeCode GmbH
4 2 #
5 3 # This program is free software: you can redistribute it and/or modify
@@ -1,4 +1,3 b''
1
2 1 # Copyright (C) 2010-2023 RhodeCode GmbH
3 2 #
4 3 # This program is free software: you can redistribute it and/or modify
@@ -1,4 +1,3 b''
1
2 1 # Copyright (C) 2010-2023 RhodeCode GmbH
3 2 #
4 3 # This program is free software: you can redistribute it and/or modify
@@ -49,7 +49,7 b' def get_gist(request, apiuser, gistid, c'
49 49
50 50 if not has_superadmin_permission(apiuser):
51 51 if gist.gist_owner != apiuser.user_id:
52 raise JSONRPCError('gist `{}` does not exist'.format(gistid))
52 raise JSONRPCError(f'gist `{gistid}` does not exist')
53 53 data = gist.get_api_data()
54 54
55 55 if content:
@@ -240,13 +240,13 b' def delete_gist(request, apiuser, gistid'
240 240 gist = get_gist_or_error(gistid)
241 241 if not has_superadmin_permission(apiuser):
242 242 if gist.gist_owner != apiuser.user_id:
243 raise JSONRPCError('gist `{}` does not exist'.format(gistid))
243 raise JSONRPCError(f'gist `{gistid}` does not exist')
244 244
245 245 try:
246 246 GistModel().delete(gist)
247 247 Session().commit()
248 248 return {
249 'msg': 'deleted gist ID:{}'.format(gist.gist_access_id),
249 'msg': f'deleted gist ID:{gist.gist_access_id}',
250 250 'gist': None
251 251 }
252 252 except Exception:
@@ -527,7 +527,7 b' def comment_pull_request('
527 527
528 528 if not PullRequestModel().check_user_read(
529 529 pull_request, apiuser, api=True):
530 raise JSONRPCError('repository `{}` does not exist'.format(repoid))
530 raise JSONRPCError(f'repository `{repoid}` does not exist')
531 531 message = Optional.extract(message)
532 532 status = Optional.extract(status)
533 533 commit_id = Optional.extract(commit_id)
@@ -1082,7 +1082,7 b' def close_pull_request('
1082 1082
1083 1083 if pull_request.is_closed():
1084 1084 raise JSONRPCError(
1085 'pull request `{}` is already closed'.format(pullrequestid))
1085 f'pull request `{pullrequestid}` is already closed')
1086 1086
1087 1087 # only owner or admin or person with write permissions
1088 1088 allowed_to_close = PullRequestModel().check_user_update(
@@ -918,13 +918,13 b' def add_field_to_repo(request, apiuser, '
918 918 field_desc=description)
919 919 Session().commit()
920 920 return {
921 'msg': "Added new repository field `{}`".format(key),
921 'msg': f"Added new repository field `{key}`",
922 922 'success': True,
923 923 }
924 924 except Exception:
925 925 log.exception("Exception occurred while trying to add field to repo")
926 926 raise JSONRPCError(
927 'failed to create new field for repository `{}`'.format(repoid))
927 f'failed to create new field for repository `{repoid}`')
928 928
929 929
930 930 @jsonrpc_method()
@@ -957,14 +957,14 b' def remove_field_from_repo(request, apiu'
957 957 RepoModel().delete_repo_field(repo, field_key=key)
958 958 Session().commit()
959 959 return {
960 'msg': "Deleted repository field `{}`".format(key),
960 'msg': f"Deleted repository field `{key}`",
961 961 'success': True,
962 962 }
963 963 except Exception:
964 964 log.exception(
965 965 "Exception occurred while trying to delete field from repo")
966 966 raise JSONRPCError(
967 'failed to delete field for repository `{}`'.format(repoid))
967 f'failed to delete field for repository `{repoid}`')
968 968
969 969
970 970 @jsonrpc_method()
@@ -1130,7 +1130,7 b' def update_repo('
1130 1130 user=apiuser, repo=repo)
1131 1131 Session().commit()
1132 1132 return {
1133 'msg': 'updated repo ID:{} {}'.format(repo.repo_id, repo.repo_name),
1133 'msg': f'updated repo ID:{repo.repo_id} {repo.repo_name}',
1134 1134 'repository': repo.get_api_data(include_secrets=include_secrets)
1135 1135 }
1136 1136 except Exception:
@@ -1351,13 +1351,13 b' def delete_repo(request, apiuser, repoid'
1351 1351 ScmModel().mark_for_invalidation(repo_name, delete=True)
1352 1352 Session().commit()
1353 1353 return {
1354 'msg': 'Deleted repository `{}`{}'.format(repo_name, _forks_msg),
1354 'msg': f'Deleted repository `{repo_name}`{_forks_msg}',
1355 1355 'success': True
1356 1356 }
1357 1357 except Exception:
1358 1358 log.exception("Exception occurred while trying to delete repo")
1359 1359 raise JSONRPCError(
1360 'failed to delete repository `{}`'.format(repo_name)
1360 f'failed to delete repository `{repo_name}`'
1361 1361 )
1362 1362
1363 1363
@@ -1412,7 +1412,7 b' def invalidate_cache(request, apiuser, r'
1412 1412 try:
1413 1413 ScmModel().mark_for_invalidation(repo.repo_name, delete=delete)
1414 1414 return {
1415 'msg': 'Cache for repository `{}` was invalidated'.format(repoid),
1415 'msg': f'Cache for repository `{repoid}` was invalidated',
1416 1416 'repository': repo.repo_name
1417 1417 }
1418 1418 except Exception:
@@ -1706,7 +1706,7 b' def comment_commit('
1706 1706 except Exception:
1707 1707 log.exception("Exception occurred while trying to comment on commit")
1708 1708 raise JSONRPCError(
1709 'failed to set comment on repository `{}`'.format(repo.repo_name)
1709 f'failed to set comment on repository `{repo.repo_name}`'
1710 1710 )
1711 1711
1712 1712
@@ -1813,14 +1813,14 b' def get_comment(request, apiuser, commen'
1813 1813
1814 1814 comment = ChangesetComment.get(comment_id)
1815 1815 if not comment:
1816 raise JSONRPCError('comment `{}` does not exist'.format(comment_id))
1816 raise JSONRPCError(f'comment `{comment_id}` does not exist')
1817 1817
1818 1818 perms = ('repository.read', 'repository.write', 'repository.admin')
1819 1819 has_comment_perm = HasRepoPermissionAnyApi(*perms)\
1820 1820 (user=apiuser, repo_name=comment.repo.repo_name)
1821 1821
1822 1822 if not has_comment_perm:
1823 raise JSONRPCError('comment `{}` does not exist'.format(comment_id))
1823 raise JSONRPCError(f'comment `{comment_id}` does not exist')
1824 1824
1825 1825 return comment
1826 1826
@@ -1858,7 +1858,7 b' def edit_comment(request, apiuser, messa'
1858 1858 auth_user = apiuser
1859 1859 comment = ChangesetComment.get(comment_id)
1860 1860 if not comment:
1861 raise JSONRPCError('comment `{}` does not exist'.format(comment_id))
1861 raise JSONRPCError(f'comment `{comment_id}` does not exist')
1862 1862
1863 1863 is_super_admin = has_superadmin_permission(apiuser)
1864 1864 is_repo_admin = HasRepoPermissionAnyApi('repository.admin')\
@@ -2120,7 +2120,7 b' def grant_user_group_permission(request,'
2120 2120 if not HasUserGroupPermissionAnyApi(*_perms)(
2121 2121 user=apiuser, user_group_name=user_group.users_group_name):
2122 2122 raise JSONRPCError(
2123 'user group `{}` does not exist'.format(usergroupid))
2123 f'user group `{usergroupid}` does not exist')
2124 2124
2125 2125 perm_additions = [[user_group.users_group_id, perm.permission_name, "user_group"]]
2126 2126 try:
@@ -2194,7 +2194,7 b' def revoke_user_group_permission(request'
2194 2194 if not HasUserGroupPermissionAnyApi(*_perms)(
2195 2195 user=apiuser, user_group_name=user_group.users_group_name):
2196 2196 raise JSONRPCError(
2197 'user group `{}` does not exist'.format(usergroupid))
2197 f'user group `{usergroupid}` does not exist')
2198 2198
2199 2199 perm_deletions = [[user_group.users_group_id, None, "user_group"]]
2200 2200 try:
@@ -96,7 +96,7 b' def get_repo_group(request, apiuser, rep'
96 96 if not HasRepoGroupPermissionAnyApi(*_perms)(
97 97 user=apiuser, group_name=repo_group.group_name):
98 98 raise JSONRPCError(
99 'repository group `{}` does not exist'.format(repogroupid))
99 f'repository group `{repogroupid}` does not exist')
100 100
101 101 permissions = []
102 102 for _user in repo_group.permissions():
@@ -240,7 +240,7 b' def create_repo_group('
240 240 except Exception:
241 241 log.exception("Exception occurred while trying create repo group")
242 242 raise JSONRPCError(
243 'failed to create repo group `{}`'.format(validated_group_name))
243 f'failed to create repo group `{validated_group_name}`')
244 244
245 245
246 246 @jsonrpc_method()
@@ -627,7 +627,7 b' def grant_user_group_permission_to_repo_'
627 627 if not HasUserGroupPermissionAnyApi(*_perms)(
628 628 user=apiuser, user_group_name=user_group.users_group_name):
629 629 raise JSONRPCError(
630 'user group `{}` does not exist'.format(usergroupid))
630 f'user group `{usergroupid}` does not exist')
631 631
632 632 apply_to_children = Optional.extract(apply_to_children)
633 633
@@ -720,7 +720,7 b' def revoke_user_group_permission_from_re'
720 720 if not HasUserGroupPermissionAnyApi(*_perms)(
721 721 user=apiuser, user_group_name=user_group.users_group_name):
722 722 raise JSONRPCError(
723 'user group `{}` does not exist'.format(usergroupid))
723 f'user group `{usergroupid}` does not exist')
724 724
725 725 apply_to_children = Optional.extract(apply_to_children)
726 726
@@ -230,10 +230,10 b' def create_user(request, apiuser, userna'
230 230 raise JSONRPCForbidden()
231 231
232 232 if UserModel().get_by_username(username):
233 raise JSONRPCError("user `{}` already exist".format(username))
233 raise JSONRPCError(f"user `{username}` already exist")
234 234
235 235 if UserModel().get_by_email(email, case_insensitive=True):
236 raise JSONRPCError("email `{}` already exist".format(email))
236 raise JSONRPCError(f"email `{email}` already exist")
237 237
238 238 # generate random password if we actually given the
239 239 # extern_name and it's not rhodecode
@@ -303,7 +303,7 b' def create_user(request, apiuser, userna'
303 303 }
304 304 except Exception:
305 305 log.exception('Error occurred during creation of user')
306 raise JSONRPCError('failed to create user `{}`'.format(username))
306 raise JSONRPCError(f'failed to create user `{username}`')
307 307
308 308
309 309 @jsonrpc_method()
@@ -396,7 +396,7 b' def update_user(request, apiuser, userid'
396 396 user=apiuser)
397 397 Session().commit()
398 398 return {
399 'msg': 'updated user ID:{} {}'.format(user.user_id, user.username),
399 'msg': f'updated user ID:{user.user_id} {user.username}',
400 400 'user': user.get_api_data(include_secrets=True)
401 401 }
402 402 except DefaultUserException:
@@ -404,7 +404,7 b' def update_user(request, apiuser, userid'
404 404 raise JSONRPCError('editing default user is forbidden')
405 405 except Exception:
406 406 log.exception("Error occurred during update of user")
407 raise JSONRPCError('failed to update user `{}`'.format(userid))
407 raise JSONRPCError(f'failed to update user `{userid}`')
408 408
409 409
410 410 @jsonrpc_method()
@@ -465,13 +465,13 b' def delete_user(request, apiuser, userid'
465 465
466 466 Session().commit()
467 467 return {
468 'msg': 'deleted user ID:{} {}'.format(user.user_id, user.username),
468 'msg': f'deleted user ID:{user.user_id} {user.username}',
469 469 'user': None
470 470 }
471 471 except Exception:
472 472 log.exception("Error occurred during deleting of user")
473 473 raise JSONRPCError(
474 'failed to delete user ID:{} {}'.format(user.user_id, user.username))
474 f'failed to delete user ID:{user.user_id} {user.username}')
475 475
476 476
477 477 @jsonrpc_method()
@@ -224,7 +224,7 b' def create_user_group('
224 224 raise JSONRPCForbidden()
225 225
226 226 if UserGroupModel().get_by_name(group_name):
227 raise JSONRPCError("user group `{}` already exist".format(group_name))
227 raise JSONRPCError(f"user group `{group_name}` already exist")
228 228
229 229 if isinstance(owner, Optional):
230 230 owner = apiuser.user_id
@@ -277,7 +277,7 b' def create_user_group('
277 277 }
278 278 except Exception:
279 279 log.exception("Error occurred during creation of user group")
280 raise JSONRPCError('failed to create group `{}`'.format(group_name))
280 raise JSONRPCError(f'failed to create group `{group_name}`')
281 281
282 282
283 283 @jsonrpc_method()
@@ -339,7 +339,7 b' def update_user_group(request, apiuser, '
339 339 if not HasUserGroupPermissionAnyApi(*_perms)(
340 340 user=apiuser, user_group_name=user_group.users_group_name):
341 341 raise JSONRPCError(
342 'user group `{}` does not exist'.format(usergroupid))
342 f'user group `{usergroupid}` does not exist')
343 343 else:
344 344 include_secrets = True
345 345
@@ -380,7 +380,7 b' def update_user_group(request, apiuser, '
380 380 except Exception:
381 381 log.exception("Error occurred during update of user group")
382 382 raise JSONRPCError(
383 'failed to update user group `{}`'.format(usergroupid))
383 f'failed to update user group `{usergroupid}`')
384 384
385 385
386 386 @jsonrpc_method()
@@ -429,7 +429,7 b' def delete_user_group(request, apiuser, '
429 429 if not HasUserGroupPermissionAnyApi(*_perms)(
430 430 user=apiuser, user_group_name=user_group.users_group_name):
431 431 raise JSONRPCError(
432 'user group `{}` does not exist'.format(usergroupid))
432 f'user group `{usergroupid}` does not exist')
433 433
434 434 old_data = user_group.get_api_data()
435 435 try:
@@ -577,7 +577,7 b' def remove_user_from_user_group(request,'
577 577 if not HasUserGroupPermissionAnyApi(*_perms)(
578 578 user=apiuser, user_group_name=user_group.users_group_name):
579 579 raise JSONRPCError(
580 'user group `{}` does not exist'.format(usergroupid))
580 f'user group `{usergroupid}` does not exist')
581 581
582 582 old_values = user_group.get_api_data()
583 583 try:
@@ -639,7 +639,7 b' def grant_user_permission_to_user_group('
639 639 if not HasUserGroupPermissionAnyApi(*_perms)(
640 640 user=apiuser, user_group_name=user_group.users_group_name):
641 641 raise JSONRPCError(
642 'user group `{}` does not exist'.format(usergroupid))
642 f'user group `{usergroupid}` does not exist')
643 643
644 644 user = get_user_or_error(userid)
645 645 perm = get_perm_or_error(perm, prefix='usergroup.')
@@ -711,7 +711,7 b' def revoke_user_permission_from_user_gro'
711 711 if not HasUserGroupPermissionAnyApi(*_perms)(
712 712 user=apiuser, user_group_name=user_group.users_group_name):
713 713 raise JSONRPCError(
714 'user group `{}` does not exist'.format(usergroupid))
714 f'user group `{usergroupid}` does not exist')
715 715
716 716 user = get_user_or_error(userid)
717 717
@@ -782,14 +782,14 b' def grant_user_group_permission_to_user_'
782 782 user=apiuser,
783 783 user_group_name=target_user_group.users_group_name):
784 784 raise JSONRPCError(
785 'to user group `{}` does not exist'.format(usergroupid))
785 f'to user group `{usergroupid}` does not exist')
786 786
787 787 # check if we have at least read permission for source user group !
788 788 _perms = ('usergroup.read', 'usergroup.write', 'usergroup.admin',)
789 789 if not HasUserGroupPermissionAnyApi(*_perms)(
790 790 user=apiuser, user_group_name=user_group.users_group_name):
791 791 raise JSONRPCError(
792 'user group `{}` does not exist'.format(sourceusergroupid))
792 f'user group `{sourceusergroupid}` does not exist')
793 793
794 794 try:
795 795 changes = UserGroupModel().grant_user_group_permission(
@@ -862,7 +862,7 b' def revoke_user_group_permission_from_us'
862 862 user=apiuser,
863 863 user_group_name=target_user_group.users_group_name):
864 864 raise JSONRPCError(
865 'to user group `{}` does not exist'.format(usergroupid))
865 f'to user group `{usergroupid}` does not exist')
866 866
867 867 # check if we have at least read permission
868 868 # for the source user group !
@@ -870,7 +870,7 b' def revoke_user_group_permission_from_us'
870 870 if not HasUserGroupPermissionAnyApi(*_perms)(
871 871 user=apiuser, user_group_name=user_group.users_group_name):
872 872 raise JSONRPCError(
873 'user group `{}` does not exist'.format(sourceusergroupid))
873 f'user group `{sourceusergroupid}` does not exist')
874 874
875 875 try:
876 876 changes = UserGroupModel().revoke_user_group_permission(
@@ -92,7 +92,7 b' def _format_ref_id(name, raw_id):'
92 92
93 93 def _format_ref_id_svn(name, raw_id):
94 94 """Special way of formatting a reference for Subversion including path"""
95 return '{}@{}'.format(name, raw_id)
95 return f'{name}@{raw_id}'
96 96
97 97
98 98 class TemplateArgs(StrictAttributeDict):
@@ -1,5 +1,3 b''
1
2
3 1 # Copyright (C) 2016-2023 RhodeCode GmbH
4 2 #
5 3 # This program is free software: you can redistribute it and/or modify
@@ -1,5 +1,3 b''
1
2
3 1 # Copyright (C) 2016-2023 RhodeCode GmbH
4 2 #
5 3 # This program is free software: you can redistribute it and/or modify
@@ -258,7 +256,7 b' class UsersView(UserAppView):'
258 256
259 257 except Exception:
260 258 log.exception(
261 'Could not extend user plugins with `{}`'.format(extern_type))
259 f'Could not extend user plugins with `{extern_type}`')
262 260 return valid_plugins
263 261
264 262 def load_default_context(self):
@@ -758,18 +756,18 b' class UsersView(UserAppView):'
758 756 named_personal_group.personal = True
759 757 Session().add(named_personal_group)
760 758 Session().commit()
761 msg = _('Linked repository group `%s` as personal' % (
762 personal_repo_group_name,))
759 msg = _('Linked repository group `{}` as personal'.format(
760 personal_repo_group_name))
763 761 h.flash(msg, category='success')
764 762 elif not named_personal_group:
765 763 RepoGroupModel().create_personal_repo_group(c.user)
766 764
767 msg = _('Created repository group `%s`' % (
768 personal_repo_group_name,))
765 msg = _('Created repository group `{}`'.format(
766 personal_repo_group_name))
769 767 h.flash(msg, category='success')
770 768 else:
771 msg = _('Repository group `%s` is already taken' % (
772 personal_repo_group_name,))
769 msg = _('Repository group `{}` is already taken'.format(
770 personal_repo_group_name))
773 771 h.flash(msg, category='warning')
774 772 except Exception:
775 773 log.exception("Exception during repository group creation")
@@ -1296,7 +1294,7 b' class UsersView(UserAppView):'
1296 1294 c.active = 'caches'
1297 1295 c.perm_user = c.user.AuthUser(ip_addr=self.request.remote_addr)
1298 1296
1299 cache_namespace_uid = 'cache_user_auth.{}'.format(self.db_user.user_id)
1297 cache_namespace_uid = f'cache_user_auth.{self.db_user.user_id}'
1300 1298 c.region = rc_cache.get_or_create_region('cache_perms', cache_namespace_uid)
1301 1299 c.backend = c.region.backend
1302 1300 c.user_keys = sorted(c.region.backend.list_keys(prefix=cache_namespace_uid))
@@ -1314,7 +1312,7 b' class UsersView(UserAppView):'
1314 1312 c.active = 'caches'
1315 1313 c.perm_user = c.user.AuthUser(ip_addr=self.request.remote_addr)
1316 1314
1317 cache_namespace_uid = 'cache_user_auth.{}'.format(self.db_user.user_id)
1315 cache_namespace_uid = f'cache_user_auth.{self.db_user.user_id}'
1318 1316 del_keys = rc_cache.clear_cache_namespace('cache_perms', cache_namespace_uid)
1319 1317
1320 1318 h.flash(_("Deleted {} cache keys").format(del_keys), category='success')
@@ -1,4 +1,3 b''
1
2 1 # Copyright (C) 2010-2023 RhodeCode GmbH
3 2 #
4 3 # This program is free software: you can redistribute it and/or modify
@@ -1,4 +1,3 b''
1
2 1 # Copyright (C) 2010-2023 RhodeCode GmbH
3 2 #
4 3 # This program is free software: you can redistribute it and/or modify
@@ -115,7 +114,7 b' class ChannelstreamView(BaseAppView):'
115 114 self.channelstream_config, payload, '/connect')
116 115 except ChannelstreamConnectionException:
117 116 log.exception(
118 'Channelstream service at {} is down'.format(channelstream_url))
117 f'Channelstream service at {channelstream_url} is down')
119 118 return HTTPBadGateway()
120 119
121 120 channel_info = connect_result.get('channels_info')
@@ -167,7 +166,7 b' class ChannelstreamView(BaseAppView):'
167 166 self.channelstream_config, payload, '/subscribe')
168 167 except ChannelstreamConnectionException:
169 168 log.exception(
170 'Channelstream service at {} is down'.format(channelstream_url))
169 f'Channelstream service at {channelstream_url} is down')
171 170 return HTTPBadGateway()
172 171
173 172 channel_info = connect_result.get('channels_info')
@@ -1,5 +1,3 b''
1
2
3 1 # Copyright (C) 2016-2023 RhodeCode GmbH
4 2 #
5 3 # This program is free software: you can redistribute it and/or modify
@@ -1,5 +1,3 b''
1
2
3 1 # Copyright (C) 2016-2023 RhodeCode GmbH
4 2 #
5 3 # This program is free software: you can redistribute it and/or modify
@@ -1,5 +1,3 b''
1
2
3 1 # Copyright (C) 2016-2023 RhodeCode GmbH
4 2 #
5 3 # This program is free software: you can redistribute it and/or modify
@@ -107,7 +105,7 b' class LocalFileStorage(object):'
107 105 self.extensions = resolve_extensions([], groups=extension_groups)
108 106
109 107 def __repr__(self):
110 return '{}@{}'.format(self.__class__, self.base_path)
108 return f'{self.__class__}@{self.base_path}'
111 109
112 110 def store_path(self, filename):
113 111 """
@@ -1,5 +1,3 b''
1
2
3 1 # Copyright (C) 2016-2023 RhodeCode GmbH
4 2 #
5 3 # This program is free software: you can redistribute it and/or modify
@@ -1,5 +1,3 b''
1
2
3 1 # Copyright (C) 2016-2023 RhodeCode GmbH
4 2 #
5 3 # This program is free software: you can redistribute it and/or modify
@@ -1,5 +1,3 b''
1
2
3 1 # Copyright (C) 2016-2023 RhodeCode GmbH
4 2 #
5 3 # This program is free software: you can redistribute it and/or modify
@@ -57,7 +55,7 b' def resolve_extensions(extensions, group'
57 55 :param groups: additionally groups to extend the extensions.
58 56 """
59 57 groups = groups or []
60 valid_exts = set([x.lower() for x in extensions])
58 valid_exts = {x.lower() for x in extensions}
61 59
62 60 for group in groups:
63 61 if group in GROUPS:
@@ -1,5 +1,3 b''
1
2
3 1 # Copyright (C) 2016-2023 RhodeCode GmbH
4 2 #
5 3 # This program is free software: you can redistribute it and/or modify
@@ -1,4 +1,3 b''
1
2 1 # Copyright (C) 2010-2023 RhodeCode GmbH
3 2 #
4 3 # This program is free software: you can redistribute it and/or modify
@@ -102,9 +101,9 b' class TestFileStoreViews(TestController)'
102 101 status=200)
103 102
104 103 assert response.json == {
105 u'error': u'store_file data field is missing',
106 u'access_path': None,
107 u'store_fid': None}
104 'error': 'store_file data field is missing',
105 'access_path': None,
106 'store_fid': None}
108 107
109 108 def test_upload_files_bogus_content_to_store(self):
110 109 self.log_user()
@@ -114,9 +113,9 b' class TestFileStoreViews(TestController)'
114 113 status=200)
115 114
116 115 assert response.json == {
117 u'error': u'filename cannot be read from the data field',
118 u'access_path': None,
119 u'store_fid': None}
116 'error': 'filename cannot be read from the data field',
117 'access_path': None,
118 'store_fid': None}
120 119
121 120 def test_upload_content_to_store(self):
122 121 self.log_user()
@@ -1,5 +1,3 b''
1
2
3 1 # Copyright (C) 2016-2023 RhodeCode GmbH
4 2 #
5 3 # This program is free software: you can redistribute it and/or modify
@@ -1,5 +1,3 b''
1
2
3 1 # Copyright (C) 2016-2023 RhodeCode GmbH
4 2 #
5 3 # This program is free software: you can redistribute it and/or modify
@@ -118,7 +116,7 b' class FileStoreView(BaseAppView):'
118 116 file_name = db_obj.file_display_name
119 117
120 118 response.headers["Content-Disposition"] = (
121 'attachment; filename="{}"'.format(str(file_name))
119 f'attachment; filename="{str(file_name)}"'
122 120 )
123 121 response.headers["X-RC-Artifact-Id"] = str(db_obj.file_store_id)
124 122 response.headers["X-RC-Artifact-Desc"] = str(db_obj.file_description)
@@ -135,7 +133,7 b' class FileStoreView(BaseAppView):'
135 133 if file_obj is None:
136 134 return {'store_fid': None,
137 135 'access_path': None,
138 'error': '{} data field is missing'.format(self.upload_key)}
136 'error': f'{self.upload_key} data field is missing'}
139 137
140 138 if not hasattr(file_obj, 'filename'):
141 139 return {'store_fid': None,
@@ -154,18 +152,18 b' class FileStoreView(BaseAppView):'
154 152 except FileNotAllowedException:
155 153 return {'store_fid': None,
156 154 'access_path': None,
157 'error': 'File {} is not allowed.'.format(filename)}
155 'error': f'File {filename} is not allowed.'}
158 156
159 157 except FileOverSizeException:
160 158 return {'store_fid': None,
161 159 'access_path': None,
162 'error': 'File {} is exceeding allowed limit.'.format(filename)}
160 'error': f'File {filename} is exceeding allowed limit.'}
163 161
164 162 try:
165 163 entry = FileStore.create(
166 164 file_uid=store_uid, filename=metadata["filename"],
167 165 file_hash=metadata["sha256"], file_size=metadata["size"],
168 file_description=u'upload attachment',
166 file_description='upload attachment',
169 167 check_acl=False, user_id=self._rhodecode_user.user_id
170 168 )
171 169 Session().add(entry)
@@ -175,7 +173,7 b' class FileStoreView(BaseAppView):'
175 173 log.exception('Failed to store file %s', filename)
176 174 return {'store_fid': None,
177 175 'access_path': None,
178 'error': 'File {} failed to store in DB.'.format(filename)}
176 'error': f'File {filename} failed to store in DB.'}
179 177
180 178 return {'store_fid': store_uid,
181 179 'access_path': h.route_path('download_file', fid=store_uid)}
@@ -1,5 +1,3 b''
1
2
3 1 # Copyright (C) 2016-2023 RhodeCode GmbH
4 2 #
5 3 # This program is free software: you can redistribute it and/or modify
@@ -1,5 +1,3 b''
1
2
3 1 # Copyright (C) 2016-2023 RhodeCode GmbH
4 2 #
5 3 # This program is free software: you can redistribute it and/or modify
@@ -1,4 +1,3 b''
1
2 1 # Copyright (C) 2010-2023 RhodeCode GmbH
3 2 #
4 3 # This program is free software: you can redistribute it and/or modify
@@ -1,5 +1,3 b''
1
2
3 1 # Copyright (C) 2013-2023 RhodeCode GmbH
4 2 #
5 3 # This program is free software: you can redistribute it and/or modify
@@ -1,5 +1,3 b''
1
2
3 1 # Copyright (C) 2016-2023 RhodeCode GmbH
4 2 #
5 3 # This program is free software: you can redistribute it and/or modify
@@ -1,5 +1,3 b''
1
2
3 1 # Copyright (C) 2016-2023 RhodeCode GmbH
4 2 #
5 3 # This program is free software: you can redistribute it and/or modify
@@ -1,5 +1,3 b''
1
2
3 1 # Copyright (C) 2016-2023 RhodeCode GmbH
4 2 #
5 3 # This program is free software: you can redistribute it and/or modify
@@ -1,5 +1,3 b''
1
2
3 1 # Copyright (C) 2016-2023 RhodeCode GmbH
4 2 #
5 3 # This program is free software: you can redistribute it and/or modify
@@ -1,5 +1,3 b''
1
2
3 1 # Copyright (C) 2016-2023 RhodeCode GmbH
4 2 #
5 3 # This program is free software: you can redistribute it and/or modify
@@ -1,5 +1,3 b''
1
2
3 1 # Copyright (C) 2016-2023 RhodeCode GmbH
4 2 #
5 3 # This program is free software: you can redistribute it and/or modify
@@ -1,4 +1,3 b''
1
2 1 # Copyright (C) 2010-2023 RhodeCode GmbH
3 2 #
4 3 # This program is free software: you can redistribute it and/or modify
@@ -1,5 +1,3 b''
1
2
3 1 # Copyright (C) 2016-2023 RhodeCode GmbH
4 2 #
5 3 # This program is free software: you can redistribute it and/or modify
@@ -129,7 +127,7 b' class HomeView(BaseAppView, DataGridAppV'
129 127 query = query.filter(Repository.repo_type == repo_type)
130 128
131 129 if name_contains:
132 ilike_expression = '%{}%'.format(safe_str(name_contains))
130 ilike_expression = f'%{safe_str(name_contains)}%'
133 131 query = query.filter(
134 132 Repository.repo_name.ilike(ilike_expression))
135 133 query = query.limit(limit)
@@ -174,7 +172,7 b' class HomeView(BaseAppView, DataGridAppV'
174 172 query = query.order_by(RepoGroup.group_name)
175 173
176 174 if name_contains:
177 ilike_expression = u'%{}%'.format(safe_str(name_contains))
175 ilike_expression = f'%{safe_str(name_contains)}%'
178 176 query = query.filter(
179 177 RepoGroup.group_name.ilike(ilike_expression))
180 178 query = query.limit(limit)
@@ -216,7 +214,7 b' class HomeView(BaseAppView, DataGridAppV'
216 214 .filter(User.username != User.DEFAULT_USER)
217 215
218 216 if name_contains:
219 ilike_expression = u'%{}%'.format(safe_str(name_contains))
217 ilike_expression = f'%{safe_str(name_contains)}%'
220 218 query = query.filter(
221 219 User.username.ilike(ilike_expression))
222 220 query = query.limit(limit)
@@ -227,7 +225,7 b' class HomeView(BaseAppView, DataGridAppV'
227 225 {
228 226 'id': obj.user_id,
229 227 'value': org_query,
230 'value_display': 'user: `{}`'.format(obj.username),
228 'value_display': f'user: `{obj.username}`',
231 229 'type': 'user',
232 230 'icon_link': h.gravatar_url(obj.email, 30, request=self.request),
233 231 'url': h.route_path(
@@ -256,7 +254,7 b' class HomeView(BaseAppView, DataGridAppV'
256 254 .order_by(UserGroup.users_group_name)
257 255
258 256 if name_contains:
259 ilike_expression = u'%{}%'.format(safe_str(name_contains))
257 ilike_expression = f'%{safe_str(name_contains)}%'
260 258 query = query.filter(
261 259 UserGroup.users_group_name.ilike(ilike_expression))
262 260 query = query.limit(limit)
@@ -267,7 +265,7 b' class HomeView(BaseAppView, DataGridAppV'
267 265 {
268 266 'id': obj.users_group_id,
269 267 'value': org_query,
270 'value_display': 'user_group: `{}`'.format(obj.users_group_name),
268 'value_display': f'user_group: `{obj.users_group_name}`',
271 269 'type': 'user_group',
272 270 'url': h.route_path(
273 271 'user_group_profile', user_group_name=obj.users_group_name)
@@ -308,7 +306,7 b' class HomeView(BaseAppView, DataGridAppV'
308 306 query = query.order_by(PullRequest.pull_request_id)
309 307
310 308 if name_contains:
311 ilike_expression = u'%{}%'.format(safe_str(name_contains))
309 ilike_expression = f'%{safe_str(name_contains)}%'
312 310 query = query.filter(or_(
313 311 cast(PullRequest.pull_request_id, String).ilike(ilike_expression),
314 312 PullRequest.title.ilike(ilike_expression),
@@ -349,7 +347,7 b' class HomeView(BaseAppView, DataGridAppV'
349 347 commit_hash = commit_hashes[0]
350 348
351 349 result = searcher.search(
352 'commit_id:{}*'.format(commit_hash), 'commit', auth_user,
350 f'commit_id:{commit_hash}*', 'commit', auth_user,
353 351 repo_name, repo_group_name, raise_on_exc=False)
354 352
355 353 commits = []
@@ -396,7 +394,7 b' class HomeView(BaseAppView, DataGridAppV'
396 394
397 395 search_path = searcher.escape_specials(file_path)
398 396 result = searcher.search(
399 'file.raw:*{}*'.format(search_path), 'path', auth_user,
397 f'file.raw:*{search_path}*', 'path', auth_user,
400 398 repo_name, repo_group_name, raise_on_exc=False)
401 399
402 400 files = []
@@ -495,7 +493,7 b' class HomeView(BaseAppView, DataGridAppV'
495 493 qry = query
496 494 return {'q': qry, 'type': 'content'}
497 495
498 label = u'File content search for `{}`'.format(h.escape(query))
496 label = f'File content search for `{h.escape(query)}`'
499 497 file_qry = {
500 498 'id': -10,
501 499 'value': query,
@@ -513,7 +511,7 b' class HomeView(BaseAppView, DataGridAppV'
513 511 qry = query
514 512 return {'q': qry, 'type': 'commit'}
515 513
516 label = u'Commit search for `{}`'.format(h.escape(query))
514 label = f'Commit search for `{h.escape(query)}`'
517 515 commit_qry = {
518 516 'id': -20,
519 517 'value': query,
@@ -539,7 +537,7 b' class HomeView(BaseAppView, DataGridAppV'
539 537 qry = query
540 538 return {'q': qry, 'type': 'content'}
541 539
542 label = u'File content search for `{}`'.format(query)
540 label = f'File content search for `{query}`'
543 541 file_qry = {
544 542 'id': -30,
545 543 'value': query,
@@ -557,7 +555,7 b' class HomeView(BaseAppView, DataGridAppV'
557 555 qry = query
558 556 return {'q': qry, 'type': 'commit'}
559 557
560 label = u'Commit search for `{}`'.format(query)
558 label = f'Commit search for `{query}`'
561 559 commit_qry = {
562 560 'id': -40,
563 561 'value': query,
@@ -583,7 +581,7 b' class HomeView(BaseAppView, DataGridAppV'
583 581 {
584 582 'id': -1,
585 583 'value': query,
586 'value_display': u'File content search for: `{}`'.format(query),
584 'value_display': f'File content search for: `{query}`',
587 585 'value_icon': '<i class="icon-code"></i>',
588 586 'type': 'search',
589 587 'subtype': 'global',
@@ -594,7 +592,7 b' class HomeView(BaseAppView, DataGridAppV'
594 592 {
595 593 'id': -2,
596 594 'value': query,
597 'value_display': u'Commit search for: `{}`'.format(query),
595 'value_display': f'Commit search for: `{query}`',
598 596 'value_icon': '<i class="icon-history"></i>',
599 597 'type': 'search',
600 598 'subtype': 'global',
@@ -853,4 +851,4 b' class HomeView(BaseAppView, DataGridAppV'
853 851 if existing_value != val:
854 852 self.request.session[key] = val
855 853
856 return 'stored:{}:{}'.format(key, val)
854 return f'stored:{key}:{val}'
@@ -1,5 +1,3 b''
1
2
3 1 # Copyright (C) 2018-2023 RhodeCode GmbH
4 2 #
5 3 # This program is free software: you can redistribute it and/or modify
@@ -1,5 +1,3 b''
1
2
3 1 # Copyright (C) 2016-2023 RhodeCode GmbH
4 2 #
5 3 # This program is free software: you can redistribute it and/or modify
@@ -1,5 +1,3 b''
1
2
3 1 # Copyright (C) 2016-2023 RhodeCode GmbH
4 2 #
5 3 # This program is free software: you can redistribute it and/or modify
@@ -1,5 +1,3 b''
1
2
3 1 # Copyright (C) 2016-2023 RhodeCode GmbH
4 2 #
5 3 # This program is free software: you can redistribute it and/or modify
@@ -1,4 +1,3 b''
1
2 1 # Copyright (C) 2010-2023 RhodeCode GmbH
3 2 #
4 3 # This program is free software: you can redistribute it and/or modify
@@ -1,5 +1,3 b''
1
2
3 1 # Copyright (C) 2016-2023 RhodeCode GmbH
4 2 #
5 3 # This program is free software: you can redistribute it and/or modify
@@ -1,4 +1,3 b''
1
2 1 # Copyright (C) 2010-2023 RhodeCode GmbH
3 2 #
4 3 # This program is free software: you can redistribute it and/or modify
@@ -1,4 +1,3 b''
1
2 1 # Copyright (C) 2010-2023 RhodeCode GmbH
3 2 #
4 3 # This program is free software: you can redistribute it and/or modify
@@ -1,5 +1,3 b''
1
2
3 1 # Copyright (C) 2016-2023 RhodeCode GmbH
4 2 #
5 3 # This program is free software: you can redistribute it and/or modify
@@ -1,5 +1,3 b''
1
2
3 1 # Copyright (C) 2016-2023 RhodeCode GmbH
4 2 #
5 3 # This program is free software: you can redistribute it and/or modify
@@ -370,7 +368,7 b' class LoginView(BaseAppView):'
370 368 return HTTPFound(self.request.route_path('reset_password'))
371 369
372 370 password_reset_form = PasswordResetForm(self.request.translate)()
373 description = u'Generated token for password reset from {}'.format(
371 description = 'Generated token for password reset from {}'.format(
374 372 datetime.datetime.now().isoformat())
375 373
376 374 try:
@@ -1,5 +1,3 b''
1
2
3 1 # Copyright (C) 2016-2023 RhodeCode GmbH
4 2 #
5 3 # This program is free software: you can redistribute it and/or modify
@@ -1,5 +1,3 b''
1
2
3 1 # Copyright (C) 2016-2023 RhodeCode GmbH
4 2 #
5 3 # This program is free software: you can redistribute it and/or modify
@@ -1,4 +1,3 b''
1
2 1 # Copyright (C) 2010-2023 RhodeCode GmbH
3 2 #
4 3 # This program is free software: you can redistribute it and/or modify
@@ -1,5 +1,3 b''
1
2
3 1 # Copyright (C) 2016-2023 RhodeCode GmbH
4 2 #
5 3 # This program is free software: you can redistribute it and/or modify
@@ -87,8 +85,8 b' class TestMyAccountEdit(TestController):'
87 85 response = self.app.get(route_path('my_account_pullrequests_data'),
88 86 extra_environ=xhr_header)
89 87 assert response.json == {
90 u'data': [], u'draw': None,
91 u'recordsFiltered': 0, u'recordsTotal': 0}
88 'data': [], 'draw': None,
89 'recordsFiltered': 0, 'recordsTotal': 0}
92 90
93 91 pr = pr_util.create_pull_request(title='TestMyAccountPR')
94 92 expected = {
@@ -115,7 +113,7 b' class TestMyAccountEdit(TestController):'
115 113 # ('extern_name', {'extern_name': None}),
116 114 ('active', {'active': False}),
117 115 ('active', {'active': True}),
118 ('email', {'email': u'some@email.com'}),
116 ('email', {'email': 'some@email.com'}),
119 117 ])
120 118 def test_my_account_update(self, name, attrs, user_util):
121 119 usr = user_util.create_user(password='qweqwe')
@@ -126,8 +124,8 b' class TestMyAccountEdit(TestController):'
126 124
127 125 params.update({'password_confirmation': ''})
128 126 params.update({'new_password': ''})
129 params.update({'extern_type': u'rhodecode'})
130 params.update({'extern_name': u'rhodecode'})
127 params.update({'extern_type': 'rhodecode'})
128 params.update({'extern_name': 'rhodecode'})
131 129 params.update({'csrf_token': self.csrf_token})
132 130
133 131 params.update(attrs)
@@ -1,4 +1,3 b''
1
2 1 # Copyright (C) 2010-2023 RhodeCode GmbH
3 2 #
4 3 # This program is free software: you can redistribute it and/or modify
@@ -1,4 +1,3 b''
1
2 1 # Copyright (C) 2010-2023 RhodeCode GmbH
3 2 #
4 3 # This program is free software: you can redistribute it and/or modify
@@ -1,4 +1,3 b''
1
2 1 # Copyright (C) 2010-2023 RhodeCode GmbH
3 2 #
4 3 # This program is free software: you can redistribute it and/or modify
@@ -1,4 +1,3 b''
1
2 1 # Copyright (C) 2010-2023 RhodeCode GmbH
3 2 #
4 3 # This program is free software: you can redistribute it and/or modify
@@ -1,4 +1,3 b''
1
2 1 # Copyright (C) 2010-2023 RhodeCode GmbH
3 2 #
4 3 # This program is free software: you can redistribute it and/or modify
@@ -1,4 +1,3 b''
1
2 1 # Copyright (C) 2010-2023 RhodeCode GmbH
3 2 #
4 3 # This program is free software: you can redistribute it and/or modify
@@ -107,7 +106,7 b' class TestChangelogController(TestContro'
107 106 repo=backend.repo_name, branch=branch)
108 107 assert expected_url in response.location
109 108 response = response.follow()
110 expected_warning = 'Branch {} is not found.'.format(branch)
109 expected_warning = f'Branch {branch} is not found.'
111 110 assert expected_warning in response.text
112 111
113 112 @pytest.mark.xfail_backends("svn", reason="Depends on branch support")
@@ -1,4 +1,3 b''
1
2 1 # Copyright (C) 2010-2023 RhodeCode GmbH
3 2 #
4 3 # This program is free software: you can redistribute it and/or modify
@@ -996,7 +996,7 b' class RepoFilesView(RepoAppView):'
996 996 commits_group = ([], _("Changesets"))
997 997 for commit in commits:
998 998 branch = ' (%s)' % commit.branch if commit.branch else ''
999 n_desc = 'r{}:{}{}'.format(commit.idx, commit.short_id, branch)
999 n_desc = f'r{commit.idx}:{commit.short_id}{branch}'
1000 1000 commits_group[0].append((commit.raw_id, n_desc, 'sha'))
1001 1001 history.append(commits_group)
1002 1002
@@ -1,5 +1,3 b''
1
2
3 1 # Copyright (C) 2017-2023 RhodeCode GmbH
4 2 #
5 3 # This program is free software: you can redistribute it and/or modify
@@ -53,7 +51,7 b' class RepoSettingsVcsView(RepoAppView):'
53 51 repo_defaults.update(model.get_repo_settings())
54 52
55 53 global_defaults = {
56 '{}_inherited'.format(k): global_defaults[k]
54 f'{k}_inherited': global_defaults[k]
57 55 for k in global_defaults}
58 56
59 57 defaults = {
@@ -1,5 +1,3 b''
1
2
3 1 # Copyright (C) 2017-2023 RhodeCode GmbH
4 2 #
5 3 # This program is free software: you can redistribute it and/or modify
@@ -1,5 +1,3 b''
1
2
3 1 # Copyright (C) 2016-2023 RhodeCode GmbH
4 2 #
5 3 # This program is free software: you can redistribute it and/or modify
@@ -207,7 +205,7 b' class SshWrapper(object):'
207 205 return server.run(tunnel_extras=extras)
208 206
209 207 else:
210 raise Exception('Unrecognised VCS: {}'.format(vcs))
208 raise Exception(f'Unrecognised VCS: {vcs}')
211 209
212 210 def wrap(self):
213 211 mode = self.mode
@@ -1,5 +1,3 b''
1
2
3 1 # Copyright (C) 2016-2023 RhodeCode GmbH
4 2 #
5 3 # This program is free software: you can redistribute it and/or modify
@@ -1,4 +1,3 b''
1
2 1 # Copyright (C) 2010-2023 RhodeCode GmbH
3 2 #
4 3 # This program is free software: you can redistribute it and/or modify
@@ -1,4 +1,3 b''
1
2 1 # Copyright (C) 2010-2023 RhodeCode GmbH
3 2 #
4 3 # This program is free software: you can redistribute it and/or modify
@@ -1,4 +1,3 b''
1
2 1 # Copyright (C) 2010-2023 RhodeCode GmbH
3 2 #
4 3 # This program is free software: you can redistribute it and/or modify
@@ -1,5 +1,3 b''
1
2
3 1 # Copyright (C) 2013-2023 RhodeCode GmbH
4 2 #
5 3 # This program is free software: you can redistribute it and/or modify
@@ -1,4 +1,3 b''
1
2 1 # Copyright (C) 2010-2023 RhodeCode GmbH
3 2 #
4 3 # This program is free software: you can redistribute it and/or modify
@@ -1,4 +1,3 b''
1
2 1 # Copyright (C) 2010-2023 RhodeCode GmbH
3 2 #
4 3 # This program is free software: you can redistribute it and/or modify
@@ -260,11 +259,11 b' def error_handler(exception, request):'
260 259
261 260 statsd = request.registry.statsd
262 261 if statsd and base_response.status_code > 499:
263 exc_type = "{}.{}".format(exception.__class__.__module__, exception.__class__.__name__)
262 exc_type = f"{exception.__class__.__module__}.{exception.__class__.__name__}"
264 263 statsd.incr('rhodecode_exception_total',
265 264 tags=["exc_source:web",
266 "http_code:{}".format(base_response.status_code),
267 "type:{}".format(exc_type)])
265 f"http_code:{base_response.status_code}",
266 f"type:{exc_type}"])
268 267
269 268 return response
270 269
@@ -1,5 +1,3 b''
1
2
3 1 # Copyright (C) 2016-2023 RhodeCode GmbH
4 2 #
5 3 # This program is free software: you can redistribute it and/or modify
@@ -69,7 +67,7 b' def inspect_getargspec():'
69 67 func = func.__wrapped__
70 68 id_func = id(func)
71 69 if id_func in memo:
72 raise ValueError('wrapper loop when unwrapping {!r}'.format(f))
70 raise ValueError(f'wrapper loop when unwrapping {f!r}')
73 71 memo.add(id_func)
74 72 return func
75 73
@@ -1,4 +1,3 b''
1
2 1 # Copyright (C) 2010-2023 RhodeCode GmbH
3 2 #
4 3 # This program is free software: you can redistribute it and/or modify
@@ -70,7 +69,7 b' class SettingsMaker(object):'
70 69 os.makedirs(input_val, mode=mode)
71 70
72 71 if not os.path.isdir(input_val):
73 raise Exception('Dir at {} does not exist'.format(input_val))
72 raise Exception(f'Dir at {input_val} does not exist')
74 73 return input_val
75 74
76 75 @classmethod
@@ -1,4 +1,3 b''
1
2 1 # Copyright (C) 2010-2023 RhodeCode GmbH
3 2 #
4 3 # This program is free software: you can redistribute it and/or modify
@@ -45,7 +45,7 b' class RhodecodeEvent(object):'
45 45 self.utc_timestamp = datetime.datetime.utcnow()
46 46
47 47 def __repr__(self):
48 return '<%s:(%s)>' % (self.__class__.__name__, self.name)
48 return '<{}:({})>'.format(self.__class__.__name__, self.name)
49 49
50 50 def get_request(self):
51 51 if self._request:
@@ -32,13 +32,13 b' class PullRequestEvent(RepoEvent):'
32 32 """
33 33
34 34 def __init__(self, pullrequest):
35 super(PullRequestEvent, self).__init__(pullrequest.target_repo)
35 super().__init__(pullrequest.target_repo)
36 36 self.pullrequest = pullrequest
37 37
38 38 def as_dict(self):
39 39 from rhodecode.lib.utils2 import md5_safe
40 40 from rhodecode.model.pull_request import PullRequestModel
41 data = super(PullRequestEvent, self).as_dict()
41 data = super().as_dict()
42 42
43 43 commits = _commits_as_dict(
44 44 self,
@@ -110,7 +110,7 b' class PullRequestReviewEvent(PullRequest'
110 110 'pull requests has changed to other.')
111 111
112 112 def __init__(self, pullrequest, status):
113 super(PullRequestReviewEvent, self).__init__(pullrequest)
113 super().__init__(pullrequest)
114 114 self.status = status
115 115
116 116
@@ -136,12 +136,12 b' class PullRequestCommentEvent(PullReques'
136 136 'in the pull request')
137 137
138 138 def __init__(self, pullrequest, comment):
139 super(PullRequestCommentEvent, self).__init__(pullrequest)
139 super().__init__(pullrequest)
140 140 self.comment = comment
141 141
142 142 def as_dict(self):
143 143 from rhodecode.model.comment import CommentsModel
144 data = super(PullRequestCommentEvent, self).as_dict()
144 data = super().as_dict()
145 145
146 146 status = None
147 147 if self.comment.status_change:
@@ -175,12 +175,12 b' class PullRequestCommentEditEvent(PullRe'
175 175 'in the pull request')
176 176
177 177 def __init__(self, pullrequest, comment):
178 super(PullRequestCommentEditEvent, self).__init__(pullrequest)
178 super().__init__(pullrequest)
179 179 self.comment = comment
180 180
181 181 def as_dict(self):
182 182 from rhodecode.model.comment import CommentsModel
183 data = super(PullRequestCommentEditEvent, self).as_dict()
183 data = super().as_dict()
184 184
185 185 status = None
186 186 if self.comment.status_change:
@@ -69,7 +69,7 b' def _commits_as_dict(event, commit_ids, '
69 69 'raw_id': commit_id, 'short_id': commit_id,
70 70 'branch': None,
71 71 'git_ref_change': 'tag_add',
72 'message': 'Added new tag {}'.format(raw_id),
72 'message': f'Added new tag {raw_id}',
73 73 'author': event.actor.full_contact,
74 74 'date': datetime.datetime.now(),
75 75 'refs': {
@@ -86,7 +86,7 b' def _commits_as_dict(event, commit_ids, '
86 86 'raw_id': commit_id, 'short_id': commit_id,
87 87 'branch': None,
88 88 'git_ref_change': 'branch_delete',
89 'message': 'Deleted branch {}'.format(raw_id),
89 'message': f'Deleted branch {raw_id}',
90 90 'author': event.actor.full_contact,
91 91 'date': datetime.datetime.now(),
92 92 'refs': {
@@ -155,12 +155,12 b' class RepoEvent(RhodeCodeIntegrationEven'
155 155 """
156 156
157 157 def __init__(self, repo):
158 super(RepoEvent, self).__init__()
158 super().__init__()
159 159 self.repo = repo
160 160
161 161 def as_dict(self):
162 162 from rhodecode.model.repo import RepoModel
163 data = super(RepoEvent, self).as_dict()
163 data = super().as_dict()
164 164
165 165 extra_fields = collections.OrderedDict()
166 166 for field in self.repo.extra_fields:
@@ -193,12 +193,12 b' class RepoCommitCommentEvent(RepoEvent):'
193 193 'on commit inside a repository')
194 194
195 195 def __init__(self, repo, commit, comment):
196 super(RepoCommitCommentEvent, self).__init__(repo)
196 super().__init__(repo)
197 197 self.commit = commit
198 198 self.comment = comment
199 199
200 200 def as_dict(self):
201 data = super(RepoCommitCommentEvent, self).as_dict()
201 data = super().as_dict()
202 202 data['commit'] = {
203 203 'commit_id': self.commit.raw_id,
204 204 'commit_message': self.commit.message,
@@ -228,12 +228,12 b' class RepoCommitCommentEditEvent(RepoEve'
228 228 'on commit inside a repository')
229 229
230 230 def __init__(self, repo, commit, comment):
231 super(RepoCommitCommentEditEvent, self).__init__(repo)
231 super().__init__(repo)
232 232 self.commit = commit
233 233 self.comment = comment
234 234
235 235 def as_dict(self):
236 data = super(RepoCommitCommentEditEvent, self).as_dict()
236 data = super().as_dict()
237 237 data['commit'] = {
238 238 'commit_id': self.commit.raw_id,
239 239 'commit_message': self.commit.message,
@@ -300,7 +300,7 b' class RepoVCSEvent(RepoEvent):'
300 300 if not self.repo:
301 301 raise Exception('repo by this name %s does not exist' % repo_name)
302 302 self.extras = extras
303 super(RepoVCSEvent, self).__init__(self.repo)
303 super().__init__(self.repo)
304 304
305 305 @property
306 306 def actor(self):
@@ -366,12 +366,12 b' class RepoPushEvent(RepoVCSEvent):'
366 366 'pushed to a repository')
367 367
368 368 def __init__(self, repo_name, pushed_commit_ids, extras):
369 super(RepoPushEvent, self).__init__(repo_name, extras)
369 super().__init__(repo_name, extras)
370 370 self.pushed_commit_ids = pushed_commit_ids
371 371 self.new_refs = extras.new_refs
372 372
373 373 def as_dict(self):
374 data = super(RepoPushEvent, self).as_dict()
374 data = super().as_dict()
375 375
376 376 def branch_url(branch_name):
377 377 return '{}/changelog?branch={}'.format(
@@ -33,11 +33,11 b' class RepoGroupEvent(RhodeCodeIntegratio'
33 33 """
34 34
35 35 def __init__(self, repo_group):
36 super(RepoGroupEvent, self).__init__()
36 super().__init__()
37 37 self.repo_group = repo_group
38 38
39 39 def as_dict(self):
40 data = super(RepoGroupEvent, self).as_dict()
40 data = super().as_dict()
41 41 data.update({
42 42 'repo_group': {
43 43 'group_id': self.repo_group.group_id,
@@ -37,7 +37,7 b' class UserRegistered(RhodeCodeIntegratio'
37 37 display_name = lazy_ugettext('user registered')
38 38
39 39 def __init__(self, user, session):
40 super(UserRegistered, self).__init__()
40 super().__init__()
41 41 self.user = user
42 42 self.session = session
43 43
@@ -52,7 +52,7 b' class UserPreCreate(RhodeCodeIntegration'
52 52 display_name = lazy_ugettext('user pre create')
53 53
54 54 def __init__(self, user_data):
55 super(UserPreCreate, self).__init__()
55 super().__init__()
56 56 self.user_data = user_data
57 57
58 58
@@ -66,7 +66,7 b' class UserPostCreate(RhodeCodeIntegratio'
66 66 display_name = lazy_ugettext('user post create')
67 67
68 68 def __init__(self, user_data):
69 super(UserPostCreate, self).__init__()
69 super().__init__()
70 70 self.user_data = user_data
71 71
72 72
@@ -80,7 +80,7 b' class UserPreUpdate(RhodeCodeIntegration'
80 80 display_name = lazy_ugettext('user pre update')
81 81
82 82 def __init__(self, user, user_data):
83 super(UserPreUpdate, self).__init__()
83 super().__init__()
84 84 self.user = user
85 85 self.user_data = user_data
86 86
@@ -100,5 +100,5 b' class UserPermissionsChange(RhodecodeEve'
100 100 display_name = lazy_ugettext('user permissions change')
101 101
102 102 def __init__(self, user_ids):
103 super(UserPermissionsChange, self).__init__()
103 super().__init__()
104 104 self.user_ids = user_ids
@@ -1,4 +1,3 b''
1
2 1 # Copyright (C) 2010-2023 RhodeCode GmbH
3 2 #
4 3 # This program is free software: you can redistribute it and/or modify
@@ -1,5 +1,3 b''
1
2
3 1 # Copyright (C) 2012-2023 RhodeCode GmbH
4 2 #
5 3 # This program is free software: you can redistribute it and/or modify
@@ -1,4 +1,3 b''
1
2 1 # Copyright (C) 2012-2023 RhodeCode GmbH
3 2 #
4 3 # This program is free software: you can redistribute it and/or modify
@@ -1,5 +1,3 b''
1
2
3 1 # Copyright (C) 2012-2023 RhodeCode GmbH
4 2 #
5 3 # This program is free software: you can redistribute it and/or modify
@@ -1,5 +1,3 b''
1
2
3 1 # Copyright (C) 2012-2023 RhodeCode GmbH
4 2 #
5 3 # This program is free software: you can redistribute it and/or modify
@@ -1,5 +1,3 b''
1
2
3 1 # Copyright (C) 2016-2023 RhodeCode GmbH
4 2 #
5 3 # This program is free software: you can redistribute it and/or modify
@@ -1,4 +1,3 b''
1
2 1 # Copyright (C) 2010-2023 RhodeCode GmbH
3 2 #
4 3 # This program is free software: you can redistribute it and/or modify
@@ -1,5 +1,3 b''
1
2
3 1 # Copyright (C) 2012-2023 RhodeCode GmbH
4 2 #
5 3 # This program is free software: you can redistribute it and/or modify
@@ -1,5 +1,3 b''
1
2
3 1 # Copyright (C) 2012-2023 RhodeCode GmbH
4 2 #
5 3 # This program is free software: you can redistribute it and/or modify
@@ -43,7 +41,7 b' class UrlTmpl(string.Template):'
43 41 def safe_substitute(self, **kws):
44 42 # url encode the kw for usage in url
45 43 kws = {k: urllib.parse.quote(safe_str(v)) for k, v in kws.items()}
46 return super(UrlTmpl, self).safe_substitute(**kws)
44 return super().safe_substitute(**kws)
47 45
48 46
49 47 class IntegrationTypeBase(object):
@@ -265,7 +263,7 b' class WebhookDataHandler(CommitParsingDa'
265 263
266 264 extra_vars = {}
267 265 for extra_key, extra_val in data['repo']['extra_fields'].items():
268 extra_vars['extra__{}'.format(extra_key)] = extra_val
266 extra_vars[f'extra__{extra_key}'] = extra_val
269 267 common_vars.update(extra_vars)
270 268
271 269 template_url = self.template_url.replace('${extra:', '${extra__')
@@ -388,7 +386,7 b' class WebhookDataHandler(CommitParsingDa'
388 386 return self.pull_request_event_handler(event, data)
389 387 else:
390 388 raise ValueError(
391 'event type `{}` has no handler defined'.format(event.__class__))
389 f'event type `{event.__class__}` has no handler defined')
392 390
393 391
394 392 def get_auth(settings):
@@ -408,7 +406,7 b' def get_url_vars(url_vars):'
408 406 items = []
409 407
410 408 for section, section_items in url_vars:
411 items.append('\n*{}*'.format(section))
409 items.append(f'\n*{section}*')
412 410 for key, explanation in section_items:
413 411 items.append(' {} - {}'.format('${' + key + '}', explanation))
414 412 return '\n'.join(items)
@@ -1,5 +1,3 b''
1
2
3 1 # Copyright (C) 2012-2023 RhodeCode GmbH
4 2 #
5 3 # This program is free software: you can redistribute it and/or modify
@@ -1,5 +1,3 b''
1
2
3 1 # Copyright (C) 2012-2023 RhodeCode GmbH
4 2 #
5 3 # This program is free software: you can redistribute it and/or modify
@@ -128,7 +126,7 b' class HipchatIntegrationType(Integration'
128 126
129 127 data = event.as_dict()
130 128
131 text = '<b>%s<b> caused a <b>%s</b> event' % (
129 text = '<b>{}<b> caused a <b>{}</b> event'.format(
132 130 data['actor']['username'], event.name)
133 131
134 132 if isinstance(event, events.PullRequestCommentEvent):
@@ -1,5 +1,3 b''
1
2
3 1 # Copyright (C) 2012-2023 RhodeCode GmbH
4 2 #
5 3 # This program is free software: you can redistribute it and/or modify
@@ -1,5 +1,3 b''
1
2
3 1 # Copyright (C) 2012-2023 RhodeCode GmbH
4 2 #
5 3 # This program is free software: you can redistribute it and/or modify
@@ -235,7 +233,7 b' def post_to_webhook(url_calls, settings)'
235 233 """
236 234
237 235 call_headers = {
238 'User-Agent': 'RhodeCode-webhook-caller/{}'.format(rhodecode.__version__)
236 'User-Agent': f'RhodeCode-webhook-caller/{rhodecode.__version__}'
239 237 } # updated below with custom ones, allows override
240 238
241 239 auth = get_auth(settings)
@@ -1,5 +1,3 b''
1
2
3 1 # Copyright (C) 2012-2023 RhodeCode GmbH
4 2 #
5 3 # This program is free software: you can redistribute it and/or modify
@@ -48,7 +46,7 b' class IntegrationSettingsViewBase(BaseAp'
48 46 """
49 47
50 48 def __init__(self, context, request):
51 super(IntegrationSettingsViewBase, self).__init__(context, request)
49 super().__init__(context, request)
52 50 self._load_view_context()
53 51
54 52 def _load_view_context(self):
@@ -112,7 +110,7 b' class IntegrationSettingsViewBase(BaseAp'
112 110
113 111 def _get_local_tmpl_context(self, include_app_defaults=True):
114 112 _ = self.request.translate
115 c = super(IntegrationSettingsViewBase, self)._get_local_tmpl_context(
113 c = super()._get_local_tmpl_context(
116 114 include_app_defaults=include_app_defaults)
117 115 c.active = 'integrations'
118 116
@@ -1,4 +1,3 b''
1
2 1 # Copyright (C) 2010-2023 RhodeCode GmbH
3 2 #
4 3 # This program is free software: you can redistribute it and/or modify
@@ -1,5 +1,3 b''
1
2
3 1 # Copyright (C) 2012-2023 RhodeCode GmbH
4 2 #
5 3 # This program is free software: you can redistribute it and/or modify
@@ -1,4 +1,3 b''
1
2 1 """
3 2 Helper functions for use with :class:`Authomatic`.
4 3
@@ -1,4 +1,3 b''
1
2 1 # Copyright (C) 2010-2023 RhodeCode GmbH
3 2 #
4 3 # This program is free software: you can redistribute it and/or modify
@@ -1,5 +1,3 b''
1
2
3 1 # Copyright (C) 2017-2023 RhodeCode GmbH
4 2 #
5 3 # This program is free software: you can redistribute it and/or modify
@@ -220,7 +218,7 b' def store(action, user, action_data=None'
220 218
221 219 action_spec = ACTIONS.get(action, None)
222 220 if action_spec is None:
223 raise ValueError('Action `{}` is not supported'.format(action))
221 raise ValueError(f'Action `{action}` is not supported')
224 222
225 223 if not sa_session:
226 224 sa_session = meta.Session()
@@ -1,4 +1,3 b''
1
2 1 # Copyright (C) 2010-2023 RhodeCode GmbH
3 2 #
4 3 # This program is free software: you can redistribute it and/or modify
@@ -1,4 +1,3 b''
1
2 1 # Copyright (C) 2010-2023 RhodeCode GmbH
3 2 #
4 3 # This program is free software: you can redistribute it and/or modify
@@ -208,7 +207,7 b' class BasicAuth(AuthBasicAuthenticator):'
208 207
209 208 def __init__(self, realm, authfunc, registry, auth_http_code=None,
210 209 initial_call_detection=False, acl_repo_name=None, rc_realm=''):
211 super(BasicAuth, self).__init__(realm=realm, authfunc=authfunc)
210 super().__init__(realm=realm, authfunc=authfunc)
212 211 self.realm = realm
213 212 self.rc_realm = rc_realm
214 213 self.initial_call = initial_call_detection
@@ -1,4 +1,3 b''
1
2 1 # Copyright (C) 2010-2023 RhodeCode GmbH
3 2 #
4 3 # This program is free software: you can redistribute it and/or modify
@@ -1,4 +1,3 b''
1
2 1 # Copyright (C) 2010-2023 RhodeCode GmbH
3 2 #
4 3 # This program is free software: you can redistribute it and/or modify
@@ -84,7 +83,7 b' def run_task(task, *args, **kwargs):'
84 83 if statsd:
85 84 task_repr = getattr(task, 'name', task)
86 85 statsd.incr('rhodecode_celery_task_total', tags=[
87 'task:{}'.format(task_repr),
86 f'task:{task_repr}',
88 87 'mode:sync'
89 88 ])
90 89
@@ -1,4 +1,3 b''
1
2 1 # Copyright (C) 2010-2023 RhodeCode GmbH
3 2 #
4 3 # This program is free software: you can redistribute it and/or modify
@@ -35,7 +34,7 b' class FileScheduleEntry(CeleryScheduleEn'
35 34 # because our custom loader passes in some variables that the original
36 35 # function doesn't expect, we have this thin wrapper
37 36
38 super(FileScheduleEntry, self).__init__(
37 super().__init__(
39 38 name=name, task=task, last_run_at=last_run_at,
40 39 total_run_count=total_run_count, schedule=schedule, args=args,
41 40 kwargs=kwargs, options=options, relative=relative, app=app)
@@ -47,7 +46,7 b' class FileScheduler(PersistentScheduler)'
47 46
48 47 def setup_schedule(self):
49 48 log.info("setup_schedule called")
50 super(FileScheduler, self).setup_schedule()
49 super().setup_schedule()
51 50
52 51
53 52 try:
@@ -1,5 +1,3 b''
1
2
3 1 # Copyright (C) 2012-2023 RhodeCode GmbH
4 2 #
5 3 # This program is free software: you can redistribute it and/or modify
@@ -1,4 +1,3 b''
1
2 1 # Copyright (C) 2010-2023 RhodeCode GmbH
3 2 #
4 3 # This program is free software: you can redistribute it and/or modify
@@ -1,5 +1,3 b''
1
2
3 1 # Copyright (C) 2016-2023 RhodeCode GmbH
4 2 #
5 3 # This program is free software: you can redistribute it and/or modify
@@ -286,7 +284,7 b' def _reload_link(label):'
286 284 def pr_channel(pull_request):
287 285 repo_name = pull_request.target_repo.repo_name
288 286 pull_request_id = pull_request.pull_request_id
289 channel = '/repo${}$/pr/{}'.format(repo_name, pull_request_id)
287 channel = f'/repo${repo_name}$/pr/{pull_request_id}'
290 288 log.debug('Getting pull-request channelstream broadcast channel: %s', channel)
291 289 return channel
292 290
@@ -1,5 +1,3 b''
1
2
3 1 # Copyright (C) 2011-2023 RhodeCode GmbH
4 2 #
5 3 # This program is free software: you can redistribute it and/or modify
@@ -785,8 +783,7 b' class DiffSet(object):'
785 783 for line in lines:
786 784
787 785 if buf and not line.original or line.original.action == ' ':
788 for b in buf:
789 yield b
786 yield from buf
790 787 buf = []
791 788
792 789 if line.original:
@@ -813,7 +810,6 b' class DiffSet(object):'
813 810 line.modified.action, line.modified.content,
814 811 line.modified.get_comment_args)
815 812
816 for b in buf:
817 yield b
813 yield from buf
818 814
819 815 return generator()
@@ -1,5 +1,3 b''
1
2
3 1 # Copyright (C) 2016-2023 RhodeCode GmbH
4 2 #
5 3 # This program is free software: you can redistribute it and/or modify
@@ -1,4 +1,3 b''
1
2 1 # Copyright (C) 2010-2023 RhodeCode GmbH
3 2 #
4 3 # This program is free software: you can redistribute it and/or modify
@@ -1,4 +1,3 b''
1
2 1 # Copyright (C) 2010-2023 RhodeCode GmbH
3 2 #
4 3 # This program is free software: you can redistribute it and/or modify
@@ -1,4 +1,3 b''
1
2 1 # Copyright (C) 2010-2023 RhodeCode GmbH
3 2 #
4 3 # This program is free software: you can redistribute it and/or modify
@@ -1,5 +1,3 b''
1
2
3 1 # Copyright (C) 2011-2023 RhodeCode GmbH
4 2 #
5 3 # This program is free software: you can redistribute it and/or modify
@@ -121,8 +119,7 b' class LimitedDiffContainer(object):'
121 119 return self.diff.__getitem__(key)
122 120
123 121 def __iter__(self):
124 for l in self.diff:
125 yield l
122 yield from self.diff
126 123
127 124
128 125 class Action(object):
@@ -1,5 +1,3 b''
1
2
3 1 # Copyright (C) 2014-2023 RhodeCode GmbH
4 2 #
5 3 # This program is free software: you can redistribute it and/or modify
@@ -42,7 +40,7 b' class InvalidDecryptedValue(str):'
42 40 <InvalidDecryptedValue(QkWusFgLJXR6m42v...)>
43 41 And represent a safe indicator that encryption key is broken
44 42 """
45 content = '<{}({}...)>'.format(cls.__name__, content[:16])
43 content = f'<{cls.__name__}({content[:16]}...)>'
46 44 return str.__new__(cls, content)
47 45
48 46 KEY_FORMAT = b'enc$aes_hmac${1}'
@@ -17,7 +17,7 b' class InvalidDecryptedValue(str):'
17 17 <InvalidDecryptedValue(QkWusFgLJXR6m42v...)>
18 18 And represent a safe indicator that encryption key is broken
19 19 """
20 content = '<{}({}...)>'.format(cls.__name__, content[:16])
20 content = f'<{cls.__name__}({content[:16]}...)>'
21 21 return str.__new__(cls, content)
22 22
23 23
@@ -1,4 +1,3 b''
1
2 1 # Copyright (C) 2010-2023 RhodeCode GmbH
3 2 #
4 3 # This program is free software: you can redistribute it and/or modify
@@ -183,10 +182,10 b' def store_exception(exc_id, exc_info, pr'
183 182 def _find_exc_file(exc_id, prefix=global_prefix):
184 183 exc_store_path = get_exc_store()
185 184 if prefix:
186 exc_id = '{}_{}'.format(exc_id, prefix)
185 exc_id = f'{exc_id}_{prefix}'
187 186 else:
188 187 # search without a prefix
189 exc_id = '{}'.format(exc_id)
188 exc_id = f'{exc_id}'
190 189
191 190 found_exc_id = None
192 191 matches = glob.glob(os.path.join(exc_store_path, exc_id) + '*')
@@ -1,4 +1,3 b''
1
2 1 # Copyright (C) 2010-2023 RhodeCode GmbH
3 2 #
4 3 # This program is free software: you can redistribute it and/or modify
@@ -95,7 +94,7 b' class HTTPRequirementError(HTTPClientErr'
95 94
96 95 def __init__(self, message, *args, **kwargs):
97 96 self.title = self.explanation = message
98 super(HTTPRequirementError, self).__init__(*args, **kwargs)
97 super().__init__(*args, **kwargs)
99 98 self.args = (message, )
100 99
101 100
@@ -114,7 +113,7 b' class HTTPLockedRC(HTTPClientError):'
114 113 self.code = rhodecode.ConfigGet().get_int('lock_ret_code', missing=self.code)
115 114
116 115 self.title = self.explanation = message
117 super(HTTPLockedRC, self).__init__(*args, **kwargs)
116 super().__init__(*args, **kwargs)
118 117 self.args = (message, )
119 118
120 119
@@ -129,7 +128,7 b' class HTTPBranchProtected(HTTPClientErro'
129 128
130 129 def __init__(self, message, *args, **kwargs):
131 130 self.title = self.explanation = message
132 super(HTTPBranchProtected, self).__init__(*args, **kwargs)
131 super().__init__(*args, **kwargs)
133 132 self.args = (message, )
134 133
135 134
@@ -163,7 +162,7 b' class VCSServerUnavailable(HTTPBadGatewa'
163 162 self.explanation = 'Could not connect to VCS Server'
164 163 if message:
165 164 self.explanation += ': ' + message
166 super(VCSServerUnavailable, self).__init__()
165 super().__init__()
167 166
168 167
169 168 class ArtifactMetadataDuplicate(ValueError):
@@ -171,7 +170,7 b' class ArtifactMetadataDuplicate(ValueErr'
171 170 def __init__(self, *args, **kwargs):
172 171 self.err_section = kwargs.pop('err_section', None)
173 172 self.err_key = kwargs.pop('err_key', None)
174 super(ArtifactMetadataDuplicate, self).__init__(*args, **kwargs)
173 super().__init__(*args, **kwargs)
175 174
176 175
177 176 class ArtifactMetadataBadValueType(ValueError):
@@ -1,4 +1,3 b''
1
2 1 # Copyright (C) 2010-2023 RhodeCode GmbH
3 2 #
4 3 # This program is free software: you can redistribute it and/or modify
@@ -1,5 +1,3 b''
1
2
3 1 # Copyright (C) 2016-2023 RhodeCode GmbH
4 2 #
5 3 # This program is free software: you can redistribute it and/or modify
@@ -23,8 +23,8 b' class SimplerXMLGenerator(XMLGenerator):'
23 23 self._write('<' + name)
24 24 # sort attributes for consistent output
25 25 for (name, value) in sorted(attrs.items()):
26 self._write(' %s=%s' % (name, quoteattr(value)))
27 self._write(six.u('>'))
26 self._write(' {}={}'.format(name, quoteattr(value)))
27 self._write('>')
28 28
29 29
30 30 def iri_to_uri(iri):
@@ -1,4 +1,3 b''
1
2 1 # Copyright (C) 2010-2023 RhodeCode GmbH
3 2 #
4 3 # This program is free software: you can redistribute it and/or modify
@@ -31,7 +30,7 b' def grandparent(parent_idx_func, lowest_'
31 30 Return all ancestors of head in roots which commit is
32 31 greater or equal to lowest_idx.
33 32 """
34 pending = set([head])
33 pending = {head}
35 34 seen = set()
36 35 kept = set()
37 36 llowestrev = max(nullrev, lowest_idx)
@@ -1,5 +1,3 b''
1
2
3 1 # Copyright (C) 2011-2023 RhodeCode GmbH
4 2 #
5 3 # This program is free software: you can redistribute it and/or modify
@@ -1,4 +1,3 b''
1
2 1 # Copyright (C) 2010-2023 RhodeCode GmbH
3 2 #
4 3 # This program is free software: you can redistribute it and/or modify
@@ -123,7 +122,7 b' def asset(path, ver=None, **kwargs):'
123 122 if ver:
124 123 query = {'ver': ver}
125 124 return request.static_path(
126 'rhodecode:public/{}'.format(path), _query=query)
125 f'rhodecode:public/{path}', _query=query)
127 126
128 127
129 128 default_html_escape_table = {
@@ -1,5 +1,3 b''
1
2
3 1 # Copyright (C) 2013-2023 RhodeCode GmbH
4 2 #
5 3 # This program is free software: you can redistribute it and/or modify
@@ -220,7 +218,7 b' def post_pull(extras):'
220 218 statsd = StatsdClient.statsd
221 219 if statsd:
222 220 statsd.incr('rhodecode_pull_total', tags=[
223 'user-agent:{}'.format(user_agent_normalizer(extras.user_agent)),
221 f'user-agent:{user_agent_normalizer(extras.user_agent)}',
224 222 ])
225 223 output = ''
226 224 # make lock is a tri state False, True, None. We only make lock on True
@@ -229,7 +227,7 b' def post_pull(extras):'
229 227 Repository.lock(Repository.get_by_repo_name(extras.repository),
230 228 user.user_id,
231 229 lock_reason=Repository.LOCK_PULL)
232 msg = 'Made lock on repo `%s`' % (extras.repository,)
230 msg = 'Made lock on repo `{}`'.format(extras.repository)
233 231 output += msg
234 232
235 233 if extras.locked_by[0]:
@@ -270,7 +268,7 b' def post_push(extras):'
270 268 statsd = StatsdClient.statsd
271 269 if statsd:
272 270 statsd.incr('rhodecode_push_total', tags=[
273 'user-agent:{}'.format(user_agent_normalizer(extras.user_agent)),
271 f'user-agent:{user_agent_normalizer(extras.user_agent)}',
274 272 ])
275 273
276 274 # Propagate to external components.
@@ -1,4 +1,3 b''
1
2 1 # Copyright (C) 2010-2023 RhodeCode GmbH
3 2 #
4 3 # This program is free software: you can redistribute it and/or modify
@@ -1,4 +1,3 b''
1
2 1 # Copyright (C) 2010-2023 RhodeCode GmbH
3 2 #
4 3 # This program is free software: you can redistribute it and/or modify
@@ -1,5 +1,3 b''
1
2
3 1 # Copyright (C) 2020-2023 RhodeCode GmbH
4 2 #
5 3 # This program is free software: you can redistribute it and/or modify
@@ -1,5 +1,3 b''
1
2
3 1 # Copyright (C) 2012-2023 RhodeCode GmbH
4 2 #
5 3 # This program is free software: you can redistribute it and/or modify
@@ -1,4 +1,3 b''
1
2 1 # Copyright (C) 2010-2023 RhodeCode GmbH
3 2 #
4 3 # This program is free software: you can redistribute it and/or modify
@@ -50,8 +49,8 b" SOCIAL_PLUGINS_LIST = ['github', 'bitbuc"
50 49
51 50 class SettingNotFound(Exception):
52 51 def __init__(self, setting_id):
53 msg = 'Setting `{}` is not found'.format(setting_id)
54 super(SettingNotFound, self).__init__(msg)
52 msg = f'Setting `{setting_id}` is not found'
53 super().__init__(msg)
55 54
56 55
57 56 class SettingsModel(BaseModel):
@@ -67,7 +66,7 b' class SettingsModel(BaseModel):'
67 66 self.UiDbModel = RepoRhodeCodeUi if repo else RhodeCodeUi
68 67 self.SettingsDbModel = (
69 68 RepoRhodeCodeSetting if repo else RhodeCodeSetting)
70 super(SettingsModel, self).__init__(sa)
69 super().__init__(sa)
71 70
72 71 def get_ui_by_key(self, key):
73 72 q = self.UiDbModel.query()
@@ -362,7 +361,7 b' class IssueTrackerSettingsModel(object):'
362 361 Session().add(settings)
363 362
364 363 def _get_keyname(self, key, uid, prefix=''):
365 return '{0}{1}{2}_{3}'.format(
364 return '{}{}{}_{}'.format(
366 365 prefix, self.SETTINGS_PREFIX, key, uid)
367 366
368 367 def _make_dict_for_settings(self, qs):
@@ -585,7 +584,7 b' class VcsSettingsModel(object):'
585 584 data_key = self._get_form_ui_key(section, key)
586 585 if data_key not in data:
587 586 raise ValueError(
588 'The given data does not contain {} key'.format(data_key))
587 f'The given data does not contain {data_key} key')
589 588
590 589 active = data.get(data_key)
591 590 repo_setting = self.repo_settings.get_ui_by_section_and_key(
@@ -604,7 +603,7 b' class VcsSettingsModel(object):'
604 603 data_key = self._get_form_ui_key(section, key)
605 604 if data_key not in data:
606 605 raise ValueError(
607 'The given data does not contain {} key'.format(data_key))
606 f'The given data does not contain {data_key} key')
608 607 active = data.get(data_key)
609 608 repo_setting = self.global_settings.get_ui_by_section_and_key(
610 609 section, key)
@@ -825,7 +824,7 b' class VcsSettingsModel(object):'
825 824 return keep
826 825
827 826 def _filter_general_settings(self, settings):
828 keys = ['rhodecode_{}'.format(key) for key in self.GENERAL_SETTINGS]
827 keys = [f'rhodecode_{key}' for key in self.GENERAL_SETTINGS]
829 828 return {
830 829 k: settings[k]
831 830 for k in settings if k in keys}
@@ -849,7 +848,7 b' class VcsSettingsModel(object):'
849 848 for name in self.GENERAL_SETTINGS:
850 849 setting = settings.get_setting_by_name(name)
851 850 if setting:
852 result_key = 'rhodecode_{}'.format(name)
851 result_key = f'rhodecode_{name}'
853 852 result[result_key] = setting.app_settings_value
854 853
855 854 return result
@@ -883,10 +882,10 b' class VcsSettingsModel(object):'
883 882
884 883 def _create_or_update_general_settings(self, settings, data):
885 884 for name in self.GENERAL_SETTINGS:
886 data_key = 'rhodecode_{}'.format(name)
885 data_key = f'rhodecode_{name}'
887 886 if data_key not in data:
888 887 raise ValueError(
889 'The given data does not contain {} key'.format(data_key))
888 f'The given data does not contain {data_key} key')
890 889 setting = settings.create_or_update_setting(
891 890 name, data[data_key], 'bool')
892 891 Session().add(setting)
@@ -896,7 +895,7 b' class VcsSettingsModel(object):'
896 895 for data_key in data_keys:
897 896 if data_key not in data:
898 897 raise ValueError(
899 'The given data does not contain {} key'.format(data_key))
898 f'The given data does not contain {data_key} key')
900 899 return data_keys
901 900
902 901 def create_largeobjects_dirs_if_needed(self, repo_store_path):
@@ -1,5 +1,3 b''
1
2
3 1 # Copyright (C) 2013-2023 RhodeCode GmbH
4 2 #
5 3 # This program is free software: you can redistribute it and/or modify
@@ -1,5 +1,3 b''
1
2
3 1 # Copyright (C) 2013-2023 RhodeCode GmbH
4 2 #
5 3 # This program is free software: you can redistribute it and/or modify
@@ -1,4 +1,3 b''
1
2 1 # Copyright (C) 2010-2023 RhodeCode GmbH
3 2 #
4 3 # This program is free software: you can redistribute it and/or modify
@@ -577,8 +576,8 b' class UserModel(BaseModel):'
577 576 try:
578 577 if user.username == User.DEFAULT_USER:
579 578 raise DefaultUserException(
580 u"You can't remove this user since it's"
581 u" crucial for entire application")
579 "You can't remove this user since it's"
580 " crucial for entire application")
582 581 handle_user = handle_new_owner or self.cls.get_first_super_admin()
583 582 log.debug('New detached objects owner %s', handle_user)
584 583
@@ -587,8 +586,8 b' class UserModel(BaseModel):'
587 586 if left_overs and user.repositories:
588 587 repos = [x.repo_name for x in user.repositories]
589 588 raise UserOwnsReposException(
590 u'user "%(username)s" still owns %(len_repos)s repositories and cannot be '
591 u'removed. Switch owners or remove those repositories:%(list_repos)s'
589 'user "%(username)s" still owns %(len_repos)s repositories and cannot be '
590 'removed. Switch owners or remove those repositories:%(list_repos)s'
592 591 % {'username': user.username, 'len_repos': len(repos),
593 592 'list_repos': ', '.join(repos)})
594 593
@@ -597,8 +596,8 b' class UserModel(BaseModel):'
597 596 if left_overs and user.repository_groups:
598 597 repo_groups = [x.group_name for x in user.repository_groups]
599 598 raise UserOwnsRepoGroupsException(
600 u'user "%(username)s" still owns %(len_repo_groups)s repository groups and cannot be '
601 u'removed. Switch owners or remove those repository groups:%(list_repo_groups)s'
599 'user "%(username)s" still owns %(len_repo_groups)s repository groups and cannot be '
600 'removed. Switch owners or remove those repository groups:%(list_repo_groups)s'
602 601 % {'username': user.username, 'len_repo_groups': len(repo_groups),
603 602 'list_repo_groups': ', '.join(repo_groups)})
604 603
@@ -607,17 +606,17 b' class UserModel(BaseModel):'
607 606 if left_overs and user.user_groups:
608 607 user_groups = [x.users_group_name for x in user.user_groups]
609 608 raise UserOwnsUserGroupsException(
610 u'user "%s" still owns %s user groups and cannot be '
611 u'removed. Switch owners or remove those user groups:%s'
609 'user "%s" still owns %s user groups and cannot be '
610 'removed. Switch owners or remove those user groups:%s'
612 611 % (user.username, len(user_groups), ', '.join(user_groups)))
613 612
614 613 left_overs = self._handle_user_pull_requests(
615 614 user.username, user.user_pull_requests, handle_user, handle_pull_requests)
616 615 if left_overs and user.user_pull_requests:
617 pull_requests = ['!{}'.format(x.pull_request_id) for x in user.user_pull_requests]
616 pull_requests = [f'!{x.pull_request_id}' for x in user.user_pull_requests]
618 617 raise UserOwnsPullRequestsException(
619 u'user "%s" still owns %s pull requests and cannot be '
620 u'removed. Switch owners or remove those pull requests:%s'
618 'user "%s" still owns %s pull requests and cannot be '
619 'removed. Switch owners or remove those pull requests:%s'
621 620 % (user.username, len(pull_requests), ', '.join(pull_requests)))
622 621
623 622 left_overs = self._handle_user_artifacts(
@@ -625,8 +624,8 b' class UserModel(BaseModel):'
625 624 if left_overs and user.artifacts:
626 625 artifacts = [x.file_uid for x in user.artifacts]
627 626 raise UserOwnsArtifactsException(
628 u'user "%s" still owns %s artifacts and cannot be '
629 u'removed. Switch owners or remove those artifacts:%s'
627 'user "%s" still owns %s artifacts and cannot be '
628 'removed. Switch owners or remove those artifacts:%s'
630 629 % (user.username, len(artifacts), ', '.join(artifacts)))
631 630
632 631 user_data = user.get_dict() # fetch user data before expire
@@ -941,7 +940,7 b' class UserModel(BaseModel):'
941 940
942 941 auth_token_role = AuthTokenModel.cls
943 942
944 def add_auth_token(self, user, lifetime_minutes, role, description=u'',
943 def add_auth_token(self, user, lifetime_minutes, role, description='',
945 944 scope_callback=None):
946 945 """
947 946 Add AuthToken for user.
@@ -1,5 +1,3 b''
1
2
3 1 # Copyright (C) 2011-2023 RhodeCode GmbH
4 2 #
5 3 # This program is free software: you can redistribute it and/or modify
@@ -298,7 +296,7 b' class UserGroupModel(BaseModel):'
298 296 assigned_to_repo+assigned_to_repo_group))
299 297
300 298 raise UserGroupAssignedException(
301 'UserGroup assigned to %s' % (assigned,))
299 'UserGroup assigned to {}'.format(assigned))
302 300 self.sa.delete(user_group)
303 301 except Exception:
304 302 log.error(traceback.format_exc())
@@ -710,7 +708,7 b' class UserGroupModel(BaseModel):'
710 708 query = query.filter(UserGroup.users_group_active == true())
711 709
712 710 if name_contains:
713 ilike_expression = u'%{}%'.format(safe_str(name_contains))
711 ilike_expression = f'%{safe_str(name_contains)}%'
714 712 query = query.filter(
715 713 UserGroup.users_group_name.ilike(ilike_expression))\
716 714 .order_by(func.length(UserGroup.users_group_name))\
@@ -1,5 +1,3 b''
1
2
3 1 # Copyright (C) 2016-2023 RhodeCode GmbH
4 2 #
5 3 # This program is free software: you can redistribute it and/or modify
@@ -1,5 +1,3 b''
1
2
3 1 # Copyright (C) 2016-2023 RhodeCode GmbH
4 2 #
5 3 # This program is free software: you can redistribute it and/or modify
@@ -1,5 +1,3 b''
1
2
3 1 # Copyright (C) 2016-2023 RhodeCode GmbH
4 2 #
5 3 # This program is free software: you can redistribute it and/or modify
@@ -1,5 +1,3 b''
1
2
3 1 # Copyright (C) 2017-2023 RhodeCode GmbH
4 2 #
5 3 # This program is free software: you can redistribute it and/or modify
@@ -39,13 +37,13 b' def unique_gist_validator(node, value):'
39 37 from rhodecode.model.db import Gist
40 38 existing = Gist.get_by_access_id(value)
41 39 if existing:
42 msg = _(u'Gist with name {} already exists').format(value)
40 msg = _('Gist with name {} already exists').format(value)
43 41 raise colander.Invalid(node, msg)
44 42
45 43
46 44 def filename_validator(node, value):
47 45 if value != os.path.basename(value):
48 msg = _(u'Filename {} cannot be inside a directory').format(value)
46 msg = _('Filename {} cannot be inside a directory').format(value)
49 47 raise colander.Invalid(node, msg)
50 48
51 49
@@ -1,5 +1,3 b''
1
2
3 1 # Copyright (C) 2016-2023 RhodeCode GmbH
4 2 #
5 3 # This program is free software: you can redistribute it and/or modify
@@ -54,7 +52,7 b' def nodes_to_sequence(nodes, colander_no'
54 52 def sequence_to_nodes(nodes, colander_node=None):
55 53
56 54 if not isinstance(nodes, list):
57 msg = 'Nodes needs to be a list, got {}'.format(type(nodes))
55 msg = f'Nodes needs to be a list, got {type(nodes)}'
58 56 raise colander.Invalid(colander_node, msg)
59 57 nodes = Nodes().deserialize(nodes)
60 58
@@ -71,7 +69,7 b' def sequence_to_nodes(nodes, colander_no'
71 69 out[filename].update(file_data_skip)
72 70
73 71 except Exception as e:
74 msg = 'Invalid data format org_exc:`{}`'.format(repr(e))
72 msg = f'Invalid data format org_exc:`{repr(e)}`'
75 73 raise colander.Invalid(colander_node, msg)
76 74 return out
77 75
@@ -1,5 +1,3 b''
1
2
3 1 # Copyright (C) 2016-2023 RhodeCode GmbH
4 2 #
5 3 # This program is free software: you can redistribute it and/or modify
@@ -1,5 +1,3 b''
1
2
3 1 # Copyright (C) 2016-2023 RhodeCode GmbH
4 2 #
5 3 # This program is free software: you can redistribute it and/or modify
@@ -50,15 +48,15 b' def deferred_can_write_to_group_validato'
50 48
51 49 messages = {
52 50 'invalid_parent_repo_group':
53 _(u"Parent repository group `{}` does not exist"),
51 _("Parent repository group `{}` does not exist"),
54 52 # permissions denied we expose as not existing, to prevent
55 53 # resource discovery
56 54 'permission_denied_parent_group':
57 _(u"You do not have the permissions to store "
58 u"repository groups inside repository group `{}`"),
55 _("You do not have the permissions to store "
56 "repository groups inside repository group `{}`"),
59 57 'permission_denied_root':
60 _(u"You do not have the permission to store "
61 u"repository groups in the root location.")
58 _("You do not have the permission to store "
59 "repository groups in the root location.")
62 60 }
63 61
64 62 value = value['repo_group_name']
@@ -124,7 +122,7 b' def deferred_repo_group_owner_validator('
124 122 value = username_converter(value)
125 123 existing = User.get_by_username(value)
126 124 if not existing:
127 msg = _(u'Repo group owner with id `{}` does not exists').format(
125 msg = _('Repo group owner with id `{}` does not exists').format(
128 126 value)
129 127 raise colander.Invalid(node, msg)
130 128
@@ -142,12 +140,12 b' def deferred_unique_name_validator(node,'
142 140
143 141 existing = Repository.get_by_repo_name(value)
144 142 if name_changed and existing:
145 msg = _(u'Repository with name `{}` already exists').format(value)
143 msg = _('Repository with name `{}` already exists').format(value)
146 144 raise colander.Invalid(node, msg)
147 145
148 146 existing_group = RepoGroup.get_by_group_name(value)
149 147 if name_changed and existing_group:
150 msg = _(u'Repository group with name `{}` already exists').format(
148 msg = _('Repository group with name `{}` already exists').format(
151 149 value)
152 150 raise colander.Invalid(node, msg)
153 151 return unique_name_validator
@@ -184,7 +182,7 b' class GroupType(colander.Mapping):'
184 182 if cstruct is colander.null:
185 183 return cstruct
186 184
187 appstruct = super(GroupType, self).deserialize(node, cstruct)
185 appstruct = super().deserialize(node, cstruct)
188 186 validated_name = appstruct['repo_group_name']
189 187
190 188 # inject group based on once deserialized data
@@ -253,7 +251,7 b' class RepoGroupSchema(colander.Schema):'
253 251 permissions, and as last step uniqueness
254 252 """
255 253
256 appstruct = super(RepoGroupSchema, self).deserialize(cstruct)
254 appstruct = super().deserialize(cstruct)
257 255 validated_name = appstruct['repo_group_name']
258 256
259 257 # second pass to validate permissions to repo_group
@@ -1,5 +1,3 b''
1
2
3 1 # Copyright (C) 2016-2023 RhodeCode GmbH
4 2 #
5 3 # This program is free software: you can redistribute it and/or modify
@@ -53,7 +51,7 b' def deferred_repo_owner_validator(node, '
53 51 value = username_converter(value)
54 52 existing = User.get_by_username(value)
55 53 if not existing:
56 msg = _(u'Repo owner with id `{}` does not exists').format(value)
54 msg = _('Repo owner with id `{}` does not exists').format(value)
57 55 raise colander.Invalid(node, msg)
58 56
59 57 return repo_owner_validator
@@ -96,11 +94,11 b' def deferred_fork_of_validator(node, kw)'
96 94 from rhodecode.model.db import Repository, RepoGroup
97 95 existing = Repository.get_by_repo_name(value)
98 96 if not existing:
99 msg = _(u'Fork with id `{}` does not exists').format(value)
97 msg = _('Fork with id `{}` does not exists').format(value)
100 98 raise colander.Invalid(node, msg)
101 99 elif old_values['repo_name'] == existing.repo_name:
102 msg = _(u'Cannot set fork of '
103 u'parameter of this repository to itself').format(value)
100 msg = _('Cannot set fork of '
101 'parameter of this repository to itself').format(value)
104 102 raise colander.Invalid(node, msg)
105 103
106 104 return fork_of_validator
@@ -124,14 +122,14 b' def deferred_can_write_to_group_validato'
124 122
125 123 messages = {
126 124 'invalid_repo_group':
127 _(u"Repository group `{}` does not exist"),
125 _("Repository group `{}` does not exist"),
128 126 # permissions denied we expose as not existing, to prevent
129 127 # resource discovery
130 128 'permission_denied':
131 _(u"Repository group `{}` does not exist"),
129 _("Repository group `{}` does not exist"),
132 130 'permission_denied_root':
133 _(u"You do not have the permission to store "
134 u"repositories in the root location.")
131 _("You do not have the permission to store "
132 "repositories in the root location.")
135 133 }
136 134
137 135 value = value['repo_group_name']
@@ -215,12 +213,12 b' def deferred_unique_name_validator(node,'
215 213
216 214 existing = Repository.get_by_repo_name(value)
217 215 if name_changed and existing:
218 msg = _(u'Repository with name `{}` already exists').format(value)
216 msg = _('Repository with name `{}` already exists').format(value)
219 217 raise colander.Invalid(node, msg)
220 218
221 219 existing_group = RepoGroup.get_by_group_name(value)
222 220 if name_changed and existing_group:
223 msg = _(u'Repository group with name `{}` already exists').format(
221 msg = _('Repository group with name `{}` already exists').format(
224 222 value)
225 223 raise colander.Invalid(node, msg)
226 224 return unique_name_validator
@@ -271,7 +269,7 b' class GroupType(colander.Mapping):'
271 269 if cstruct is colander.null:
272 270 return cstruct
273 271
274 appstruct = super(GroupType, self).deserialize(node, cstruct)
272 appstruct = super().deserialize(node, cstruct)
275 273 validated_name = appstruct['repo_group_name']
276 274
277 275 # inject group based on once deserialized data
@@ -380,7 +378,7 b' class RepoSchema(colander.MappingSchema)'
380 378 """
381 379
382 380 # first pass, to validate given data
383 appstruct = super(RepoSchema, self).deserialize(cstruct)
381 appstruct = super().deserialize(cstruct)
384 382 validated_name = appstruct['repo_name']
385 383
386 384 # second pass to validate permissions to repo_group
@@ -1,5 +1,3 b''
1
2
3 1 # Copyright (C) 2016-2023 RhodeCode GmbH
4 2 #
5 3 # This program is free software: you can redistribute it and/or modify
@@ -1,5 +1,3 b''
1
2
3 1 # Copyright (C) 2016-2023 RhodeCode GmbH
4 2 #
5 3 # This program is free software: you can redistribute it and/or modify
@@ -30,7 +28,7 b' def sort_validator(node, value):'
30 28 if value.startswith('desc:'):
31 29 return value
32 30
33 msg = u'Invalid search sort, must be `oldfirst`, `newfirst`, or start with asc: or desc:'
31 msg = 'Invalid search sort, must be `oldfirst`, `newfirst`, or start with asc: or desc:'
34 32 raise colander.Invalid(node, msg)
35 33
36 34
@@ -1,5 +1,3 b''
1
2
3 1 # Copyright (C) 2016-2023 RhodeCode GmbH
4 2 #
5 3 # This program is free software: you can redistribute it and/or modify
@@ -47,7 +45,7 b' def deferred_user_group_owner_validator('
47 45 value = username_converter(value)
48 46 existing = User.get_by_username(value)
49 47 if not existing:
50 msg = _(u'User group owner with id `{}` does not exists').format(value)
48 msg = _('User group owner with id `{}` does not exists').format(value)
51 49 raise colander.Invalid(node, msg)
52 50
53 51 return owner_validator
@@ -76,5 +74,5 b' class UserGroupSchema(colander.Schema):'
76 74 permissions, and as last step uniqueness
77 75 """
78 76
79 appstruct = super(UserGroupSchema, self).deserialize(cstruct)
77 appstruct = super().deserialize(cstruct)
80 78 return appstruct
@@ -1,5 +1,3 b''
1
2
3 1 # Copyright (C) 2016-2023 RhodeCode GmbH
4 2 #
5 3 # This program is free software: you can redistribute it and/or modify
@@ -69,9 +67,9 b' def deferred_username_validator(node, kw'
69 67
70 68 def name_validator(node, value):
71 69 msg = _(
72 u'Username may only contain alphanumeric characters '
73 u'underscores, periods or dashes and must begin with '
74 u'alphanumeric character or underscore')
70 'Username may only contain alphanumeric characters '
71 'underscores, periods or dashes and must begin with '
72 'alphanumeric character or underscore')
75 73
76 74 if not re.match(r'^[\w]{1}[\w\-\.]{0,254}$', value):
77 75 raise colander.Invalid(node, msg)
@@ -126,7 +124,7 b' class UserSchema(colander.Schema):'
126 124 permissions, and as last step uniqueness
127 125 """
128 126
129 appstruct = super(UserSchema, self).deserialize(cstruct)
127 appstruct = super().deserialize(cstruct)
130 128 return appstruct
131 129
132 130
@@ -145,7 +143,7 b' def deferred_additional_email_validator('
145 143 raise colander.Invalid(node, msg)
146 144 user = User.get_by_email(value, case_insensitive=True)
147 145 if user:
148 msg = _(u'This e-mail address is already taken')
146 msg = _('This e-mail address is already taken')
149 147 raise colander.Invalid(node, msg)
150 148 c = colander.Email()
151 149 return c(node, value)
@@ -1,5 +1,3 b''
1
2
3 1 # Copyright (C) 2016-2023 RhodeCode GmbH
4 2 #
5 3 # This program is free software: you can redistribute it and/or modify
@@ -62,7 +60,7 b' class RepoNameType(colander.String):'
62 60 SEPARATOR = '/'
63 61
64 62 def deserialize(self, node, cstruct):
65 result = super(RepoNameType, self).deserialize(node, cstruct)
63 result = super().deserialize(node, cstruct)
66 64 if cstruct is colander.null:
67 65 return colander.null
68 66 return self._normalize(result)
@@ -78,7 +76,7 b' class GroupNameType(colander.String):'
78 76 if cstruct is RootLocation:
79 77 return cstruct
80 78
81 result = super(GroupNameType, self).deserialize(node, cstruct)
79 result = super().deserialize(node, cstruct)
82 80 if cstruct is colander.null:
83 81 return colander.null
84 82 return self._normalize(result)
@@ -116,7 +114,7 b' class StringBooleanType(colander.String)'
116 114 return False
117 115 else:
118 116 raise colander.Invalid(
119 node, '{} value cannot be translated to bool'.format(value))
117 node, f'{value} value cannot be translated to bool')
120 118
121 119
122 120 class UserOrUserGroupType(colander.SchemaType):
@@ -144,7 +142,7 b' class UserOrUserGroupType(colander.Schem'
144 142 return appstruct.users_group_name
145 143
146 144 raise colander.Invalid(
147 node, '%s is not a valid %s' % (appstruct, ' or '.join(self.scopes)))
145 node, '{} is not a valid {}'.format(appstruct, ' or '.join(self.scopes)))
148 146
149 147 def deserialize(self, node, cstruct):
150 148 if cstruct is colander.null:
@@ -177,7 +175,7 b' class UserOrUserGroupType(colander.Schem'
177 175 return usergroup
178 176
179 177 raise colander.Invalid(
180 node, '%s is not a valid %s' % (cstruct, ' or '.join(self.scopes)))
178 node, '{} is not a valid {}'.format(cstruct, ' or '.join(self.scopes)))
181 179
182 180
183 181 class UserType(UserOrUserGroupType):
@@ -191,6 +189,6 b' class UserGroupType(UserOrUserGroupType)'
191 189 class StrOrIntType(colander.String):
192 190 def deserialize(self, node, cstruct):
193 191 if isinstance(cstruct, str):
194 return super(StrOrIntType, self).deserialize(node, cstruct)
192 return super().deserialize(node, cstruct)
195 193 else:
196 194 return colander.Integer().deserialize(node, cstruct)
@@ -1,5 +1,3 b''
1
2
3 1 # Copyright (C) 2016-2023 RhodeCode GmbH
4 2 #
5 3 # This program is free software: you can redistribute it and/or modify
@@ -1,5 +1,3 b''
1
2
3 1 # Copyright (C) 2011-2023 RhodeCode GmbH
4 2 #
5 3 # This program is free software: you can redistribute it and/or modify
@@ -120,7 +118,7 b' def url_validator(url, repo_type, config'
120 118 # no validation for SVN yet
121 119 return
122 120
123 raise InvalidCloneUrl('Invalid repo type specified: `{}`'.format(repo_type))
121 raise InvalidCloneUrl(f'Invalid repo type specified: `{repo_type}`')
124 122
125 123
126 124 class CloneUriValidator(object):
@@ -157,5 +155,5 b' def json_validator_with_exc(node, value)'
157 155 try:
158 156 json.loads(value)
159 157 except (Exception,) as e:
160 msg = _('Please enter a valid json object: `{}`'.format(e))
158 msg = _(f'Please enter a valid json object: `{e}`')
161 159 raise colander.Invalid(node, msg)
@@ -1,5 +1,3 b''
1
2
3 1 # Copyright (C) 2011-2023 RhodeCode GmbH
4 2 #
5 3 # This program is free software: you can redistribute it and/or modify
@@ -1,4 +1,3 b''
1
2 1 # Copyright (C) 2010-2023 RhodeCode GmbH
3 2 #
4 3 # This program is free software: you can redistribute it and/or modify
@@ -1,4 +1,3 b''
1
2 1 # Copyright (C) 2010-2023 RhodeCode GmbH
3 2 #
4 3 # This program is free software: you can redistribute it and/or modify
@@ -370,7 +369,7 b' class AsyncSubprocessSubscriber(AsyncSub'
370 369 def __init__(self, cmd, timeout=None):
371 370 if not isinstance(cmd, (list, tuple)):
372 371 cmd = shlex.split(cmd)
373 super(AsyncSubprocessSubscriber, self).__init__()
372 super().__init__()
374 373 self._cmd = cmd
375 374 self._timeout = timeout
376 375
@@ -1,4 +1,3 b''
1
2 1 # Copyright (C) 2010-2023 RhodeCode GmbH
3 2 #
4 3 # This program is free software: you can redistribute it and/or modify
@@ -1,4 +1,3 b''
1
2 1 # Copyright (C) 2010-2023 RhodeCode GmbH
3 2 #
4 3 # This program is free software: you can redistribute it and/or modify
General Comments 0
You need to be logged in to leave comments. Login now