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