comparison mercurial/utils/urlutil.py @ 48913:f254fc73d956

global: bulk replace simple pycompat.iteritems(x) with x.items() pycompat.iteritems() just calls .items(). This commit applies a regular expression search and replace to convert simple instances of pycompat.iteritems() with .items(). There are still a handful of calls to pycompat.iteritems() remaining. But these all have more complicated expressions that I wasn't comfortable performing an automated replace on. In addition, some simple replacements were withheld because they broke pytype. These will be handled by their own changesets. Differential Revision: https://phab.mercurial-scm.org/D12318
author Gregory Szorc <gregory.szorc@gmail.com>
date Thu, 03 Mar 2022 18:28:30 -0800
parents a1538c05d855
children 642e31cb55f0
comparison
equal deleted inserted replaced
48912:a0674e916fb6 48913:f254fc73d956
451 451
452 def list_paths(ui, target_path=None): 452 def list_paths(ui, target_path=None):
453 """list all the (name, paths) in the passed ui""" 453 """list all the (name, paths) in the passed ui"""
454 result = [] 454 result = []
455 if target_path is None: 455 if target_path is None:
456 for name, paths in sorted(pycompat.iteritems(ui.paths)): 456 for name, paths in sorted(ui.paths.items()):
457 for p in paths: 457 for p in paths:
458 result.append((name, p)) 458 result.append((name, p))
459 459
460 else: 460 else:
461 for path in ui.paths.get(target_path, []): 461 for path in ui.paths.get(target_path, []):
917 917
918 def _apply_suboptions(self, ui, sub_options): 918 def _apply_suboptions(self, ui, sub_options):
919 # Now process the sub-options. If a sub-option is registered, its 919 # Now process the sub-options. If a sub-option is registered, its
920 # attribute will always be present. The value will be None if there 920 # attribute will always be present. The value will be None if there
921 # was no valid sub-option. 921 # was no valid sub-option.
922 for suboption, (attr, func) in pycompat.iteritems(_pathsuboptions): 922 for suboption, (attr, func) in _pathsuboptions.items():
923 if suboption not in sub_options: 923 if suboption not in sub_options:
924 setattr(self, attr, None) 924 setattr(self, attr, None)
925 continue 925 continue
926 926
927 value = func(ui, self, sub_options[suboption]) 927 value = func(ui, self, sub_options[suboption])
943 """Return sub-options and their values for this path. 943 """Return sub-options and their values for this path.
944 944
945 This is intended to be used for presentation purposes. 945 This is intended to be used for presentation purposes.
946 """ 946 """
947 d = {} 947 d = {}
948 for subopt, (attr, _func) in pycompat.iteritems(_pathsuboptions): 948 for subopt, (attr, _func) in _pathsuboptions.items():
949 value = getattr(self, attr) 949 value = getattr(self, attr)
950 if value is not None: 950 if value is not None:
951 d[subopt] = value 951 d[subopt] = value
952 return d 952 return d