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