Mercurial > public > mercurial-scm > hg
comparison mercurial/templatefilters.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 | 6000f5b25c9b |
children | 176f1a0d15dc |
comparison
equal
deleted
inserted
replaced
48912:a0674e916fb6 | 48913:f254fc73d956 |
---|---|
344 ) | 344 ) |
345 elif util.safehasattr(obj, b'keys'): | 345 elif util.safehasattr(obj, b'keys'): |
346 out = [ | 346 out = [ |
347 b'"%s": %s' | 347 b'"%s": %s' |
348 % (encoding.jsonescape(k, paranoid=paranoid), json(v, paranoid)) | 348 % (encoding.jsonescape(k, paranoid=paranoid), json(v, paranoid)) |
349 for k, v in sorted(pycompat.iteritems(obj)) | 349 for k, v in sorted(obj.items()) |
350 ] | 350 ] |
351 return b'{' + b', '.join(out) + b'}' | 351 return b'{' + b', '.join(out) + b'}' |
352 elif util.safehasattr(obj, b'__iter__'): | 352 elif util.safehasattr(obj, b'__iter__'): |
353 out = [json(i, paranoid) for i in obj] | 353 out = [json(i, paranoid) for i in obj] |
354 return b'[' + b', '.join(out) + b']' | 354 return b'[' + b', '.join(out) + b']' |
546 return text | 546 return text |
547 | 547 |
548 | 548 |
549 def loadfilter(ui, extname, registrarobj): | 549 def loadfilter(ui, extname, registrarobj): |
550 """Load template filter from specified registrarobj""" | 550 """Load template filter from specified registrarobj""" |
551 for name, func in pycompat.iteritems(registrarobj._table): | 551 for name, func in registrarobj._table.items(): |
552 filters[name] = func | 552 filters[name] = func |
553 | 553 |
554 | 554 |
555 # tell hggettext to extract docstrings from these functions: | 555 # tell hggettext to extract docstrings from these functions: |
556 i18nfunctions = filters.values() | 556 i18nfunctions = filters.values() |