##// END OF EJS Templates
apps: modernize for python3
super-admin -
r5093:525812a8 default
parent child Browse files
Show More
@@ -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
@@ -56,8 +54,8 b' URL_NAME_REQUIREMENTS = {'
56 # file path eats up everything at the end
54 # file path eats up everything at the end
57 'f_path': r'.*',
55 'f_path': r'.*',
58 # reference types
56 # reference types
59 'source_ref_type': '(branch|book|tag|rev|\%\(source_ref_type\)s)',
57 'source_ref_type': r'(branch|book|tag|rev|\%\(source_ref_type\)s)',
60 'target_ref_type': '(branch|book|tag|rev|\%\(target_ref_type\)s)',
58 'target_ref_type': r'(branch|book|tag|rev|\%\(target_ref_type\)s)',
61 }
59 }
62
60
63
61
@@ -94,7 +92,7 b' def _format_ref_id(name, raw_id):'
94
92
95 def _format_ref_id_svn(name, raw_id):
93 def _format_ref_id_svn(name, raw_id):
96 """Special way of formatting a reference for Subversion including path"""
94 """Special way of formatting a reference for Subversion including path"""
97 return '%s@%s' % (name, raw_id)
95 return '{}@{}'.format(name, raw_id)
98
96
99
97
100 class TemplateArgs(StrictAttributeDict):
98 class TemplateArgs(StrictAttributeDict):
@@ -231,7 +229,7 b' class BaseAppView(object):'
231 class RepoAppView(BaseAppView):
229 class RepoAppView(BaseAppView):
232
230
233 def __init__(self, context, request):
231 def __init__(self, context, request):
234 super(RepoAppView, self).__init__(context, request)
232 super().__init__(context, request)
235 self.db_repo = request.db_repo
233 self.db_repo = request.db_repo
236 self.db_repo_name = self.db_repo.repo_name
234 self.db_repo_name = self.db_repo.repo_name
237 self.db_repo_pull_requests = ScmModel().get_pull_requests(self.db_repo)
235 self.db_repo_pull_requests = ScmModel().get_pull_requests(self.db_repo)
@@ -261,7 +259,7 b' class RepoAppView(BaseAppView):'
261
259
262 def _get_local_tmpl_context(self, include_app_defaults=True):
260 def _get_local_tmpl_context(self, include_app_defaults=True):
263 _ = self.request.translate
261 _ = self.request.translate
264 c = super(RepoAppView, self)._get_local_tmpl_context(
262 c = super()._get_local_tmpl_context(
265 include_app_defaults=include_app_defaults)
263 include_app_defaults=include_app_defaults)
266
264
267 # register common vars for this type of view
265 # register common vars for this type of view
@@ -353,7 +351,7 b' class RepoAppView(BaseAppView):'
353 return None, None
351 return None, None
354 landing_commit_id = landing_commit.raw_id
352 landing_commit_id = landing_commit.raw_id
355
353
356 cache_namespace_uid = 'repo.{}'.format(db_repo.repo_id)
354 cache_namespace_uid = f'repo.{db_repo.repo_id}'
357 region = rc_cache.get_or_create_region('cache_repo', cache_namespace_uid, use_async_runner=True)
355 region = rc_cache.get_or_create_region('cache_repo', cache_namespace_uid, use_async_runner=True)
358 start = time.time()
356 start = time.time()
359
357
@@ -477,13 +475,13 b' class PathFilter(object):'
477
475
478 class RepoGroupAppView(BaseAppView):
476 class RepoGroupAppView(BaseAppView):
479 def __init__(self, context, request):
477 def __init__(self, context, request):
480 super(RepoGroupAppView, self).__init__(context, request)
478 super().__init__(context, request)
481 self.db_repo_group = request.db_repo_group
479 self.db_repo_group = request.db_repo_group
482 self.db_repo_group_name = self.db_repo_group.group_name
480 self.db_repo_group_name = self.db_repo_group.group_name
483
481
484 def _get_local_tmpl_context(self, include_app_defaults=True):
482 def _get_local_tmpl_context(self, include_app_defaults=True):
485 _ = self.request.translate
483 _ = self.request.translate
486 c = super(RepoGroupAppView, self)._get_local_tmpl_context(
484 c = super()._get_local_tmpl_context(
487 include_app_defaults=include_app_defaults)
485 include_app_defaults=include_app_defaults)
488 c.repo_group = self.db_repo_group
486 c.repo_group = self.db_repo_group
489 return c
487 return c
@@ -502,14 +500,14 b' class RepoGroupAppView(BaseAppView):'
502
500
503 class UserGroupAppView(BaseAppView):
501 class UserGroupAppView(BaseAppView):
504 def __init__(self, context, request):
502 def __init__(self, context, request):
505 super(UserGroupAppView, self).__init__(context, request)
503 super().__init__(context, request)
506 self.db_user_group = request.db_user_group
504 self.db_user_group = request.db_user_group
507 self.db_user_group_name = self.db_user_group.users_group_name
505 self.db_user_group_name = self.db_user_group.users_group_name
508
506
509
507
510 class UserAppView(BaseAppView):
508 class UserAppView(BaseAppView):
511 def __init__(self, context, request):
509 def __init__(self, context, request):
512 super(UserAppView, self).__init__(context, request)
510 super().__init__(context, request)
513 self.db_user = request.db_user
511 self.db_user = request.db_user
514 self.db_user_id = self.db_user.user_id
512 self.db_user_id = self.db_user.user_id
515
513
@@ -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,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
@@ -80,7 +78,7 b' class ExceptionsTrackerView(BaseAppView)'
80 exc_metadata = exc_tracking.exc_unserialize(f.read())
78 exc_metadata = exc_tracking.exc_unserialize(f.read())
81 exc.update(exc_metadata)
79 exc.update(exc_metadata)
82 except Exception:
80 except Exception:
83 log.exception('Failed to read exc data from:{}'.format(full_path))
81 log.exception(f'Failed to read exc data from:{full_path}')
84 pass
82 pass
85 # convert our timestamp to a date obj, for nicer representation
83 # convert our timestamp to a date obj, for nicer representation
86 exc['exc_utc_date'] = time_to_utcdatetime(exc['exc_timestamp'])
84 exc['exc_utc_date'] = time_to_utcdatetime(exc['exc_timestamp'])
@@ -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
@@ -410,7 +408,7 b' class AdminPermissionsView(BaseAppView, '
410 base_q = UserSshKeys.query().join(UserSshKeys.user)
408 base_q = UserSshKeys.query().join(UserSshKeys.user)
411
409
412 if search_q:
410 if search_q:
413 like_expression = u'%{}%'.format(safe_str(search_q))
411 like_expression = f'%{safe_str(search_q)}%'
414 base_q = base_q.filter(or_(
412 base_q = base_q.filter(or_(
415 User.username.ilike(like_expression),
413 User.username.ilike(like_expression),
416 UserSshKeys.ssh_key_fingerprint.ilike(like_expression),
414 UserSshKeys.ssh_key_fingerprint.ilike(like_expression),
@@ -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
@@ -132,14 +130,14 b' class AdminProcessManagementView(BaseApp'
132 try:
130 try:
133 p.terminate()
131 p.terminate()
134 except psutil.AccessDenied as e:
132 except psutil.AccessDenied as e:
135 log.warning('Access denied: {}'.format(e))
133 log.warning(f'Access denied: {e}')
136
134
137 gone, alive = psutil.wait_procs(procs, timeout=10, callback=on_terminate)
135 gone, alive = psutil.wait_procs(procs, timeout=10, callback=on_terminate)
138 for p in alive:
136 for p in alive:
139 try:
137 try:
140 p.kill()
138 p.kill()
141 except psutil.AccessDenied as e:
139 except psutil.AccessDenied as e:
142 log.warning('Access denied: {}'.format(e))
140 log.warning(f'Access denied: {e}')
143
141
144 return {'result': result}
142 return {'result': result}
145
143
@@ -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
@@ -182,7 +180,7 b' class AdminRepoGroupsView(BaseAppView, D'
182 base_q = base_q.group_by(RepoGroup, OwnerUser)
180 base_q = base_q.group_by(RepoGroup, OwnerUser)
183
181
184 if search_q:
182 if search_q:
185 like_expression = u'%{}%'.format(safe_str(search_q))
183 like_expression = f'%{safe_str(search_q)}%'
186 base_q = base_q.filter(or_(
184 base_q = base_q.filter(or_(
187 RepoGroup.group_name.ilike(like_expression),
185 RepoGroup.group_name.ilike(like_expression),
188 ))
186 ))
@@ -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
@@ -117,7 +115,7 b' class AdminReposView(BaseAppView, DataGr'
117 .join(OwnerUser, Repository.user_id == OwnerUser.user_id)
115 .join(OwnerUser, Repository.user_id == OwnerUser.user_id)
118
116
119 if search_q:
117 if search_q:
120 like_expression = u'%{}%'.format(safe_str(search_q))
118 like_expression = f'%{safe_str(search_q)}%'
121 base_q = base_q.filter(or_(
119 base_q = base_q.filter(or_(
122 Repository.repo_name.ilike(like_expression),
120 Repository.repo_name.ilike(like_expression),
123 ))
121 ))
@@ -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
@@ -464,7 +463,7 b' class AdminSettingsView(BaseAppView):'
464 except formencode.Invalid as errors:
463 except formencode.Invalid as errors:
465 log.exception('Failed to add new pattern')
464 log.exception('Failed to add new pattern')
466 error = errors
465 error = errors
467 h.flash(_('Invalid issue tracker pattern: {}'.format(error)),
466 h.flash(_(f'Invalid issue tracker pattern: {error}'),
468 category='error')
467 category='error')
469 raise HTTPFound(h.route_path('admin_settings_issuetracker'))
468 raise HTTPFound(h.route_path('admin_settings_issuetracker'))
470
469
@@ -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
@@ -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
@@ -399,7 +397,7 b' class MyAccountView(BaseAppView, DataGri'
399 channelstream_request(channelstream_config, [payload], '/message')
397 channelstream_request(channelstream_config, [payload], '/message')
400 except ChannelstreamException as e:
398 except ChannelstreamException as e:
401 log.exception('Failed to send channelstream data')
399 log.exception('Failed to send channelstream data')
402 return {"response": 'ERROR: {}'.format(e.__class__.__name__)}
400 return {"response": f'ERROR: {e.__class__.__name__}'}
403 return {"response": 'Channelstream data sent. '
401 return {"response": 'Channelstream data sent. '
404 'You should see a new live message now.'}
402 'You should see a new live message now.'}
405
403
@@ -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
@@ -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,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) 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,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,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,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,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,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,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
@@ -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,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,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,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
@@ -52,7 +50,7 b' class RepoCachesView(RepoAppView):'
52 c.cached_diff_size = system_info.get_storage_size(cached_diffs_dir)
50 c.cached_diff_size = system_info.get_storage_size(cached_diffs_dir)
53 c.shadow_repos = c.rhodecode_db_repo.shadow_repos()
51 c.shadow_repos = c.rhodecode_db_repo.shadow_repos()
54
52
55 cache_namespace_uid = 'repo.{}'.format(self.db_repo.repo_id)
53 cache_namespace_uid = f'repo.{self.db_repo.repo_id}'
56 c.region = rc_cache.get_or_create_region('cache_repo', cache_namespace_uid)
54 c.region = rc_cache.get_or_create_region('cache_repo', cache_namespace_uid)
57 c.backend = c.region.backend
55 c.backend = c.region.backend
58 c.repo_keys = sorted(c.region.backend.list_keys(prefix=cache_namespace_uid))
56 c.repo_keys = sorted(c.region.backend.list_keys(prefix=cache_namespace_uid))
@@ -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
@@ -111,7 +110,7 b' class RepoChangelogView(RepoAppView):'
111
110
112 def _check_if_valid_branch(self, branch_name, repo_name, f_path):
111 def _check_if_valid_branch(self, branch_name, repo_name, f_path):
113 if branch_name not in self.rhodecode_vcs_repo.branches_all:
112 if branch_name not in self.rhodecode_vcs_repo.branches_all:
114 h.flash(u'Branch {} is not found.'.format(h.escape(safe_str(branch_name))),
113 h.flash(f'Branch {h.escape(safe_str(branch_name))} is not found.',
115 category='warning')
114 category='warning')
116 redirect_url = h.route_path(
115 redirect_url = h.route_path(
117 'repo_commits_file', repo_name=repo_name,
116 'repo_commits_file', repo_name=repo_name,
@@ -300,7 +299,7 b' class RepoChangelogView(RepoAppView):'
300 c.selected_name = branch_name or book_name
299 c.selected_name = branch_name or book_name
301 if branch_name and branch_name not in self.rhodecode_vcs_repo.branches_all:
300 if branch_name and branch_name not in self.rhodecode_vcs_repo.branches_all:
302 return wrap_for_error(
301 return wrap_for_error(
303 safe_str('Branch: {} is not valid'.format(branch_name)))
302 safe_str(f'Branch: {branch_name} is not valid'))
304
303
305 pre_load = self.get_commit_preload_attrs()
304 pre_load = self.get_commit_preload_attrs()
306
305
@@ -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
@@ -383,7 +382,7 b' class RepoCommitsView(RepoAppView):'
383 resolves_comment_id = entry['resolves_comment_id']
382 resolves_comment_id = entry['resolves_comment_id']
384 f_path = entry['f_path']
383 f_path = entry['f_path']
385 line_no = entry['line']
384 line_no = entry['line']
386 target_elem_id = 'file-{}'.format(h.safeid(h.safe_str(f_path)))
385 target_elem_id = f'file-{h.safeid(h.safe_str(f_path))}'
387
386
388 if status:
387 if status:
389 text = text or (_('Status change %(transition_icon)s %(status)s')
388 text = text or (_('Status change %(transition_icon)s %(status)s')
@@ -579,7 +578,7 b' class RepoCommitsView(RepoAppView):'
579 self.request.response.status = 400
578 self.request.response.status = 400
580 return {'store_fid': None,
579 return {'store_fid': None,
581 'access_path': None,
580 'access_path': None,
582 'error': '{} data field is missing'.format(upload_key)}
581 'error': f'{upload_key} data field is missing'}
583
582
584 if not hasattr(file_obj, 'filename'):
583 if not hasattr(file_obj, 'filename'):
585 self.request.response.status = 400
584 self.request.response.status = 400
@@ -628,7 +627,7 b' class RepoCommitsView(RepoAppView):'
628 file_uid=store_uid, filename=metadata["filename"],
627 file_uid=store_uid, filename=metadata["filename"],
629 file_hash=metadata["sha256"], file_size=metadata["size"],
628 file_hash=metadata["sha256"], file_size=metadata["size"],
630 file_display_name=file_display_name,
629 file_display_name=file_display_name,
631 file_description=u'comment attachment `{}`'.format(safe_str(filename)),
630 file_description=f'comment attachment `{safe_str(filename)}`',
632 hidden=True, check_acl=True, user_id=self._rhodecode_user.user_id,
631 hidden=True, check_acl=True, user_id=self._rhodecode_user.user_id,
633 scope_repo_id=self.db_repo.repo_id
632 scope_repo_id=self.db_repo.repo_id
634 )
633 )
@@ -640,7 +639,7 b' class RepoCommitsView(RepoAppView):'
640 self.request.response.status = 400
639 self.request.response.status = 400
641 return {'store_fid': None,
640 return {'store_fid': None,
642 'access_path': None,
641 'access_path': None,
643 'error': 'File {} failed to store in DB.'.format(filename)}
642 'error': f'File {filename} failed to store in DB.'}
644
643
645 Session().commit()
644 Session().commit()
646
645
@@ -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) 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
@@ -99,7 +97,7 b' class RepoFeedView(RepoAppView):'
99 has_hidden_changes=has_hidden_changes
97 has_hidden_changes=has_hidden_changes
100 )
98 )
101
99
102 def _set_timezone(self, date, tzinfo=datetime.timezone.utc):
100 def _set_timezone(self, date, tzinfo=datetime.UTC):
103 if not getattr(date, "tzinfo", None):
101 if not getattr(date, "tzinfo", None):
104 date.replace(tzinfo=tzinfo)
102 date.replace(tzinfo=tzinfo)
105 return date
103 return date
@@ -131,7 +129,7 b' class RepoFeedView(RepoAppView):'
131 self.load_default_context()
129 self.load_default_context()
132 force_recache = self.get_recache_flag()
130 force_recache = self.get_recache_flag()
133
131
134 cache_namespace_uid = 'repo_feed.{}'.format(self.db_repo.repo_id)
132 cache_namespace_uid = f'repo_feed.{self.db_repo.repo_id}'
135 condition = not (self.path_filter.is_enabled or force_recache)
133 condition = not (self.path_filter.is_enabled or force_recache)
136 region = rc_cache.get_or_create_region('cache_repo', cache_namespace_uid)
134 region = rc_cache.get_or_create_region('cache_repo', cache_namespace_uid)
137
135
@@ -178,7 +176,7 b' class RepoFeedView(RepoAppView):'
178 self.load_default_context()
176 self.load_default_context()
179 force_recache = self.get_recache_flag()
177 force_recache = self.get_recache_flag()
180
178
181 cache_namespace_uid = 'repo_feed.{}'.format(self.db_repo.repo_id)
179 cache_namespace_uid = f'repo_feed.{self.db_repo.repo_id}'
182 condition = not (self.path_filter.is_enabled or force_recache)
180 condition = not (self.path_filter.is_enabled or force_recache)
183 region = rc_cache.get_or_create_region('cache_repo', cache_namespace_uid)
181 region = rc_cache.get_or_create_region('cache_repo', cache_namespace_uid)
184
182
@@ -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
@@ -312,7 +310,7 b' class RepoFilesView(RepoAppView):'
312 'with caching: %s[TTL: %ss]' % (
310 'with caching: %s[TTL: %ss]' % (
313 repo_id, commit_id, f_path, cache_on, cache_seconds or 0))
311 repo_id, commit_id, f_path, cache_on, cache_seconds or 0))
314
312
315 cache_namespace_uid = 'repo.{}'.format(repo_id)
313 cache_namespace_uid = f'repo.{repo_id}'
316 region = rc_cache.get_or_create_region('cache_repo', cache_namespace_uid)
314 region = rc_cache.get_or_create_region('cache_repo', cache_namespace_uid)
317
315
318 @region.conditional_cache_on_arguments(namespace=cache_namespace_uid, condition=cache_on)
316 @region.conditional_cache_on_arguments(namespace=cache_namespace_uid, condition=cache_on)
@@ -387,7 +385,7 b' class RepoFilesView(RepoAppView):'
387
385
388 # we used a ref, or a shorter version, lets redirect client ot use explicit hash
386 # we used a ref, or a shorter version, lets redirect client ot use explicit hash
389 if commit_id != commit.raw_id:
387 if commit_id != commit.raw_id:
390 fname='{}{}'.format(commit.raw_id, ext)
388 fname=f'{commit.raw_id}{ext}'
391 raise HTTPFound(self.request.current_route_path(fname=fname))
389 raise HTTPFound(self.request.current_route_path(fname=fname))
392
390
393 try:
391 try:
@@ -772,7 +770,7 b' class RepoFilesView(RepoAppView):'
772 prev_url = h.route_path(
770 prev_url = h.route_path(
773 'repo_files:annotated', repo_name=self.db_repo_name,
771 'repo_files:annotated', repo_name=self.db_repo_name,
774 commit_id=prev_commit_id, f_path=f_path,
772 commit_id=prev_commit_id, f_path=f_path,
775 _anchor='L{}'.format(line_anchor))
773 _anchor=f'L{line_anchor}')
776
774
777 raise HTTPFound(prev_url)
775 raise HTTPFound(prev_url)
778
776
@@ -792,7 +790,7 b' class RepoFilesView(RepoAppView):'
792 try:
790 try:
793 dir_node = commit.get_node(f_path)
791 dir_node = commit.get_node(f_path)
794 except RepositoryError as e:
792 except RepositoryError as e:
795 return Response('error: {}'.format(h.escape(safe_str(e))))
793 return Response(f'error: {h.escape(safe_str(e))}')
796
794
797 if dir_node.is_file():
795 if dir_node.is_file():
798 return Response('')
796 return Response('')
@@ -921,7 +919,7 b' class RepoFilesView(RepoAppView):'
921 'with caching: %s[TTL: %ss]' % (
919 'with caching: %s[TTL: %ss]' % (
922 repo_id, commit_id, f_path, cache_on, cache_seconds or 0))
920 repo_id, commit_id, f_path, cache_on, cache_seconds or 0))
923
921
924 cache_namespace_uid = 'repo.{}'.format(repo_id)
922 cache_namespace_uid = f'repo.{repo_id}'
925 region = rc_cache.get_or_create_region('cache_repo', cache_namespace_uid)
923 region = rc_cache.get_or_create_region('cache_repo', cache_namespace_uid)
926
924
927 @region.conditional_cache_on_arguments(namespace=cache_namespace_uid, condition=cache_on)
925 @region.conditional_cache_on_arguments(namespace=cache_namespace_uid, condition=cache_on)
@@ -998,7 +996,7 b' class RepoFilesView(RepoAppView):'
998 commits_group = ([], _("Changesets"))
996 commits_group = ([], _("Changesets"))
999 for commit in commits:
997 for commit in commits:
1000 branch = ' (%s)' % commit.branch if commit.branch else ''
998 branch = ' (%s)' % commit.branch if commit.branch else ''
1001 n_desc = 'r%s:%s%s' % (commit.idx, commit.short_id, branch)
999 n_desc = 'r{}:{}{}'.format(commit.idx, commit.short_id, branch)
1002 commits_group[0].append((commit.raw_id, n_desc, 'sha'))
1000 commits_group[0].append((commit.raw_id, n_desc, 'sha'))
1003 history.append(commits_group)
1001 history.append(commits_group)
1004
1002
@@ -1086,7 +1084,7 b' class RepoFilesView(RepoAppView):'
1086 c.file_last_commit = file_node.last_commit
1084 c.file_last_commit = file_node.last_commit
1087 if self.request.GET.get('annotate') == '1':
1085 if self.request.GET.get('annotate') == '1':
1088 # use _hist from annotation if annotation mode is on
1086 # use _hist from annotation if annotation mode is on
1089 commit_ids = set(x[1] for x in file_node.annotate)
1087 commit_ids = {x[1] for x in file_node.annotate}
1090 _hist = (
1088 _hist = (
1091 self.rhodecode_vcs_repo.get_commit(commit_id)
1089 self.rhodecode_vcs_repo.get_commit(commit_id)
1092 for commit_id in commit_ids)
1090 for commit_id in commit_ids)
@@ -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
@@ -102,7 +100,7 b' class RepoForksView(RepoAppView, DataGri'
102 .filter(Repository.repo_id.in_(allowed_ids))\
100 .filter(Repository.repo_id.in_(allowed_ids))\
103
101
104 if search_q:
102 if search_q:
105 like_expression = u'%{}%'.format(safe_str(search_q))
103 like_expression = f'%{safe_str(search_q)}%'
106 base_q = base_q.filter(or_(
104 base_q = base_q.filter(or_(
107 Repository.repo_name.ilike(like_expression),
105 Repository.repo_name.ilike(like_expression),
108 Repository.description.ilike(like_expression),
106 Repository.description.ilike(like_expression),
@@ -174,7 +172,7 b' class RepoForksView(RepoAppView, DataGri'
174 defaults = RepoModel()._get_defaults(self.db_repo_name)
172 defaults = RepoModel()._get_defaults(self.db_repo_name)
175 # alter the description to indicate a fork
173 # alter the description to indicate a fork
176 defaults['description'] = (
174 defaults['description'] = (
177 'fork of repository: %s \n%s' % (
175 'fork of repository: {} \n{}'.format(
178 defaults['repo_name'], defaults['description']))
176 defaults['repo_name'], defaults['description']))
179 # add suffix to fork
177 # add suffix to fork
180 defaults['repo_name'] = '%s-fork' % defaults['repo_name']
178 defaults['repo_name'] = '%s-fork' % defaults['repo_name']
@@ -235,7 +233,7 b' class RepoForksView(RepoAppView, DataGri'
235 return Response(html)
233 return Response(html)
236 except Exception:
234 except Exception:
237 log.exception(
235 log.exception(
238 u'Exception while trying to fork the repository %s', self.db_repo_name)
236 'Exception while trying to fork the repository %s', self.db_repo_name)
239 msg = _('An error occurred during repository forking %s') % (self.db_repo_name, )
237 msg = _('An error occurred during repository forking %s') % (self.db_repo_name, )
240 h.flash(msg, category='error')
238 h.flash(msg, category='error')
241 raise HTTPFound(h.route_path('home'))
239 raise HTTPFound(h.route_path('home'))
@@ -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,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,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
@@ -932,7 +930,7 b' class RepoPullRequestsView(RepoAppView, '
932 .filter(Repository.fork_id == self.db_repo.parent.repo_id)
930 .filter(Repository.fork_id == self.db_repo.parent.repo_id)
933
931
934 if filter_query:
932 if filter_query:
935 ilike_expression = u'%{}%'.format(safe_str(filter_query))
933 ilike_expression = f'%{safe_str(filter_query)}%'
936 parents_query = parents_query.filter(
934 parents_query = parents_query.filter(
937 Repository.repo_name.ilike(ilike_expression))
935 Repository.repo_name.ilike(ilike_expression))
938 parents = parents_query.limit(20).all()
936 parents = parents_query.limit(20).all()
@@ -952,7 +950,7 b' class RepoPullRequestsView(RepoAppView, '
952 .filter(~Repository.repo_id.in_([x.repo_id for x in parent_target_repos]))
950 .filter(~Repository.repo_id.in_([x.repo_id for x in parent_target_repos]))
953
951
954 if filter_query:
952 if filter_query:
955 ilike_expression = u'%{}%'.format(safe_str(filter_query))
953 ilike_expression = f'%{safe_str(filter_query)}%'
956 query = query.filter(Repository.repo_name.ilike(ilike_expression))
954 query = query.filter(Repository.repo_name.ilike(ilike_expression))
957
955
958 limit = max(20 - len(parent_target_repos), 5) # not less then 5
956 limit = max(20 - len(parent_target_repos), 5) # not less then 5
@@ -1274,7 +1272,7 b' class RepoPullRequestsView(RepoAppView, '
1274
1272
1275 if pull_request.is_closed():
1273 if pull_request.is_closed():
1276 log.debug('update: forbidden because pull request is closed')
1274 log.debug('update: forbidden because pull request is closed')
1277 msg = _(u'Cannot update closed pull requests.')
1275 msg = _('Cannot update closed pull requests.')
1278 h.flash(msg, category='error')
1276 h.flash(msg, category='error')
1279 return {'response': True,
1277 return {'response': True,
1280 'redirect_url': redirect_url}
1278 'redirect_url': redirect_url}
@@ -1306,8 +1304,8 b' class RepoPullRequestsView(RepoAppView, '
1306 if is_state_changing:
1304 if is_state_changing:
1307 log.debug('commits update: forbidden because pull request is in state %s',
1305 log.debug('commits update: forbidden because pull request is in state %s',
1308 pull_request.pull_request_state)
1306 pull_request.pull_request_state)
1309 msg = _(u'Cannot update pull requests commits in state other than `{}`. '
1307 msg = _('Cannot update pull requests commits in state other than `{}`. '
1310 u'Current state is: `{}`').format(
1308 'Current state is: `{}`').format(
1311 PullRequest.STATE_CREATED, pull_request.pull_request_state)
1309 PullRequest.STATE_CREATED, pull_request.pull_request_state)
1312 h.flash(msg, category='error')
1310 h.flash(msg, category='error')
1313 return {'response': True,
1311 return {'response': True,
@@ -1343,13 +1341,13 b' class RepoPullRequestsView(RepoAppView, '
1343 self.request.POST.get('description_renderer'),
1341 self.request.POST.get('description_renderer'),
1344 self._rhodecode_user)
1342 self._rhodecode_user)
1345 except ValueError:
1343 except ValueError:
1346 msg = _(u'Cannot update closed pull requests.')
1344 msg = _('Cannot update closed pull requests.')
1347 h.flash(msg, category='error')
1345 h.flash(msg, category='error')
1348 return
1346 return
1349 else:
1347 else:
1350 Session().commit()
1348 Session().commit()
1351
1349
1352 msg = _(u'Pull request title & description updated.')
1350 msg = _('Pull request title & description updated.')
1353 h.flash(msg, category='success')
1351 h.flash(msg, category='success')
1354 return
1352 return
1355
1353
@@ -1376,9 +1374,9 b' class RepoPullRequestsView(RepoAppView, '
1376 else:
1374 else:
1377 changed = 'nothing'
1375 changed = 'nothing'
1378
1376
1379 msg = _(u'Pull request updated to "{source_commit_id}" with '
1377 msg = _('Pull request updated to "{source_commit_id}" with '
1380 u'{count_added} added, {count_removed} removed commits. '
1378 '{count_added} added, {count_removed} removed commits. '
1381 u'Source of changes: {change_source}.')
1379 'Source of changes: {change_source}.')
1382 msg = msg.format(
1380 msg = msg.format(
1383 source_commit_id=pull_request.source_ref_parts.commit_id,
1381 source_commit_id=pull_request.source_ref_parts.commit_id,
1384 count_added=len(resp.changes.added),
1382 count_added=len(resp.changes.added),
@@ -1406,7 +1404,7 b' class RepoPullRequestsView(RepoAppView, '
1406 try:
1404 try:
1407 reviewers = validate_default_reviewers(review_members, reviewer_rules)
1405 reviewers = validate_default_reviewers(review_members, reviewer_rules)
1408 except ValueError as e:
1406 except ValueError as e:
1409 log.error('Reviewers Validation: {}'.format(e))
1407 log.error(f'Reviewers Validation: {e}')
1410 h.flash(e, category='error')
1408 h.flash(e, category='error')
1411 return
1409 return
1412
1410
@@ -1432,7 +1430,7 b' class RepoPullRequestsView(RepoAppView, '
1432 try:
1430 try:
1433 observers = validate_observers(review_members, reviewer_rules)
1431 observers = validate_observers(review_members, reviewer_rules)
1434 except ValueError as e:
1432 except ValueError as e:
1435 log.error('Observers Validation: {}'.format(e))
1433 log.error(f'Observers Validation: {e}')
1436 h.flash(e, category='error')
1434 h.flash(e, category='error')
1437 return
1435 return
1438
1436
@@ -1464,8 +1462,8 b' class RepoPullRequestsView(RepoAppView, '
1464 if pull_request.is_state_changing():
1462 if pull_request.is_state_changing():
1465 log.debug('show: forbidden because pull request is in state %s',
1463 log.debug('show: forbidden because pull request is in state %s',
1466 pull_request.pull_request_state)
1464 pull_request.pull_request_state)
1467 msg = _(u'Cannot merge pull requests in state other than `{}`. '
1465 msg = _('Cannot merge pull requests in state other than `{}`. '
1468 u'Current state is: `{}`').format(PullRequest.STATE_CREATED,
1466 'Current state is: `{}`').format(PullRequest.STATE_CREATED,
1469 pull_request.pull_request_state)
1467 pull_request.pull_request_state)
1470 h.flash(msg, category='error')
1468 h.flash(msg, category='error')
1471 raise HTTPFound(
1469 raise HTTPFound(
@@ -1566,7 +1564,7 b' class RepoPullRequestsView(RepoAppView, '
1566 close_pull_request = entry['close_pull_request']
1564 close_pull_request = entry['close_pull_request']
1567 f_path = entry['f_path']
1565 f_path = entry['f_path']
1568 line_no = entry['line']
1566 line_no = entry['line']
1569 target_elem_id = 'file-{}'.format(h.safeid(h.safe_str(f_path)))
1567 target_elem_id = f'file-{h.safeid(h.safe_str(f_path))}'
1570
1568
1571 # the logic here should work like following, if we submit close
1569 # the logic here should work like following, if we submit close
1572 # pr comment, use `close_pull_request_with_comment` function
1570 # pr comment, use `close_pull_request_with_comment` function
@@ -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
@@ -231,7 +229,7 b' class RepoSettingsView(RepoAppView):'
231 c.stats_percentage = 0
229 c.stats_percentage = 0
232 else:
230 else:
233 c.stats_percentage = '%.2f' % (
231 c.stats_percentage = '%.2f' % (
234 (float((last_rev)) / c.repo_last_rev) * 100)
232 (float(last_rev) / c.repo_last_rev) * 100)
235 return self._get_template_context(c)
233 return self._get_template_context(c)
236
234
237 @LoginRequired()
235 @LoginRequired()
@@ -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,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) 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
@@ -110,7 +108,7 b' class RepoSettingsIssueTrackersView(Repo'
110 except formencode.Invalid as errors:
108 except formencode.Invalid as errors:
111 log.exception('Failed to add new pattern')
109 log.exception('Failed to add new pattern')
112 error = errors
110 error = errors
113 h.flash(_('Invalid issue tracker pattern: {}'.format(error)),
111 h.flash(_(f'Invalid issue tracker pattern: {error}'),
114 category='error')
112 category='error')
115 raise HTTPFound(
113 raise HTTPFound(
116 h.route_path('edit_repo_issuetracker',
114 h.route_path('edit_repo_issuetracker',
@@ -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) 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
@@ -161,7 +159,7 b' class RepoSummaryView(RepoAppView):'
161 'with caching: %s[TTL: %ss]' % (
159 'with caching: %s[TTL: %ss]' % (
162 repo_id, landing_commit, cache_on, cache_seconds or 0))
160 repo_id, landing_commit, cache_on, cache_seconds or 0))
163
161
164 cache_namespace_uid = 'repo.{}'.format(repo_id)
162 cache_namespace_uid = f'repo.{repo_id}'
165 region = rc_cache.get_or_create_region('cache_repo', cache_namespace_uid)
163 region = rc_cache.get_or_create_region('cache_repo', cache_namespace_uid)
166
164
167 @region.conditional_cache_on_arguments(namespace=cache_namespace_uid,
165 @region.conditional_cache_on_arguments(namespace=cache_namespace_uid,
@@ -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,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
@@ -195,7 +194,7 b' class TestSearchController(TestControlle'
195 _, kwargs = search_mock.call_args
194 _, kwargs = search_mock.call_args
196 assert isinstance(kwargs['filter'], query.Or)
195 assert isinstance(kwargs['filter'], query.Or)
197 expected_repositories = [
196 expected_repositories = [
198 'vcs_test_{}'.format(b) for b in enabled_backends]
197 f'vcs_test_{b}' for b in enabled_backends]
199 queried_repositories = [
198 queried_repositories = [
200 name for type_, name in kwargs['filter'].all_terms()]
199 name for type_, name in kwargs['filter'].all_terms()]
201 for repository in expected_repositories:
200 for repository in expected_repositories:
@@ -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
@@ -97,7 +95,7 b' def perform_search(request, tmpl_context'
97 search_tags = searcher.extract_search_tags(search_query)
95 search_tags = searcher.extract_search_tags(search_query)
98
96
99 if not search_result['error']:
97 if not search_result['error']:
100 execution_time = '%s results (%.4f seconds)' % (
98 execution_time = '{} results ({:.4f} seconds)'.format(
101 search_result['count'],
99 search_result['count'],
102 search_result['runtime'])
100 search_result['runtime'])
103 elif not errors:
101 elif not errors:
@@ -122,7 +120,7 b' def perform_search(request, tmpl_context'
122 c.sort_tag = None
120 c.sort_tag = None
123 c.sort_tag_dir = direction
121 c.sort_tag_dir = direction
124 if sort_definition:
122 if sort_definition:
125 c.sort = '{}:{}'.format(direction, sort_field)
123 c.sort = f'{direction}:{sort_field}'
126 c.sort_tag = sort_field
124 c.sort_tag = sort_field
127
125
128
126
@@ -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
@@ -107,7 +105,7 b' class VcsServer(object):'
107 'make_lock': None,
105 'make_lock': None,
108 'locked_by': [None, None],
106 'locked_by': [None, None],
109 'server_url': None,
107 'server_url': None,
110 'user_agent': '{}/ssh-user-agent'.format(self.repo_user_agent),
108 'user_agent': f'{self.repo_user_agent}/ssh-user-agent',
111 'hooks': ['push', 'pull'],
109 'hooks': ['push', 'pull'],
112 'hooks_module': 'rhodecode.lib.hooks_daemon',
110 'hooks_module': 'rhodecode.lib.hooks_daemon',
113 'is_shadow_repo': False,
111 'is_shadow_repo': False,
@@ -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
@@ -63,7 +61,7 b' class GitServer(VcsServer):'
63
61
64 def __init__(self, store, ini_path, repo_name, repo_mode,
62 def __init__(self, store, ini_path, repo_name, repo_mode,
65 user, user_permissions, config, env):
63 user, user_permissions, config, env):
66 super(GitServer, self).\
64 super().\
67 __init__(user, user_permissions, config, env)
65 __init__(user, user_permissions, config, env)
68
66
69 self.store = store
67 self.store = store
@@ -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
@@ -101,7 +99,7 b' class MercurialServer(VcsServer):'
101 cli_flags = ['phases', 'largefiles', 'extensions', 'experimental', 'hooks']
99 cli_flags = ['phases', 'largefiles', 'extensions', 'experimental', 'hooks']
102
100
103 def __init__(self, store, ini_path, repo_name, user, user_permissions, config, env):
101 def __init__(self, store, ini_path, repo_name, user, user_permissions, config, env):
104 super(MercurialServer, self).__init__(user, user_permissions, config, env)
102 super().__init__(user, user_permissions, config, env)
105
103
106 self.store = store
104 self.store = store
107 self.ini_path = ini_path
105 self.ini_path = ini_path
@@ -142,7 +140,7 b' class MercurialServer(VcsServer):'
142 flags = []
140 flags = []
143 for _sec, key_val in ui_sections.items():
141 for _sec, key_val in ui_sections.items():
144 flags.append(' ')
142 flags.append(' ')
145 flags.append('[{}]'.format(_sec))
143 flags.append(f'[{_sec}]')
146 for key, val in key_val:
144 for key, val in key_val:
147 flags.append('{}= {}'.format(key, val))
145 flags.append(f'{key}= {val}')
148 return flags
146 return flags
@@ -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
@@ -126,7 +124,7 b' class SubversionTunnelWrapper(object):'
126 def _svn_string(self, str_):
124 def _svn_string(self, str_):
127 if not str_:
125 if not str_:
128 return ''
126 return ''
129 return '{length}:{string} '.format(length=len(str_), string=str_)
127 return f'{len(str_)}:{str_} '
130
128
131 def _read_first_client_response(self):
129 def _read_first_client_response(self):
132 buffer_ = ""
130 buffer_ = ""
@@ -226,7 +224,7 b' class SubversionServer(VcsServer):'
226
224
227 def __init__(self, store, ini_path, repo_name,
225 def __init__(self, store, ini_path, repo_name,
228 user, user_permissions, config, env):
226 user, user_permissions, config, env):
229 super(SubversionServer, self)\
227 super()\
230 .__init__(user, user_permissions, config, env)
228 .__init__(user, user_permissions, config, env)
231 self.store = store
229 self.store = store
232 self.ini_path = ini_path
230 self.ini_path = ini_path
@@ -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,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,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
@@ -31,9 +29,9 b' class TestModDavSvnConfig(object):'
31
29
32 @classmethod
30 @classmethod
33 def setup_class(cls):
31 def setup_class(cls):
34 cls.location_root = u'/location/root/çµäö'
32 cls.location_root = '/location/root/çµäö'
35 cls.parent_path_root = u'/parent/path/çµäö'
33 cls.parent_path_root = '/parent/path/çµäö'
36 cls.realm = u'Dummy Realm (äöüçµ)'
34 cls.realm = 'Dummy Realm (äöüçµ)'
37
35
38 @classmethod
36 @classmethod
39 def get_repo_group_mocks(cls, count=1):
37 def get_repo_group_mocks(cls, count=1):
@@ -47,12 +45,12 b' class TestModDavSvnConfig(object):'
47 return repo_groups
45 return repo_groups
48
46
49 def assert_root_location_directive(self, config):
47 def assert_root_location_directive(self, config):
50 pattern = u'<Location "{location}">'.format(
48 pattern = '<Location "{location}">'.format(
51 location=self.location_root)
49 location=self.location_root)
52 assert len(re.findall(pattern, config)) == 1
50 assert len(re.findall(pattern, config)) == 1
53
51
54 def assert_group_location_directive(self, config, group_path):
52 def assert_group_location_directive(self, config, group_path):
55 pattern = u'<Location "{location}{group_path}">'.format(
53 pattern = '<Location "{location}{group_path}">'.format(
56 location=self.location_root, group_path=group_path)
54 location=self.location_root, group_path=group_path)
57 assert len(re.findall(pattern, config)) == 1
55 assert len(re.findall(pattern, config)) == 1
58
56
@@ -78,7 +76,7 b' class TestModDavSvnConfig(object):'
78 def test_render_mod_dav_svn_config_with_alternative_template(self, tmpdir):
76 def test_render_mod_dav_svn_config_with_alternative_template(self, tmpdir):
79 repo_groups = self.get_repo_group_mocks(count=10)
77 repo_groups = self.get_repo_group_mocks(count=10)
80 test_file_path = os.path.join(str(tmpdir), 'example.mako')
78 test_file_path = os.path.join(str(tmpdir), 'example.mako')
81 with open(test_file_path, 'wt') as f:
79 with open(test_file_path, 'w') as f:
82 f.write('TEST_EXAMPLE\n')
80 f.write('TEST_EXAMPLE\n')
83
81
84 generated_config = utils._render_mod_dav_svn_config(
82 generated_config = utils._render_mod_dav_svn_config(
@@ -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,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,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
General Comments 0
You need to be logged in to leave comments. Login now