Show More
@@ -1,5 +1,3 b'' | |||
|
1 | ||
|
2 | ||
|
3 | 1 |
|
|
4 | 2 | # |
|
5 | 3 | # This program is free software: you can redistribute it and/or modify |
@@ -54,7 +52,7 b' def free_cache_keys(*args):' | |||
|
54 | 52 | if cache_keys_by_pid: |
|
55 | 53 | try: |
|
56 | 54 | for cache_proc in set(cache_keys_by_pid): |
|
57 |
like_expression = '{}%' |
|
|
55 | like_expression = f'{cache_proc}%' | |
|
58 | 56 | qry = CacheKey.query().filter(CacheKey.cache_key.like(like_expression)) |
|
59 | 57 | count = qry.count() |
|
60 | 58 | log.info('Clearing %s: %s cache keys, total: %s', cache_proc, len(cache_keys_by_pid), count) |
@@ -181,7 +181,7 b' def get_or_create_region(region_name, re' | |||
|
181 | 181 | region_obj = region_meta.dogpile_cache_regions.get(region_name) |
|
182 | 182 | if not region_obj: |
|
183 | 183 | reg_keys = list(region_meta.dogpile_cache_regions.keys()) |
|
184 |
raise |
|
|
184 | raise OSError(f'Region `{region_name}` not in configured: {reg_keys}.') | |
|
185 | 185 | |
|
186 | 186 | region_uid_name = f'{region_name}:{region_namespace}' |
|
187 | 187 | |
@@ -331,7 +331,7 b' class InvalidationContext(object):' | |||
|
331 | 331 | self.cache_key = compute_key_from_params(uid) |
|
332 | 332 | self.cache_key = 'proc:{}|thread:{}|params:{}'.format( |
|
333 | 333 | self.proc_id, self.thread_id, self.cache_key) |
|
334 |
self.proc_key = 'proc:{ |
|
|
334 | self.proc_key = f'proc:{self.proc_id}' | |
|
335 | 335 | self.compute_time = 0 |
|
336 | 336 | |
|
337 | 337 | def get_or_create_cache_obj(self, cache_type, invalidation_namespace=''): |
@@ -1,5 +1,3 b'' | |||
|
1 | ||
|
2 | ||
|
3 | 1 |
|
|
4 | 2 | # |
|
5 | 3 | # This program is free software: you can redistribute it and/or modify |
@@ -76,7 +74,7 b' def command(ini_path, filename, file_pat' | |||
|
76 | 74 | |
|
77 | 75 | repo = Repository.get(repo_id) |
|
78 | 76 | if not repo: |
|
79 |
click.secho('ERROR: Unable to find repository with id `{}`' |
|
|
77 | click.secho(f'ERROR: Unable to find repository with id `{repo_id}`', | |
|
80 | 78 | fg='red') |
|
81 | 79 | sys.exit(-1) |
|
82 | 80 | |
@@ -87,7 +85,7 b' def command(ini_path, filename, file_pat' | |||
|
87 | 85 | db_user = User.get_first_super_admin() |
|
88 | 86 | |
|
89 | 87 | if not db_user: |
|
90 |
click.secho('ERROR: Unable to find user with id/username `{}`' |
|
|
88 | click.secho(f'ERROR: Unable to find user with id/username `{user_id}`', | |
|
91 | 89 | fg='red') |
|
92 | 90 | sys.exit(-1) |
|
93 | 91 | |
@@ -96,12 +94,12 b' def command(ini_path, filename, file_pat' | |||
|
96 | 94 | storage = store_utils.get_file_storage(request.registry.settings) |
|
97 | 95 | |
|
98 | 96 | with open(file_path, 'rb') as f: |
|
99 |
click.secho('Adding new artifact from path: `{}`' |
|
|
97 | click.secho(f'Adding new artifact from path: `{file_path}`', | |
|
100 | 98 | fg='green') |
|
101 | 99 | |
|
102 | 100 | file_data = _store_file( |
|
103 | 101 | storage, auth_user, filename, content=None, check_acl=True, |
|
104 | 102 | file_obj=f, description=description, |
|
105 | 103 | scope_repo_id=repo.repo_id) |
|
106 |
click.secho('File Data: {}' |
|
|
104 | click.secho(f'File Data: {file_data}', | |
|
107 | 105 | fg='green') |
@@ -1,5 +1,3 b'' | |||
|
1 | ||
|
2 | ||
|
3 | 1 |
|
|
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 |
|
|
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 |
|
|
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 |
|
|
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 |
|
|
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 |
|
|
4 | 2 | # |
|
5 | 3 | # This program is free software: you can redistribute it and/or modify |
@@ -12,7 +12,7 b' class _Singleton(type):' | |||
|
12 | 12 | |
|
13 | 13 | def __call__(cls, *args, **kwargs): |
|
14 | 14 | if cls not in cls._instances: |
|
15 |
cls._instances[cls] = super( |
|
|
15 | cls._instances[cls] = super().__call__(*args, **kwargs) | |
|
16 | 16 | return cls._instances[cls] |
|
17 | 17 | |
|
18 | 18 | |
@@ -29,12 +29,12 b' class StatsdClientClass(Singleton):' | |||
|
29 | 29 | |
|
30 | 30 | if name.startswith("statsd"): |
|
31 | 31 | if self.setup_run: |
|
32 |
return super( |
|
|
32 | return super().__getattribute__(name) | |
|
33 | 33 | else: |
|
34 | 34 | return None |
|
35 | 35 | #raise StatsdClientNotInitialised("requested key was %s" % name) |
|
36 | 36 | |
|
37 |
return super( |
|
|
37 | return super().__getattribute__(name) | |
|
38 | 38 | |
|
39 | 39 | def setup(self, settings): |
|
40 | 40 | """ |
@@ -1,4 +1,3 b'' | |||
|
1 | ||
|
2 | 1 |
|
|
3 | 2 | # |
|
4 | 3 | # This program is free software: you can redistribute it and/or modify |
@@ -67,7 +66,7 b' def base64_to_str(text) -> str:' | |||
|
67 | 66 | return safe_str(base64.encodebytes(safe_bytes(text))).strip() |
|
68 | 67 | |
|
69 | 68 | |
|
70 |
def get_default_encodings() -> |
|
|
69 | def get_default_encodings() -> list[str]: | |
|
71 | 70 | return aslist(rhodecode.CONFIG.get('default_encoding', 'utf8'), sep=',') |
|
72 | 71 | |
|
73 | 72 |
@@ -1,4 +1,3 b'' | |||
|
1 | ||
|
2 | 1 |
|
|
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 |
|
|
4 | 2 | # |
|
5 | 3 | # This program is free software: you can redistribute it and/or modify |
@@ -125,7 +123,7 b' class SysInfoRes(object):' | |||
|
125 | 123 | return self.__json__() |
|
126 | 124 | |
|
127 | 125 | def __str__(self): |
|
128 |
return '<SysInfoRes({ |
|
|
126 | return f'<SysInfoRes({self.__json__()})>' | |
|
129 | 127 | |
|
130 | 128 | |
|
131 | 129 | class SysInfo(object): |
@@ -146,7 +144,7 b' class SysInfo(object):' | |||
|
146 | 144 | return computed.__json__() |
|
147 | 145 | |
|
148 | 146 | def __str__(self): |
|
149 |
return '<SysInfo({ |
|
|
147 | return f'<SysInfo({self.function_name})>' | |
|
150 | 148 | |
|
151 | 149 | def compute(self, **kwargs): |
|
152 | 150 | return self.function_name(**kwargs) |
@@ -251,7 +249,7 b' def uptime():' | |||
|
251 | 249 | human_value['boot_time'] = time_to_datetime(boot_time) |
|
252 | 250 | human_value['uptime'] = age(time_to_datetime(boot_time), show_suffix=False) |
|
253 | 251 | |
|
254 |
human_value['text'] = 'Server started {}' |
|
|
252 | human_value['text'] = f'Server started {date_or_age}' | |
|
255 | 253 | return SysInfoRes(value=value, human_value=human_value) |
|
256 | 254 | |
|
257 | 255 | |
@@ -270,10 +268,10 b' def memory():' | |||
|
270 | 268 | value['used_real'], value['total'], 1) |
|
271 | 269 | |
|
272 | 270 | human_value = value.copy() |
|
273 |
human_value['text'] = ' |
|
|
271 | human_value['text'] = '{}/{}, {}% used'.format( | |
|
274 | 272 | format_byte_size_binary(value['used_real']), |
|
275 | 273 | format_byte_size_binary(value['total']), |
|
276 |
value['percent_used'] |
|
|
274 | value['percent_used']) | |
|
277 | 275 | |
|
278 | 276 | keys = list(value.keys())[::] |
|
279 | 277 | keys.pop(keys.index('percent')) |
@@ -546,7 +544,7 b' def git_info():' | |||
|
546 | 544 | value = human_value = '' |
|
547 | 545 | try: |
|
548 | 546 | value = git.discover_git_version(raise_on_exc=True) |
|
549 |
human_value = 'version reported from VCSServer: {}' |
|
|
547 | human_value = f'version reported from VCSServer: {value}' | |
|
550 | 548 | except Exception as e: |
|
551 | 549 | state = {'message': str(e), 'type': STATE_ERR} |
|
552 | 550 | |
@@ -560,7 +558,7 b' def hg_info():' | |||
|
560 | 558 | value = human_value = '' |
|
561 | 559 | try: |
|
562 | 560 | value = hg.discover_hg_version(raise_on_exc=True) |
|
563 |
human_value = 'version reported from VCSServer: {}' |
|
|
561 | human_value = f'version reported from VCSServer: {value}' | |
|
564 | 562 | except Exception as e: |
|
565 | 563 | state = {'message': str(e), 'type': STATE_ERR} |
|
566 | 564 | return SysInfoRes(value=value, state=state, human_value=human_value) |
@@ -573,7 +571,7 b' def svn_info():' | |||
|
573 | 571 | value = human_value = '' |
|
574 | 572 | try: |
|
575 | 573 | value = svn.discover_svn_version(raise_on_exc=True) |
|
576 |
human_value = 'version reported from VCSServer: {}' |
|
|
574 | human_value = f'version reported from VCSServer: {value}' | |
|
577 | 575 | except Exception as e: |
|
578 | 576 | state = {'message': str(e), 'type': STATE_ERR} |
|
579 | 577 | return SysInfoRes(value=value, state=state, human_value=human_value) |
@@ -774,7 +772,7 b' def server_info(environ):' | |||
|
774 | 772 | from rhodecode.lib.base import get_server_ip_addr, get_server_port |
|
775 | 773 | |
|
776 | 774 | value = { |
|
777 |
'server_ip': ' |
|
|
775 | 'server_ip': '{}:{}'.format( | |
|
778 | 776 | get_server_ip_addr(environ, log_errors=False), |
|
779 | 777 | get_server_port(environ) |
|
780 | 778 | ), |
@@ -1,5 +1,3 b'' | |||
|
1 | ||
|
2 | ||
|
3 | 1 |
|
|
4 | 2 | # |
|
5 | 3 | # This program is free software: you can redistribute it and/or modify |
@@ -1,4 +1,3 b'' | |||
|
1 | ||
|
2 | 1 |
|
|
3 | 2 | # |
|
4 | 3 | # This program is free software: you can redistribute it and/or modify |
@@ -1,5 +1,3 b'' | |||
|
1 | ||
|
2 | ||
|
3 | 1 |
|
|
4 | 2 | # |
|
5 | 3 | # This program is free software: you can redistribute it and/or modify |
@@ -165,9 +163,8 b' class MemcachedAuthSessions(BaseAuthSess' | |||
|
165 | 163 | """ Return a list of tuples containing keys and details """ |
|
166 | 164 | cmd = 'stats cachedump %s %s' |
|
167 | 165 | for slab_id in slab_ids: |
|
168 |
|
|
|
169 |
self._run_telnet_cmd(client, cmd % (slab_id, limit))) |
|
|
170 | yield key | |
|
166 | yield from self._key_regex.finditer( | |
|
167 | self._run_telnet_cmd(client, cmd % (slab_id, limit))) | |
|
171 | 168 | |
|
172 | 169 | def get_count(self): |
|
173 | 170 | client = self._get_client() |
@@ -261,4 +258,4 b' def get_session_handler(session_type):' | |||
|
261 | 258 | return types[session_type] |
|
262 | 259 | except KeyError: |
|
263 | 260 | raise ValueError( |
|
264 |
'This type {} is not supported' |
|
|
261 | f'This type {session_type} is not supported') |
@@ -1,4 +1,3 b'' | |||
|
1 | ||
|
2 | 1 |
|
|
3 | 2 | # |
|
4 | 3 | # This program is free software: you can redistribute it and/or modify |
@@ -192,8 +191,7 b' def get_filesystem_repos(path, recursive' | |||
|
192 | 191 | #check if this dir containts other repos for recursive scan |
|
193 | 192 | rec_path = os.path.join(p, dirpath) |
|
194 | 193 | if os.path.isdir(rec_path): |
|
195 |
|
|
|
196 | yield inner_scm | |
|
194 | yield from _get_repos(rec_path) | |
|
197 | 195 | |
|
198 | 196 | return _get_repos(path) |
|
199 | 197 | |
@@ -330,7 +328,7 b' def ask_ok(prompt, retries=4, complaint=' | |||
|
330 | 328 | return False |
|
331 | 329 | retries = retries - 1 |
|
332 | 330 | if retries < 0: |
|
333 |
raise |
|
|
331 | raise OSError | |
|
334 | 332 | print(complaint) |
|
335 | 333 | |
|
336 | 334 | # propagated from mercurial documentation |
@@ -805,5 +803,5 b' def send_test_email(recipients, email_bo' | |||
|
805 | 803 | from rhodecode.lib.celerylib import tasks, run_task |
|
806 | 804 | |
|
807 | 805 | email_body = email_body_plaintext = email_body |
|
808 |
subject = 'SUBJECT FROM: { |
|
|
806 | subject = f'SUBJECT FROM: {socket.gethostname()}' | |
|
809 | 807 | tasks.send_email(recipients, subject, email_body_plaintext, email_body) |
@@ -1,5 +1,3 b'' | |||
|
1 | ||
|
2 | ||
|
3 | 1 |
|
|
4 | 2 | # |
|
5 | 3 | # This program is free software: you can redistribute it and/or modify |
@@ -715,7 +713,7 b' def action_logger_generic(action, namesp' | |||
|
715 | 713 | user = '<unknown user>' |
|
716 | 714 | logfunc = log.warning |
|
717 | 715 | |
|
718 |
logfunc('Logging action by {}: {}' |
|
|
716 | logfunc(f'Logging action by {user}: {action}') | |
|
719 | 717 | |
|
720 | 718 | |
|
721 | 719 | def escape_split(text, sep=',', maxsplit=-1): |
@@ -1,5 +1,3 b'' | |||
|
1 | ||
|
2 | ||
|
3 | 1 |
|
|
4 | 2 | # |
|
5 | 3 | # This program is free software: you can redistribute it and/or modify |
@@ -347,7 +345,7 b' class BaseRepository(object):' | |||
|
347 | 345 | raise NotImplementedError |
|
348 | 346 | |
|
349 | 347 | def __repr__(self): |
|
350 |
return '<{ |
|
|
348 | return f'<{self.__class__.__name__} at {self.path}>' | |
|
351 | 349 | |
|
352 | 350 | def __len__(self): |
|
353 | 351 | return self.count() |
@@ -716,7 +714,7 b' class BaseRepository(object):' | |||
|
716 | 714 | """ |
|
717 | 715 | return os.path.join( |
|
718 | 716 | os.path.dirname(repo_path), |
|
719 |
'.__shadow_{ |
|
|
717 | f'.__shadow_{os.path.basename(repo_path)}_{workspace_id}') | |
|
720 | 718 | |
|
721 | 719 | @classmethod |
|
722 | 720 | def _get_shadow_repository_path(cls, repo_path, repo_id, workspace_id): |
@@ -728,7 +726,7 b' class BaseRepository(object):' | |||
|
728 | 726 | else: |
|
729 | 727 | return os.path.join( |
|
730 | 728 | os.path.dirname(repo_path), |
|
731 |
'.__shadow_repo_{}_{}' |
|
|
729 | f'.__shadow_repo_{repo_id}_{workspace_id}') | |
|
732 | 730 | |
|
733 | 731 | def cleanup_merge_workspace(self, repo_id, workspace_id): |
|
734 | 732 | """ |
@@ -806,7 +804,7 b' class BaseRepository(object):' | |||
|
806 | 804 | |
|
807 | 805 | def _validate_branch_name(self, branch_name): |
|
808 | 806 | if branch_name and branch_name not in self.branches_all: |
|
809 |
msg = ("Branch {} not found in {}" |
|
|
807 | msg = (f"Branch {branch_name} not found in {self}") | |
|
810 | 808 | raise BranchDoesNotExistError(msg) |
|
811 | 809 | |
|
812 | 810 | # |
@@ -1583,7 +1581,7 b' class BaseInMemoryCommit(object):' | |||
|
1583 | 1581 | pass |
|
1584 | 1582 | else: |
|
1585 | 1583 | raise NodeAlreadyExistsError( |
|
1586 |
"Node `{ |
|
|
1584 | f"Node `{node.path}` already exists at {p}") | |
|
1587 | 1585 | |
|
1588 | 1586 | # Check nodes marked as changed |
|
1589 | 1587 | missing = set(self.changed) |
@@ -373,7 +373,7 b' class GitRepository(BaseRepository):' | |||
|
373 | 373 | if name in self.tags: |
|
374 | 374 | raise TagAlreadyExistError("Tag %s already exists" % name) |
|
375 | 375 | commit = self.get_commit(commit_id=commit_id) |
|
376 |
message = message or "Added tag {} for commit { |
|
|
376 | message = message or f"Added tag {name} for commit {commit.raw_id}" | |
|
377 | 377 | |
|
378 | 378 | self._remote.set_refs('refs/tags/%s' % name, commit.raw_id) |
|
379 | 379 | |
@@ -641,7 +641,7 b' class GitRepository(BaseRepository):' | |||
|
641 | 641 | else: |
|
642 | 642 | output, __ = repo1.run_git_command( |
|
643 | 643 | ['log', '--reverse', '--pretty=format: %H', '-s', |
|
644 |
'{}..{}' |
|
|
644 | f'{commit_id1}..{commit_id2}']) | |
|
645 | 645 | commits = [ |
|
646 | 646 | repo1.get_commit(commit_id=commit_id, pre_load=pre_load) |
|
647 | 647 | for commit_id in self.COMMIT_ID_PAT.findall(output)] |
@@ -912,7 +912,7 b' class GitRepository(BaseRepository):' | |||
|
912 | 912 | target_repo._local_pull(self.path, source_branch) |
|
913 | 913 | else: |
|
914 | 914 | cmd = ['push', os.path.abspath(repository_path), |
|
915 |
'{}:{}' |
|
|
915 | f'{source_branch}:{target_branch}'] | |
|
916 | 916 | gitenv = {} |
|
917 | 917 | if rc_scm_data: |
|
918 | 918 | gitenv.update({'RC_SCM_DATA': rc_scm_data}) |
@@ -922,7 +922,7 b' class GitRepository(BaseRepository):' | |||
|
922 | 922 | self.run_git_command(cmd, fail_on_stderr=False, extra_env=gitenv) |
|
923 | 923 | |
|
924 | 924 | def _get_new_pr_branch(self, source_branch, target_branch): |
|
925 |
prefix = 'pr_{}-{}_' |
|
|
925 | prefix = f'pr_{source_branch}-{target_branch}_' | |
|
926 | 926 | pr_branches = [] |
|
927 | 927 | for branch in self.branches: |
|
928 | 928 | if branch.startswith(prefix): |
@@ -289,7 +289,7 b' class MercurialCommit(base.BaseCommit):' | |||
|
289 | 289 | |
|
290 | 290 | if self._get_kind(path) != NodeKind.DIR: |
|
291 | 291 | raise CommitError( |
|
292 |
"Directory does not exist for idx { |
|
|
292 | f"Directory does not exist for idx {self.raw_id} at '{path}'") | |
|
293 | 293 | path = self._fix_path(path) |
|
294 | 294 | |
|
295 | 295 | filenodes = [ |
@@ -178,7 +178,7 b' class MercurialRepository(BaseRepository' | |||
|
178 | 178 | local = kwargs.setdefault('local', False) |
|
179 | 179 | |
|
180 | 180 | if message is None: |
|
181 |
message = "Added tag {} for commit { |
|
|
181 | message = f"Added tag {name} for commit {commit.short_id}" | |
|
182 | 182 | |
|
183 | 183 | date, tz = date_to_timestamp_plus_offset(date) |
|
184 | 184 | |
@@ -529,17 +529,17 b' class MercurialRepository(BaseRepository' | |||
|
529 | 529 | commit_filter = [] |
|
530 | 530 | |
|
531 | 531 | if branch_name and not branch_ancestors: |
|
532 |
commit_filter.append('branch("{}")' |
|
|
532 | commit_filter.append(f'branch("{branch_name}")') | |
|
533 | 533 | elif branch_name and branch_ancestors: |
|
534 |
commit_filter.append('ancestors(branch("{}"))' |
|
|
534 | commit_filter.append(f'ancestors(branch("{branch_name}"))') | |
|
535 | 535 | |
|
536 | 536 | if start_date and not end_date: |
|
537 |
commit_filter.append('date(">{}")' |
|
|
537 | commit_filter.append(f'date(">{start_date}")') | |
|
538 | 538 | if end_date and not start_date: |
|
539 |
commit_filter.append('date("<{}")' |
|
|
539 | commit_filter.append(f'date("<{end_date}")') | |
|
540 | 540 | if start_date and end_date: |
|
541 | 541 | commit_filter.append( |
|
542 |
'date(">{}") and date("<{}")' |
|
|
542 | f'date(">{start_date}") and date("<{end_date}")') | |
|
543 | 543 | |
|
544 | 544 | if not show_hidden: |
|
545 | 545 | commit_filter.append('not obsolete()') |
@@ -657,7 +657,7 b' class MercurialRepository(BaseRepository' | |||
|
657 | 657 | unresolved = None |
|
658 | 658 | if use_rebase: |
|
659 | 659 | try: |
|
660 |
bookmark_name = 'rcbook{}{}' |
|
|
660 | bookmark_name = f'rcbook{source_ref_commit_id}{target_ref_commit_id}' | |
|
661 | 661 | self.bookmark(bookmark_name, revision=source_ref.commit_id) |
|
662 | 662 | self._remote.rebase( |
|
663 | 663 | source=source_ref_commit_id, dest=target_ref_commit_id) |
@@ -687,7 +687,7 b' class MercurialRepository(BaseRepository' | |||
|
687 | 687 | self._remote.invalidate_vcs_cache() |
|
688 | 688 | self._remote.commit( |
|
689 | 689 | message=safe_str(merge_message), |
|
690 |
username=safe_str('{} <{}>' |
|
|
690 | username=safe_str(f'{user_name} <{user_email}>')) | |
|
691 | 691 | self._remote.invalidate_vcs_cache() |
|
692 | 692 | return self._identify(), True |
|
693 | 693 | except RepositoryError as e: |
@@ -718,7 +718,7 b' class MercurialRepository(BaseRepository' | |||
|
718 | 718 | try: |
|
719 | 719 | self._remote.commit( |
|
720 | 720 | message=safe_str(message), |
|
721 |
username=safe_str('{} <{}>' |
|
|
721 | username=safe_str(f'{user_name} <{user_email}>'), | |
|
722 | 722 | close_branch=True) |
|
723 | 723 | self._remote.invalidate_vcs_cache() |
|
724 | 724 | return self._identify(), True |
@@ -767,7 +767,7 b' class MercurialRepository(BaseRepository' | |||
|
767 | 767 | if len(heads_all) > max_heads: |
|
768 | 768 | heads = '\n,'.join( |
|
769 | 769 | heads_all[:max_heads] + |
|
770 |
['and { |
|
|
770 | [f'and {len(heads_all)-max_heads} more.']) | |
|
771 | 771 | else: |
|
772 | 772 | heads = '\n,'.join(heads_all) |
|
773 | 773 | metadata = { |
@@ -862,7 +862,7 b' class MercurialRepository(BaseRepository' | |||
|
862 | 862 | max_conflicts = 20 |
|
863 | 863 | if len(all_conflicts) > max_conflicts: |
|
864 | 864 | conflicts = all_conflicts[:max_conflicts] \ |
|
865 |
+ ['and { |
|
|
865 | + [f'and {len(all_conflicts)-max_conflicts} more.'] | |
|
866 | 866 | else: |
|
867 | 867 | conflicts = all_conflicts |
|
868 | 868 | metadata['unresolved_files'] = \ |
@@ -53,7 +53,7 b' class SubversionCommit(base.BaseCommit):' | |||
|
53 | 53 | # which knows how to translate commit index and commit id |
|
54 | 54 | self.raw_id = commit_id |
|
55 | 55 | self.short_id = commit_id |
|
56 |
self.id = 'r{}' |
|
|
56 | self.id = f'r{commit_id}' | |
|
57 | 57 | |
|
58 | 58 | # TODO: Implement the following placeholder attributes |
|
59 | 59 | self.nodes = {} |
@@ -199,7 +199,7 b' class SubversionCommit(base.BaseCommit):' | |||
|
199 | 199 | return nodes.NodeKind.DIR |
|
200 | 200 | else: |
|
201 | 201 | raise CommitError( |
|
202 |
"Node does not exist at the given path '{}'" |
|
|
202 | f"Node does not exist at the given path '{path}'") | |
|
203 | 203 | |
|
204 | 204 | @LazyProperty |
|
205 | 205 | def _changes_cache(self): |
@@ -221,7 +221,7 b' class SubversionRepository(base.BaseRepo' | |||
|
221 | 221 | commit_idx = svn_rev - 1 |
|
222 | 222 | if commit_idx >= len(self.commit_ids): |
|
223 | 223 | raise CommitDoesNotExistError( |
|
224 |
"Commit at index {} does not exist." |
|
|
224 | f"Commit at index {commit_idx} does not exist.") | |
|
225 | 225 | return commit_idx |
|
226 | 226 | |
|
227 | 227 | @staticmethod |
@@ -245,7 +245,7 b' class SubversionRepository(base.BaseRepo' | |||
|
245 | 245 | |
|
246 | 246 | def _check_path(self): |
|
247 | 247 | if not os.path.exists(self.path): |
|
248 |
raise VCSError('Path "{}" does not exist!' |
|
|
248 | raise VCSError(f'Path "{self.path}" does not exist!') | |
|
249 | 249 | if not self._remote.is_path_valid_repository(self.path): |
|
250 | 250 | raise VCSError( |
|
251 | 251 | 'Path "%s" does not contain a Subversion repository' % |
@@ -341,11 +341,11 b' class SubversionRepository(base.BaseRepo' | |||
|
341 | 341 | return commit_id |
|
342 | 342 | else: |
|
343 | 343 | raise CommitDoesNotExistError( |
|
344 |
"Commit {} does not exist." |
|
|
344 | f"Commit {commit_id} does not exist.") | |
|
345 | 345 | if commit_id not in [ |
|
346 | 346 | None, 'HEAD', 'tip', self.DEFAULT_BRANCH_NAME]: |
|
347 | 347 | raise CommitDoesNotExistError( |
|
348 |
"Commit id {} not understood." |
|
|
348 | f"Commit id {commit_id} not understood.") | |
|
349 | 349 | svn_rev = self._remote.lookup('HEAD') |
|
350 | 350 | return str(svn_rev) |
|
351 | 351 |
@@ -51,7 +51,7 b' def get_scm(path):' | |||
|
51 | 51 | if len(found_scms) > 1: |
|
52 | 52 | found = ', '.join(x[0] for x in found_scms) |
|
53 | 53 | raise VCSError( |
|
54 |
'More than one [{}] scm found at given path {}' |
|
|
54 | f'More than one [{found}] scm found at given path {path}') | |
|
55 | 55 | |
|
56 | 56 | if len(found_scms) == 0: |
|
57 | 57 | raise VCSError('No scm found at given path %s' % path) |
@@ -1,4 +1,3 b'' | |||
|
1 | ||
|
2 | 1 |
|
|
3 | 2 | # |
|
4 | 3 | # This program is free software: you can redistribute it and/or modify |
@@ -55,7 +54,7 b' def _format_ref_id(name, raw_id):' | |||
|
55 | 54 | |
|
56 | 55 | def _format_ref_id_svn(name, raw_id): |
|
57 | 56 | """Special way of formatting a reference for Subversion including path""" |
|
58 |
return ' |
|
|
57 | return '{}@{}'.format(name, raw_id) | |
|
59 | 58 | |
|
60 | 59 | |
|
61 | 60 | def get_commit_from_ref_name(repo, ref_name, ref_type=None): |
@@ -83,6 +82,6 b' def get_commit_from_ref_name(repo, ref_n' | |||
|
83 | 82 | commit_id = ref_type_mapping[ref_type][ref_name] |
|
84 | 83 | except KeyError: |
|
85 | 84 | raise RepositoryError( |
|
86 |
' |
|
|
85 | '{} "{}" does not exist'.format(ref_type, ref_name)) | |
|
87 | 86 | |
|
88 | 87 | return repo_scm.get_commit(commit_id) |
@@ -1,4 +1,3 b'' | |||
|
1 | ||
|
2 | 1 |
|
|
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 |
|
|
4 | 2 | # |
|
5 | 3 | # This program is free software: you can redistribute it and/or modify |
@@ -1,4 +1,3 b'' | |||
|
1 | ||
|
2 | 1 |
|
|
3 | 2 | # |
|
4 | 3 | # This program is free software: you can redistribute it and/or modify |
@@ -1,5 +1,3 b'' | |||
|
1 | ||
|
2 | ||
|
3 | 1 |
|
|
4 | 2 | # |
|
5 | 3 | # This program is free software: you can redistribute it and/or modify |
@@ -95,8 +93,7 b' class CommentsModel(BaseModel):' | |||
|
95 | 93 | [comment_groups[_co.pull_request_version_id].append(_co) for _co in comments] |
|
96 | 94 | |
|
97 | 95 | def yield_comments(pos): |
|
98 |
|
|
|
99 | yield co | |
|
96 | yield from comment_groups[pos] | |
|
100 | 97 | |
|
101 | 98 | comment_versions = collections.defaultdict( |
|
102 | 99 | lambda: collections.defaultdict(list)) |
@@ -402,7 +399,7 b' class CommentsModel(BaseModel):' | |||
|
402 | 399 | commit_comment_url = self.get_url(comment, request=request) |
|
403 | 400 | commit_comment_reply_url = self.get_url( |
|
404 | 401 | comment, request=request, |
|
405 |
anchor='comment-{ |
|
|
402 | anchor=f'comment-{comment.comment_id}/?/ReplyToComment') | |
|
406 | 403 | |
|
407 | 404 | target_repo_url = h.link_to( |
|
408 | 405 | repo.repo_name, |
@@ -438,7 +435,7 b' class CommentsModel(BaseModel):' | |||
|
438 | 435 | pr_comment_url = self.get_url(comment, request=request) |
|
439 | 436 | pr_comment_reply_url = self.get_url( |
|
440 | 437 | comment, request=request, |
|
441 |
anchor='comment-{ |
|
|
438 | anchor=f'comment-{comment.comment_id}/?/ReplyToComment') | |
|
442 | 439 | |
|
443 | 440 | pr_url = h.route_url( |
|
444 | 441 | 'pullrequest_show', |
@@ -595,7 +592,7 b' class CommentsModel(BaseModel):' | |||
|
595 | 592 | |
|
596 | 593 | comment = self.__get_commit_comment(comment) |
|
597 | 594 | if anchor is None: |
|
598 |
anchor = 'comment-{ |
|
|
595 | anchor = f'comment-{comment.comment_id}' | |
|
599 | 596 | |
|
600 | 597 | if comment.pull_request: |
|
601 | 598 | pull_request = comment.pull_request |
@@ -823,7 +820,7 b' class CommentsModel(BaseModel):' | |||
|
823 | 820 | |
|
824 | 821 | |
|
825 | 822 | def _parse_comment_line_number(line_no): |
|
826 | """ | |
|
823 | r""" | |
|
827 | 824 | Parses line numbers of the form "(o|n)\d+" and returns them in a tuple. |
|
828 | 825 | """ |
|
829 | 826 | old_line = None |
@@ -839,10 +836,10 b' def _parse_comment_line_number(line_no):' | |||
|
839 | 836 | |
|
840 | 837 | def _diff_to_comment_line_number(diff_line): |
|
841 | 838 | if diff_line.new is not None: |
|
842 |
return |
|
|
839 | return f'n{diff_line.new}' | |
|
843 | 840 | elif diff_line.old is not None: |
|
844 |
return |
|
|
845 |
return |
|
|
841 | return f'o{diff_line.old}' | |
|
842 | return '' | |
|
846 | 843 | |
|
847 | 844 | |
|
848 | 845 | def _diff_line_delta(a, b): |
@@ -852,4 +849,4 b' def _diff_line_delta(a, b):' | |||
|
852 | 849 | return abs(a.old - b.old) |
|
853 | 850 | else: |
|
854 | 851 | raise ValueError( |
|
855 |
"Cannot compute delta between {} and {}" |
|
|
852 | f"Cannot compute delta between {a} and {b}") |
@@ -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 |
|
|
3 | 2 | # |
|
4 | 3 | # This program is free software: you can redistribute it and/or modify |
@@ -84,8 +83,8 b' def LoginForm(localizer):' | |||
|
84 | 83 | min=1, |
|
85 | 84 | not_empty=True, |
|
86 | 85 | messages={ |
|
87 |
'empty': _( |
|
|
88 |
'tooShort': _( |
|
|
86 | 'empty': _('Please enter a login'), | |
|
87 | 'tooShort': _('Enter a value %(min)i characters long or more') | |
|
89 | 88 | } |
|
90 | 89 | ) |
|
91 | 90 | |
@@ -95,8 +94,8 b' def LoginForm(localizer):' | |||
|
95 | 94 | max=72, |
|
96 | 95 | not_empty=True, |
|
97 | 96 | messages={ |
|
98 |
'empty': _( |
|
|
99 |
'tooShort': _( |
|
|
97 | 'empty': _('Please enter a password'), | |
|
98 | 'tooShort': _('Enter %(min)i characters or more')} | |
|
100 | 99 | ) |
|
101 | 100 | |
|
102 | 101 | remember = v.StringBoolean(if_missing=False) |
@@ -322,7 +321,7 b' def RepoFieldForm(localizer):' | |||
|
322 | 321 | |
|
323 | 322 | new_field_key = All(v.FieldKey(localizer), |
|
324 | 323 | v.UnicodeString(strip=True, min=3, not_empty=True)) |
|
325 |
new_field_value = v.UnicodeString(not_empty=False, if_missing= |
|
|
324 | new_field_value = v.UnicodeString(not_empty=False, if_missing='') | |
|
326 | 325 | new_field_type = v.OneOf(['str', 'unicode', 'list', 'tuple'], |
|
327 | 326 | if_missing='str') |
|
328 | 327 | new_field_label = v.UnicodeString(not_empty=False) |
@@ -1,5 +1,3 b'' | |||
|
1 | ||
|
2 | ||
|
3 | 1 |
|
|
4 | 2 | # |
|
5 | 3 | # This program is free software: you can redistribute it and/or modify |
@@ -102,7 +100,7 b' class GistModel(BaseModel):' | |||
|
102 | 100 | repo = Gist.get_by_access_id(gist_access_id) |
|
103 | 101 | vcs_repo = repo.scm_instance() |
|
104 | 102 | if not vcs_repo: |
|
105 |
raise VCSError('Failed to load gist repository for {}' |
|
|
103 | raise VCSError(f'Failed to load gist repository for {repo}') | |
|
106 | 104 | |
|
107 | 105 | commit = vcs_repo.get_commit(commit_id=revision) |
|
108 | 106 | return commit, [n for n in commit.get_node('/')] |
@@ -1,5 +1,3 b'' | |||
|
1 | ||
|
2 | ||
|
3 | 1 |
|
|
4 | 2 | # |
|
5 | 3 | # This program is free software: you can redistribute it and/or modify |
@@ -1,4 +1,3 b'' | |||
|
1 | ||
|
2 | 1 |
|
|
3 | 2 | # |
|
4 | 3 | # This program is free software: you can redistribute it and/or modify |
@@ -1,5 +1,3 b'' | |||
|
1 | ||
|
2 | ||
|
3 | 1 |
|
|
4 | 2 | # |
|
5 | 3 | # This program is free software: you can redistribute it and/or modify |
@@ -391,7 +389,7 b' class EmailNotificationModel(BaseModel):' | |||
|
391 | 389 | EmailNotificationModel.TYPE_TEST, **email_kwargs) |
|
392 | 390 | |
|
393 | 391 | """ |
|
394 |
super( |
|
|
392 | super().__init__() | |
|
395 | 393 | self.rhodecode_instance_name = rhodecode.CONFIG.get('rhodecode_title') |
|
396 | 394 | |
|
397 | 395 | def _update_kwargs_for_render(self, kwargs): |
@@ -1,4 +1,3 b'' | |||
|
1 | ||
|
2 | 1 |
|
|
3 | 2 | # |
|
4 | 3 | # This program is free software: you can redistribute it and/or modify |
@@ -283,7 +282,7 b' class PermissionModel(BaseModel):' | |||
|
283 | 282 | # at that stage we validate all are passed inside form_result |
|
284 | 283 | for _perm_key, perm_value in _global_perms.items(): |
|
285 | 284 | if perm_value is None: |
|
286 |
raise ValueError('Missing permission for |
|
|
285 | raise ValueError('Missing permission for {}'.format(_perm_key)) | |
|
287 | 286 | |
|
288 | 287 | if obj_type == 'user': |
|
289 | 288 | p = self._make_new_user_perm(to_object, perm_value) |
@@ -1,5 +1,3 b'' | |||
|
1 | ||
|
2 | ||
|
3 | 1 |
|
|
4 | 2 | # |
|
5 | 3 | # This program is free software: you can redistribute it and/or modify |
@@ -1,4 +1,3 b'' | |||
|
1 | ||
|
2 | 1 |
|
|
3 | 2 | # |
|
4 | 3 | # This program is free software: you can redistribute it and/or modify |
@@ -1067,7 +1066,7 b' class RepoModel(BaseModel):' | |||
|
1067 | 1066 | |
|
1068 | 1067 | _now = datetime.datetime.now() |
|
1069 | 1068 | _ms = str(_now.microsecond).rjust(6, '0') |
|
1070 |
_d = 'rm__ |
|
|
1069 | _d = 'rm__{}__{}'.format(_now.strftime('%Y%m%d_%H%M%S_' + _ms), | |
|
1071 | 1070 | repo.just_name) |
|
1072 | 1071 | if repo_group: |
|
1073 | 1072 | # if repository is in group, prefix the removal path with the group |
@@ -1196,4 +1195,4 b' class ReadmeMatch:' | |||
|
1196 | 1195 | return self.node.path |
|
1197 | 1196 | |
|
1198 | 1197 | def __repr__(self): |
|
1199 |
return '<ReadmeMatch { |
|
|
1198 | return f'<ReadmeMatch {self.path} priority={self.priority}' |
@@ -1,5 +1,3 b'' | |||
|
1 | ||
|
2 | ||
|
3 | 1 |
|
|
4 | 2 | # |
|
5 | 3 | # This program is free software: you can redistribute it and/or modify |
@@ -173,7 +171,7 b' class RepoGroupModel(BaseModel):' | |||
|
173 | 171 | if os.path.isdir(create_path): |
|
174 | 172 | if exc_on_failure: |
|
175 | 173 | abs_create_path = os.path.abspath(create_path) |
|
176 |
raise Exception('Directory `{}` already exists !' |
|
|
174 | raise Exception(f'Directory `{abs_create_path}` already exists !') | |
|
177 | 175 | return False |
|
178 | 176 | return True |
|
179 | 177 | |
@@ -234,7 +232,7 b' class RepoGroupModel(BaseModel):' | |||
|
234 | 232 | # archive that group` |
|
235 | 233 | _now = datetime.datetime.now() |
|
236 | 234 | _ms = str(_now.microsecond).rjust(6, '0') |
|
237 |
_d = 'rm__ |
|
|
235 | _d = 'rm__{}_GROUP_{}'.format( | |
|
238 | 236 | _now.strftime('%Y%m%d_%H%M%S_' + _ms), group.name) |
|
239 | 237 | shutil.move(rm_path, os.path.join(self.repos_path, _d)) |
|
240 | 238 |
@@ -1,5 +1,3 b'' | |||
|
1 | ||
|
2 | ||
|
3 | 1 |
|
|
4 | 2 | # |
|
5 | 3 | # This program is free software: you can redistribute it and/or modify |
@@ -1,4 +1,3 b'' | |||
|
1 | ||
|
2 | 1 |
|
|
3 | 2 | # |
|
4 | 3 | # This program is free software: you can redistribute it and/or modify |
@@ -61,7 +60,7 b' class UserTemp(object):' | |||
|
61 | 60 | self.user_id = user_id |
|
62 | 61 | |
|
63 | 62 | def __repr__(self): |
|
64 |
return "< |
|
|
63 | return "<{}('id:{}')>".format(self.__class__.__name__, self.user_id) | |
|
65 | 64 | |
|
66 | 65 | |
|
67 | 66 | class RepoTemp(object): |
@@ -69,7 +68,7 b' class RepoTemp(object):' | |||
|
69 | 68 | self.repo_id = repo_id |
|
70 | 69 | |
|
71 | 70 | def __repr__(self): |
|
72 |
return "< |
|
|
71 | return "<{}('id:{}')>".format(self.__class__.__name__, self.repo_id) | |
|
73 | 72 | |
|
74 | 73 | |
|
75 | 74 | class SimpleCachedRepoList(object): |
@@ -91,7 +90,7 b' class SimpleCachedRepoList(object):' | |||
|
91 | 90 | return len(self.db_repo_list) |
|
92 | 91 | |
|
93 | 92 | def __repr__(self): |
|
94 |
return '< |
|
|
93 | return '<{} ({})>'.format(self.__class__.__name__, self.__len__()) | |
|
95 | 94 | |
|
96 | 95 | def __iter__(self): |
|
97 | 96 | for dbr in self.db_repo_list: |
@@ -133,7 +132,7 b' class _PermCheckIterator(object):' | |||
|
133 | 132 | return len(self.obj_list) |
|
134 | 133 | |
|
135 | 134 | def __repr__(self): |
|
136 |
return '< |
|
|
135 | return '<{} ({})>'.format(self.__class__.__name__, self.__len__()) | |
|
137 | 136 | |
|
138 | 137 | def __iter__(self): |
|
139 | 138 | for db_obj in self.obj_list: |
@@ -152,7 +151,7 b' class RepoList(_PermCheckIterator):' | |||
|
152 | 151 | if not perm_set: |
|
153 | 152 | perm_set = ['repository.read', 'repository.write', 'repository.admin'] |
|
154 | 153 | |
|
155 |
super( |
|
|
154 | super().__init__( | |
|
156 | 155 | obj_list=db_repo_list, |
|
157 | 156 | obj_attr='_repo_name', perm_set=perm_set, |
|
158 | 157 | perm_checker=HasRepoPermissionAny, |
@@ -165,7 +164,7 b' class RepoGroupList(_PermCheckIterator):' | |||
|
165 | 164 | if not perm_set: |
|
166 | 165 | perm_set = ['group.read', 'group.write', 'group.admin'] |
|
167 | 166 | |
|
168 |
super( |
|
|
167 | super().__init__( | |
|
169 | 168 | obj_list=db_repo_group_list, |
|
170 | 169 | obj_attr='_group_name', perm_set=perm_set, |
|
171 | 170 | perm_checker=HasRepoGroupPermissionAny, |
@@ -178,7 +177,7 b' class UserGroupList(_PermCheckIterator):' | |||
|
178 | 177 | if not perm_set: |
|
179 | 178 | perm_set = ['usergroup.read', 'usergroup.write', 'usergroup.admin'] |
|
180 | 179 | |
|
181 |
super( |
|
|
180 | super().__init__( | |
|
182 | 181 | obj_list=db_user_group_list, |
|
183 | 182 | obj_attr='users_group_name', perm_set=perm_set, |
|
184 | 183 | perm_checker=HasUserGroupPermissionAny, |
@@ -284,7 +283,7 b' class ScmModel(BaseModel):' | |||
|
284 | 283 | config.set('extensions', 'largefiles', '') |
|
285 | 284 | repo.update_commit_cache(config=config, cs_cache=None) |
|
286 | 285 | if delete: |
|
287 |
cache_namespace_uid = 'cache_repo.{}' |
|
|
286 | cache_namespace_uid = f'cache_repo.{repo_id}' | |
|
288 | 287 | rc_cache.clear_cache_namespace('cache_repo', cache_namespace_uid, method=rc_cache.CLEAR_INVALIDATE) |
|
289 | 288 | |
|
290 | 289 | def toggle_following_repo(self, follow_repo_id, user_id): |
@@ -87,7 +87,7 b' class UserModel(BaseModel):' | |||
|
87 | 87 | query = query.filter(User.active == true()) |
|
88 | 88 | |
|
89 | 89 | if name_contains: |
|
90 |
ilike_expression = |
|
|
90 | ilike_expression = f'%{safe_str(name_contains)}%' | |
|
91 | 91 | query = query.filter( |
|
92 | 92 | or_( |
|
93 | 93 | User.name.ilike(ilike_expression), |
@@ -387,7 +387,7 b' class UserModel(BaseModel):' | |||
|
387 | 387 | self.add_auth_token( |
|
388 | 388 | user=username, lifetime_minutes=-1, |
|
389 | 389 | role=self.auth_token_role.ROLE_FEED, |
|
390 |
description= |
|
|
390 | description='Generated feed token') | |
|
391 | 391 | |
|
392 | 392 | kwargs = new_user.get_dict() |
|
393 | 393 | # backward compat, require api_keys present |
@@ -129,7 +129,7 b' def UniqueListFromString(localizer):' | |||
|
129 | 129 | def _convert_to_python(self, value, state): |
|
130 | 130 | if isinstance(value, str): |
|
131 | 131 | value = aslist(value, ',') |
|
132 |
return super( |
|
|
132 | return super()._convert_to_python(value, state) | |
|
133 | 133 | return _validator |
|
134 | 134 | |
|
135 | 135 | |
@@ -951,7 +951,7 b' def ValidIp(localizer):' | |||
|
951 | 951 | |
|
952 | 952 | # we override the default to_python() call |
|
953 | 953 | def to_python(self, value, state): |
|
954 |
v = super( |
|
|
954 | v = super().to_python(value, state) | |
|
955 | 955 | v = safe_str(v.strip()) |
|
956 | 956 | net = ipaddress.ip_network(address=v, strict=False) |
|
957 | 957 | return str(net) |
@@ -1078,7 +1078,7 b' def ValidPattern(localizer):' | |||
|
1078 | 1078 | new_item_id = name[len(pattern_name)+1:] |
|
1079 | 1079 | |
|
1080 | 1080 | def _field(name): |
|
1081 |
return ' |
|
|
1081 | return '{}_{}_{}'.format(prefix, name, new_item_id) | |
|
1082 | 1082 | |
|
1083 | 1083 | values = { |
|
1084 | 1084 | 'issuetracker_pat': value.get(_field('pattern')), |
General Comments 0
You need to be logged in to leave comments.
Login now