##// END OF EJS Templates
libs: more python3 reformats
super-admin -
r5091:9ce86a18 default
parent child Browse files
Show More
@@ -1,5 +1,3 b''
1
2
3 1 # Copyright (C) 2014-2023 RhodeCode GmbH
4 2 #
5 3 # This program is free software: you can redistribute it and/or modify
@@ -95,7 +93,7 b' def connect_vcs(server_and_port, protoco'
95 93 if protocol == 'http':
96 94 connect_http(server_and_port)
97 95 else:
98 raise Exception('Invalid vcs server protocol "{}"'.format(protocol))
96 raise Exception(f'Invalid vcs server protocol "{protocol}"')
99 97
100 98
101 99 class CurlSession(object):
@@ -1,5 +1,3 b''
1
2
3 1 # Copyright (C) 2014-2023 RhodeCode GmbH
4 2 #
5 3 # This program is free software: you can redistribute it and/or modify
@@ -247,7 +247,7 b' class MergeResponse(object):'
247 247 self.metadata = metadata or {}
248 248
249 249 def __repr__(self):
250 return '<MergeResponse:{} {}>'.format(self.label, self.failure_reason)
250 return f'<MergeResponse:{self.label} {self.failure_reason}>'
251 251
252 252 def __eq__(self, other):
253 253 same_instance = isinstance(other, self.__class__)
@@ -320,8 +320,8 b' class BaseRepository(object):'
320 320 """
321 321
322 322 DEFAULT_BRANCH_NAME = None
323 DEFAULT_CONTACT = u"Unknown"
324 DEFAULT_DESCRIPTION = u"unknown"
323 DEFAULT_CONTACT = "Unknown"
324 DEFAULT_DESCRIPTION = "unknown"
325 325 EMPTY_COMMIT_ID = '0' * 40
326 326 COMMIT_ID_PAT = re.compile(r'[0-9a-fA-F]{40}')
327 327
@@ -347,7 +347,7 b' class BaseRepository(object):'
347 347 raise NotImplementedError
348 348
349 349 def __repr__(self):
350 return '<%s at %s>' % (self.__class__.__name__, self.path)
350 return '<{} at {}>'.format(self.__class__.__name__, self.path)
351 351
352 352 def __len__(self):
353 353 return self.count()
@@ -716,7 +716,7 b' class BaseRepository(object):'
716 716 """
717 717 return os.path.join(
718 718 os.path.dirname(repo_path),
719 '.__shadow_%s_%s' % (os.path.basename(repo_path), workspace_id))
719 '.__shadow_{}_{}'.format(os.path.basename(repo_path), workspace_id))
720 720
721 721 @classmethod
722 722 def _get_shadow_repository_path(cls, repo_path, repo_id, workspace_id):
@@ -728,7 +728,7 b' class BaseRepository(object):'
728 728 else:
729 729 return os.path.join(
730 730 os.path.dirname(repo_path),
731 '.__shadow_repo_%s_%s' % (repo_id, workspace_id))
731 '.__shadow_repo_{}_{}'.format(repo_id, workspace_id))
732 732
733 733 def cleanup_merge_workspace(self, repo_id, workspace_id):
734 734 """
@@ -806,7 +806,7 b' class BaseRepository(object):'
806 806
807 807 def _validate_branch_name(self, branch_name):
808 808 if branch_name and branch_name not in self.branches_all:
809 msg = ("Branch %s not found in %s" % (branch_name, self))
809 msg = ("Branch {} not found in {}".format(branch_name, self))
810 810 raise BranchDoesNotExistError(msg)
811 811
812 812 #
@@ -1342,7 +1342,7 b' class BaseCommit(object):'
1342 1342 """
1343 1343 Returns total number of bytes from contents of all filenodes.
1344 1344 """
1345 return sum((node.size for node in self.get_filenodes_generator()))
1345 return sum(node.size for node in self.get_filenodes_generator())
1346 1346
1347 1347 def walk(self, topurl=''):
1348 1348 """
@@ -1369,16 +1369,14 b' class BaseCommit(object):'
1369 1369 for dir_node in top_node.dirs:
1370 1370 if has_default_pre_load:
1371 1371 dir_node.default_pre_load = default_pre_load
1372 for tup in self.walk(dir_node):
1373 yield tup
1372 yield from self.walk(dir_node)
1374 1373
1375 1374 def get_filenodes_generator(self):
1376 1375 """
1377 1376 Returns generator that yields *all* file nodes.
1378 1377 """
1379 1378 for topnode, dirs, files in self.walk():
1380 for node in files:
1381 yield node
1379 yield from files
1382 1380
1383 1381 #
1384 1382 # Utilities for sub classes to support consistent behavior
@@ -1426,7 +1424,7 b' class BaseChangeset(BaseCommit, metaclas'
1426 1424 def __new__(cls, *args, **kwargs):
1427 1425 warnings.warn(
1428 1426 "Use BaseCommit instead of BaseChangeset", DeprecationWarning)
1429 return super(BaseChangeset, cls).__new__(cls, *args, **kwargs)
1427 return super().__new__(cls, *args, **kwargs)
1430 1428
1431 1429
1432 1430 class BaseInMemoryCommit(object):
@@ -1585,7 +1583,7 b' class BaseInMemoryCommit(object):'
1585 1583 pass
1586 1584 else:
1587 1585 raise NodeAlreadyExistsError(
1588 "Node `%s` already exists at %s" % (node.path, p))
1586 "Node `{}` already exists at {}".format(node.path, p))
1589 1587
1590 1588 # Check nodes marked as changed
1591 1589 missing = set(self.changed)
@@ -1668,7 +1666,7 b' class BaseInMemoryChangeset(BaseInMemory'
1668 1666 def __new__(cls, *args, **kwargs):
1669 1667 warnings.warn(
1670 1668 "Use BaseCommit instead of BaseInMemoryCommit", DeprecationWarning)
1671 return super(BaseInMemoryChangeset, cls).__new__(cls, *args, **kwargs)
1669 return super().__new__(cls, *args, **kwargs)
1672 1670
1673 1671
1674 1672 class EmptyCommit(BaseCommit):
@@ -1745,7 +1743,7 b' class EmptyChangeset(EmptyCommit, metacl'
1745 1743 warnings.warn(
1746 1744 "Parameter requested_revision not supported anymore",
1747 1745 DeprecationWarning)
1748 super(EmptyChangeset, self).__init__(
1746 super().__init__(
1749 1747 commit_id=cs, repo=repo, alias=alias, idx=revision,
1750 1748 message=message, author=author, date=date)
1751 1749
@@ -1832,7 +1830,7 b' class Config(object):'
1832 1830 return clone
1833 1831
1834 1832 def __repr__(self):
1835 return '<Config(%s sections) at %s>' % (
1833 return '<Config({} sections) at {}>'.format(
1836 1834 len(self._values), hex(id(self)))
1837 1835
1838 1836 def items(self, section):
@@ -1,5 +1,3 b''
1
2
3 1 # Copyright (C) 2014-2023 RhodeCode GmbH
4 2 #
5 3 # This program is free software: you can redistribute it and/or modify
@@ -1,5 +1,3 b''
1
2
3 1 # Copyright (C) 2014-2023 RhodeCode GmbH
4 2 #
5 3 # This program is free software: you can redistribute it and/or modify
@@ -476,8 +474,7 b' class GitCommit(base.BaseCommit):'
476 474 # ConfigParser fails if there are whitespaces, also it needs an iterable
477 475 # file like content
478 476 def iter_content(_content):
479 for line in _content.splitlines():
480 yield line
477 yield from _content.splitlines()
481 478
482 479 parser = configparser.RawConfigParser()
483 480 parser.read_file(iter_content(submodules_node.content))
@@ -1,5 +1,3 b''
1
2
3 1 # Copyright (C) 2014-2023 RhodeCode GmbH
4 2 #
5 3 # This program is free software: you can redistribute it and/or modify
@@ -1,5 +1,3 b''
1
2
3 1 # Copyright (C) 2014-2023 RhodeCode GmbH
4 2 #
5 3 # This program is free software: you can redistribute it and/or modify
@@ -1,5 +1,3 b''
1
2
3 1 # Copyright (C) 2014-2023 RhodeCode GmbH
4 2 #
5 3 # This program is free software: you can redistribute it and/or modify
@@ -55,7 +53,7 b' class GitRepository(BaseRepository):'
55 53 Git repository backend.
56 54 """
57 55 DEFAULT_BRANCH_NAME = os.environ.get('GIT_DEFAULT_BRANCH_NAME') or 'master'
58 DEFAULT_REF = 'branch:{}'.format(DEFAULT_BRANCH_NAME)
56 DEFAULT_REF = f'branch:{DEFAULT_BRANCH_NAME}'
59 57
60 58 contact = BaseRepository.DEFAULT_CONTACT
61 59
@@ -95,8 +93,8 b' class GitRepository(BaseRepository):'
95 93 return commit_ids
96 94
97 95 def _rebuild_cache(self, commit_ids):
98 self._commit_ids = dict((commit_id, index)
99 for index, commit_id in enumerate(commit_ids))
96 self._commit_ids = {commit_id: index
97 for index, commit_id in enumerate(commit_ids)}
100 98
101 99 def run_git_command(self, cmd, **opts):
102 100 """
@@ -375,7 +373,7 b' class GitRepository(BaseRepository):'
375 373 if name in self.tags:
376 374 raise TagAlreadyExistError("Tag %s already exists" % name)
377 375 commit = self.get_commit(commit_id=commit_id)
378 message = message or "Added tag %s for commit %s" % (name, commit.raw_id)
376 message = message or "Added tag {} for commit {}".format(name, commit.raw_id)
379 377
380 378 self._remote.set_refs('refs/tags/%s' % name, commit.raw_id)
381 379
@@ -421,7 +419,7 b' class GitRepository(BaseRepository):'
421 419 return tree
422 420
423 421 def get_remote_ref(self, ref_name):
424 ref_key = 'refs/remotes/origin/{}'.format(safe_str(ref_name))
422 ref_key = f'refs/remotes/origin/{safe_str(ref_name)}'
425 423 try:
426 424 return self._refs[ref_key]
427 425 except Exception:
@@ -643,7 +641,7 b' class GitRepository(BaseRepository):'
643 641 else:
644 642 output, __ = repo1.run_git_command(
645 643 ['log', '--reverse', '--pretty=format: %H', '-s',
646 '%s..%s' % (commit_id1, commit_id2)])
644 '{}..{}'.format(commit_id1, commit_id2)])
647 645 commits = [
648 646 repo1.get_commit(commit_id=commit_id, pre_load=pre_load)
649 647 for commit_id in self.COMMIT_ID_PAT.findall(output)]
@@ -797,7 +795,7 b' class GitRepository(BaseRepository):'
797 795 self.run_git_command(cmd, fail_on_stderr=False)
798 796
799 797 def _local_reset(self, branch_name):
800 branch_name = '{}'.format(branch_name)
798 branch_name = f'{branch_name}'
801 799 cmd = ['reset', '--hard', branch_name, '--']
802 800 self.run_git_command(cmd, fail_on_stderr=False)
803 801
@@ -880,7 +878,7 b' class GitRepository(BaseRepository):'
880 878 files = self.run_git_command(['diff', '--name-only', '--diff-filter', 'U'],
881 879 fail_on_stderr=False)[0].splitlines()
882 880 # NOTE(marcink): we add U notation for consistent with HG backend output
883 unresolved = ['U {}'.format(f) for f in files]
881 unresolved = [f'U {f}' for f in files]
884 882
885 883 # Cleanup any merge leftovers
886 884 self._remote.invalidate_vcs_cache()
@@ -914,7 +912,7 b' class GitRepository(BaseRepository):'
914 912 target_repo._local_pull(self.path, source_branch)
915 913 else:
916 914 cmd = ['push', os.path.abspath(repository_path),
917 '%s:%s' % (source_branch, target_branch)]
915 '{}:{}'.format(source_branch, target_branch)]
918 916 gitenv = {}
919 917 if rc_scm_data:
920 918 gitenv.update({'RC_SCM_DATA': rc_scm_data})
@@ -924,7 +922,7 b' class GitRepository(BaseRepository):'
924 922 self.run_git_command(cmd, fail_on_stderr=False, extra_env=gitenv)
925 923
926 924 def _get_new_pr_branch(self, source_branch, target_branch):
927 prefix = 'pr_%s-%s_' % (source_branch, target_branch)
925 prefix = 'pr_{}-{}_'.format(source_branch, target_branch)
928 926 pr_branches = []
929 927 for branch in self.branches:
930 928 if branch.startswith(prefix):
@@ -1,5 +1,3 b''
1
2
3 1 # Copyright (C) 2014-2023 RhodeCode GmbH
4 2 #
5 3 # This program is free software: you can redistribute it and/or modify
@@ -1,5 +1,3 b''
1
2
3 1 # Copyright (C) 2014-2023 RhodeCode GmbH
4 2 #
5 3 # This program is free software: you can redistribute it and/or modify
@@ -291,7 +289,7 b' class MercurialCommit(base.BaseCommit):'
291 289
292 290 if self._get_kind(path) != NodeKind.DIR:
293 291 raise CommitError(
294 "Directory does not exist for idx %s at '%s'" % (self.raw_id, path))
292 "Directory does not exist for idx {} at '{}'".format(self.raw_id, path))
295 293 path = self._fix_path(path)
296 294
297 295 filenodes = [
@@ -1,5 +1,3 b''
1
2
3 1 # Copyright (C) 2014-2023 RhodeCode GmbH
4 2 #
5 3 # This program is free software: you can redistribute it and/or modify
@@ -1,5 +1,3 b''
1
2
3 1 # Copyright (C) 2014-2023 RhodeCode GmbH
4 2 #
5 3 # This program is free software: you can redistribute it and/or modify
@@ -1,5 +1,3 b''
1
2
3 1 # Copyright (C) 2014-2023 RhodeCode GmbH
4 2 #
5 3 # This program is free software: you can redistribute it and/or modify
@@ -104,8 +102,8 b' class MercurialRepository(BaseRepository'
104 102 return commit_ids
105 103
106 104 def _rebuild_cache(self, commit_ids):
107 self._commit_ids = dict((commit_id, index)
108 for index, commit_id in enumerate(commit_ids))
105 self._commit_ids = {commit_id: index
106 for index, commit_id in enumerate(commit_ids)}
109 107
110 108 @CachedProperty
111 109 def branches(self):
@@ -180,7 +178,7 b' class MercurialRepository(BaseRepository'
180 178 local = kwargs.setdefault('local', False)
181 179
182 180 if message is None:
183 message = "Added tag %s for commit %s" % (name, commit.short_id)
181 message = "Added tag {} for commit {}".format(name, commit.short_id)
184 182
185 183 date, tz = date_to_timestamp_plus_offset(date)
186 184
@@ -531,17 +529,17 b' class MercurialRepository(BaseRepository'
531 529 commit_filter = []
532 530
533 531 if branch_name and not branch_ancestors:
534 commit_filter.append('branch("%s")' % (branch_name,))
532 commit_filter.append('branch("{}")'.format(branch_name))
535 533 elif branch_name and branch_ancestors:
536 commit_filter.append('ancestors(branch("%s"))' % (branch_name,))
534 commit_filter.append('ancestors(branch("{}"))'.format(branch_name))
537 535
538 536 if start_date and not end_date:
539 commit_filter.append('date(">%s")' % (start_date,))
537 commit_filter.append('date(">{}")'.format(start_date))
540 538 if end_date and not start_date:
541 commit_filter.append('date("<%s")' % (end_date,))
539 commit_filter.append('date("<{}")'.format(end_date))
542 540 if start_date and end_date:
543 541 commit_filter.append(
544 'date(">%s") and date("<%s")' % (start_date, end_date))
542 'date(">{}") and date("<{}")'.format(start_date, end_date))
545 543
546 544 if not show_hidden:
547 545 commit_filter.append('not obsolete()')
@@ -659,7 +657,7 b' class MercurialRepository(BaseRepository'
659 657 unresolved = None
660 658 if use_rebase:
661 659 try:
662 bookmark_name = 'rcbook%s%s' % (source_ref_commit_id, target_ref_commit_id)
660 bookmark_name = 'rcbook{}{}'.format(source_ref_commit_id, target_ref_commit_id)
663 661 self.bookmark(bookmark_name, revision=source_ref.commit_id)
664 662 self._remote.rebase(
665 663 source=source_ref_commit_id, dest=target_ref_commit_id)
@@ -689,7 +687,7 b' class MercurialRepository(BaseRepository'
689 687 self._remote.invalidate_vcs_cache()
690 688 self._remote.commit(
691 689 message=safe_str(merge_message),
692 username=safe_str('%s <%s>' % (user_name, user_email)))
690 username=safe_str('{} <{}>'.format(user_name, user_email)))
693 691 self._remote.invalidate_vcs_cache()
694 692 return self._identify(), True
695 693 except RepositoryError as e:
@@ -716,11 +714,11 b' class MercurialRepository(BaseRepository'
716 714 commit needs to be pushed.
717 715 """
718 716 self._update(source_ref.commit_id)
719 message = close_message or "Closing branch: `{}`".format(source_ref.name)
717 message = close_message or f"Closing branch: `{source_ref.name}`"
720 718 try:
721 719 self._remote.commit(
722 720 message=safe_str(message),
723 username=safe_str('%s <%s>' % (user_name, user_email)),
721 username=safe_str('{} <{}>'.format(user_name, user_email)),
724 722 close_branch=True)
725 723 self._remote.invalidate_vcs_cache()
726 724 return self._identify(), True
@@ -1,5 +1,3 b''
1
2
3 1 # Copyright (C) 2014-2023 RhodeCode GmbH
4 2 #
5 3 # This program is free software: you can redistribute it and/or modify
@@ -1,5 +1,3 b''
1
2
3 1 # Copyright (C) 2014-2023 RhodeCode GmbH
4 2 #
5 3 # This program is free software: you can redistribute it and/or modify
@@ -55,7 +53,7 b' class SubversionCommit(base.BaseCommit):'
55 53 # which knows how to translate commit index and commit id
56 54 self.raw_id = commit_id
57 55 self.short_id = commit_id
58 self.id = 'r%s' % (commit_id, )
56 self.id = 'r{}'.format(commit_id)
59 57
60 58 # TODO: Implement the following placeholder attributes
61 59 self.nodes = {}
@@ -201,7 +199,7 b' class SubversionCommit(base.BaseCommit):'
201 199 return nodes.NodeKind.DIR
202 200 else:
203 201 raise CommitError(
204 "Node does not exist at the given path '%s'" % (path, ))
202 "Node does not exist at the given path '{}'".format(path))
205 203
206 204 @LazyProperty
207 205 def _changes_cache(self):
@@ -1,5 +1,3 b''
1
2
3 1 # Copyright (C) 2014-2023 RhodeCode GmbH
4 2 #
5 3 # This program is free software: you can redistribute it and/or modify
@@ -1,5 +1,3 b''
1
2
3 1 # Copyright (C) 2014-2023 RhodeCode GmbH
4 2 #
5 3 # This program is free software: you can redistribute it and/or modify
@@ -1,5 +1,3 b''
1
2
3 1 # Copyright (C) 2014-2023 RhodeCode GmbH
4 2 #
5 3 # This program is free software: you can redistribute it and/or modify
@@ -223,7 +221,7 b' class SubversionRepository(base.BaseRepo'
223 221 commit_idx = svn_rev - 1
224 222 if commit_idx >= len(self.commit_ids):
225 223 raise CommitDoesNotExistError(
226 "Commit at index %s does not exist." % (commit_idx, ))
224 "Commit at index {} does not exist.".format(commit_idx))
227 225 return commit_idx
228 226
229 227 @staticmethod
@@ -247,7 +245,7 b' class SubversionRepository(base.BaseRepo'
247 245
248 246 def _check_path(self):
249 247 if not os.path.exists(self.path):
250 raise VCSError('Path "%s" does not exist!' % (self.path, ))
248 raise VCSError('Path "{}" does not exist!'.format(self.path))
251 249 if not self._remote.is_path_valid_repository(self.path):
252 250 raise VCSError(
253 251 'Path "%s" does not contain a Subversion repository' %
@@ -286,7 +284,7 b' class SubversionRepository(base.BaseRepo'
286 284 try:
287 285 commit_id = self.commit_ids[commit_idx]
288 286 except IndexError:
289 raise CommitDoesNotExistError('No commit with idx: {}'.format(commit_idx))
287 raise CommitDoesNotExistError(f'No commit with idx: {commit_idx}')
290 288
291 289 commit_id = self._sanitize_commit_id(commit_id)
292 290 commit = SubversionCommit(repository=self, commit_id=commit_id)
@@ -343,11 +341,11 b' class SubversionRepository(base.BaseRepo'
343 341 return commit_id
344 342 else:
345 343 raise CommitDoesNotExistError(
346 "Commit %s does not exist." % (commit_id, ))
344 "Commit {} does not exist.".format(commit_id))
347 345 if commit_id not in [
348 346 None, 'HEAD', 'tip', self.DEFAULT_BRANCH_NAME]:
349 347 raise CommitDoesNotExistError(
350 "Commit id %s not understood." % (commit_id, ))
348 "Commit id {} not understood.".format(commit_id))
351 349 svn_rev = self._remote.lookup('HEAD')
352 350 return str(svn_rev)
353 351
@@ -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
@@ -68,7 +66,7 b' def _remote_call(url, payload, exception'
68 66 log.warning(f'Received a "Connection reset by peer" error. '
69 67 f'Retrying... ({attempt + 1}/{retries})')
70 68 continue # Retry if connection reset error.
71 msg = '{}. \npycurl traceback: {}'.format(e, traceback.format_exc())
69 msg = f'{e}. \npycurl traceback: {traceback.format_exc()}'
72 70 raise exceptions.HttpVCSCommunicationError(msg)
73 71 except Exception as e:
74 72 message = getattr(e, 'message', '')
@@ -130,7 +128,7 b' def _streaming_remote_call(url, payload,'
130 128 response = session.post(url, data=msgpack.packb(payload), headers=headers)
131 129 except pycurl.error as e:
132 130 error_code, error_message = e.args
133 msg = '{}. \npycurl traceback: {}'.format(e, traceback.format_exc())
131 msg = f'{e}. \npycurl traceback: {traceback.format_exc()}'
134 132 raise exceptions.HttpVCSCommunicationError(msg)
135 133 except Exception as e:
136 134 message = getattr(e, 'message', '')
@@ -180,7 +178,7 b' class RemoteVCSMaker(object):'
180 178
181 179 @classmethod
182 180 def init_cache_region(cls, repo_id):
183 cache_namespace_uid = 'repo.{}'.format(repo_id)
181 cache_namespace_uid = f'repo.{repo_id}'
184 182 region = rc_cache.get_or_create_region('cache_repo', cache_namespace_uid)
185 183 return region, cache_namespace_uid
186 184
@@ -403,8 +401,7 b' class VcsHttpProxy(object):'
403 401 unpacker = msgpack.Unpacker()
404 402 for line in result.iter_content(chunk_size=self.CHUNK_SIZE):
405 403 unpacker.feed(line)
406 for chunk in unpacker:
407 yield chunk
404 yield from unpacker
408 405
409 406 def _get_result(self, result):
410 407 iterator = self._iterate(result)
@@ -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) 2014-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) 2014-2023 RhodeCode GmbH
4 2 #
5 3 # This program is free software: you can redistribute it and/or modify
@@ -56,8 +54,8 b" HOOKS_HOST = '127.0.0.1'"
56 54
57 55
58 56 MERGE_MESSAGE_TMPL = (
59 u'Merge pull request !{pr_id} from {source_repo} {source_ref_name}\n\n '
60 u'{pr_title}')
57 'Merge pull request !{pr_id} from {source_repo} {source_ref_name}\n\n '
58 '{pr_title}')
61 59 MERGE_DRY_RUN_MESSAGE = 'dry_run_merge_message_from_rhodecode'
62 60 MERGE_DRY_RUN_USER = 'Dry-Run User'
63 61 MERGE_DRY_RUN_EMAIL = 'dry-run-merge@rhodecode.com'
@@ -1,5 +1,3 b''
1
2
3 1 # Copyright (C) 2014-2023 RhodeCode GmbH
4 2 #
5 3 # This program is free software: you can redistribute it and/or modify
@@ -1,5 +1,3 b''
1
2
3 1 # Copyright (C) 2014-2023 RhodeCode GmbH
4 2 #
5 3 # This program is free software: you can redistribute it and/or modify
@@ -222,7 +220,7 b' def map_vcs_exceptions(func):'
222 220 # replace the first argument with a prefix exc name
223 221 args = ['{}:{}'.format(exc_name, _args[0] if _args else '?')] + _args[1:]
224 222 else:
225 args = [__traceback_info__ or '{}: UnhandledException'.format(exc_name)]
223 args = [__traceback_info__ or f'{exc_name}: UnhandledException']
226 224 if debug or __traceback_info__ and kind not in ['unhandled', 'lookup']:
227 225 # for other than unhandled errors also log the traceback
228 226 # can be useful for debugging
@@ -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
@@ -355,7 +355,7 b' class FileNode(Node):'
355 355 self._set_bulk_properties(pre_load)
356 356
357 357 def __eq__(self, other):
358 eq = super(FileNode, self).__eq__(other)
358 eq = super().__eq__(other)
359 359 if eq is not None:
360 360 return eq
361 361 return self.content == other.content
@@ -365,7 +365,7 b' class FileNode(Node):'
365 365 return hash((self.path, raw_id))
366 366
367 367 def __lt__(self, other):
368 lt = super(FileNode, self).__lt__(other)
368 lt = super().__lt__(other)
369 369 if lt is not None:
370 370 return lt
371 371 return self.content < other.content
@@ -751,17 +751,16 b' class DirNode(Node):'
751 751 """
752 752 if nodes and commit:
753 753 raise NodeError("Cannot use both nodes and commit")
754 super(DirNode, self).__init__(path, NodeKind.DIR)
754 super().__init__(path, NodeKind.DIR)
755 755 self.commit = commit
756 756 self._nodes = nodes
757 757 self.default_pre_load = default_pre_load or ['is_binary', 'size']
758 758
759 759 def __iter__(self):
760 for node in self.nodes:
761 yield node
760 yield from self.nodes
762 761
763 762 def __eq__(self, other):
764 eq = super(DirNode, self).__eq__(other)
763 eq = super().__eq__(other)
765 764 if eq is not None:
766 765 return eq
767 766 # check without entering each dir
@@ -770,7 +769,7 b' class DirNode(Node):'
770 769 return self_nodes_paths == other_nodes_paths
771 770
772 771 def __lt__(self, other):
773 lt = super(DirNode, self).__lt__(other)
772 lt = super().__lt__(other)
774 773 if lt is not None:
775 774 return lt
776 775 # check without entering each dir
@@ -788,16 +787,16 b' class DirNode(Node):'
788 787 nodes = self.commit.get_nodes(self.path, pre_load=self.default_pre_load)
789 788 else:
790 789 nodes = self._nodes
791 self._nodes_dict = dict((node.path, node) for node in nodes)
790 self._nodes_dict = {node.path: node for node in nodes}
792 791 return sorted(nodes)
793 792
794 793 @LazyProperty
795 794 def files(self):
796 return sorted((node for node in self.nodes if node.is_file()))
795 return sorted(node for node in self.nodes if node.is_file())
797 796
798 797 @LazyProperty
799 798 def dirs(self):
800 return sorted((node for node in self.nodes if node.is_dir()))
799 return sorted(node for node in self.nodes if node.is_dir())
801 800
802 801 def get_node(self, path):
803 802 """
@@ -873,7 +872,7 b' class RootNode(DirNode):'
873 872 """
874 873
875 874 def __init__(self, nodes=(), commit=None):
876 super(RootNode, self).__init__(path=b'', nodes=nodes, commit=commit)
875 super().__init__(path=b'', nodes=nodes, commit=commit)
877 876
878 877 def __repr__(self):
879 878 return f'<{self.__class__.__name__}>'
@@ -1,5 +1,3 b''
1
2
3 1 # Copyright (C) 2014-2023 RhodeCode GmbH
4 2 #
5 3 # This program is free software: you can redistribute it and/or modify
@@ -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) 2014-2023 RhodeCode GmbH
4 2 #
5 3 # This program is free software: you can redistribute it and/or modify
@@ -51,9 +49,9 b' def get_scm(path):'
51 49 found_scms = [(scm, path) for scm in get_scms_for_path(path)]
52 50
53 51 if len(found_scms) > 1:
54 found = ', '.join((x[0] for x in found_scms))
52 found = ', '.join(x[0] for x in found_scms)
55 53 raise VCSError(
56 'More than one [%s] scm found at given path %s' % (found, path))
54 'More than one [{}] scm found at given path {}'.format(found, path))
57 55
58 56 if len(found_scms) == 0:
59 57 raise VCSError('No scm found at given path %s' % path)
@@ -1,4 +1,3 b''
1
2 1 # Copyright (C) 2010-2023 RhodeCode GmbH
3 2 #
4 3 # This program is free software: you can redistribute it and/or modify
@@ -1,4 +1,3 b''
1
2 1 # Copyright (C) 2010-2023 RhodeCode GmbH
3 2 #
4 3 # This program is free software: you can redistribute it and/or modify
General Comments 0
You need to be logged in to leave comments. Login now