forked from upstream/UXP-mirror
Issue #2974 - Part 6: Adapt dict
2to3 . --fix dict -wpn Py2 dict was a list by default, the iterator versions were switched around to be the default. This lets you have the old behavior. Mechanical. Ref: PEP 3106 https://peps.python.org/pep-3106/
This commit is contained in:
1 parent
112c119477
commit
8c0f0ccdcf
422 files changed
+1180
-1180
No files matched your search
@@ -38,7 +38,7 @@ def test_verification_perf(n = 100):
|
||||
def print_dict(title, d):
|
||||
print(title)
|
||||
print('-' * len(title))
|
||||
for k, v in d.items():
|
||||
for k, v in list(d.items()):
|
||||
print(k, '\t', v)
|
||||
print()
|
||||
|
||||
|
||||
@@ -127,7 +127,7 @@ class _priorityDictionary(dict):
|
||||
dict.__setitem__(self,key,val)
|
||||
heap = self.__heap
|
||||
if len(heap) > 2 * len(self):
|
||||
self.__heap = [(v,k) for k,v in self.iteritems()]
|
||||
self.__heap = [(v,k) for k,v in self.items()]
|
||||
self.__heap.sort() # builtin sort probably faster than O(n)-time heapify
|
||||
else:
|
||||
newPair = (val,key)
|
||||
|
||||
@@ -67,7 +67,7 @@ class TestGraphUtil (unittest.TestCase):
|
||||
|
||||
total_counts = sum(counts.values())
|
||||
P = {}
|
||||
for degree, count in counts.items():
|
||||
for degree, count in list(counts.items()):
|
||||
P[degree] = count * 1.0 / total_counts
|
||||
|
||||
# XXX: use algoritm <http://stackoverflow.com/questions/3433486/how-to-do-exponential-and-logarithmic-curve-fitting-in-python-i-found-only-polyn>
|
||||
|
||||
@@ -64,7 +64,7 @@ def eval_marker(value):
|
||||
|
||||
class M:
|
||||
def __init__(self, **kwds):
|
||||
for k, v in kwds.items():
|
||||
for k, v in list(kwds.items()):
|
||||
setattr(self, k, v)
|
||||
|
||||
variables = {
|
||||
@@ -634,7 +634,7 @@ else:
|
||||
sep_boundary = '\n--' + boundary
|
||||
end_boundary = sep_boundary + '--'
|
||||
body = StringIO.StringIO()
|
||||
for key, value in data.items():
|
||||
for key, value in list(data.items()):
|
||||
if not isinstance(value, list):
|
||||
value = [value]
|
||||
|
||||
|
||||
@@ -342,7 +342,7 @@ class DTDChecker(Checker):
|
||||
if u != ru:
|
||||
msgs.append("units for %s don't match "
|
||||
"(%s != %s)" % (s, u, ru))
|
||||
for s in refMap.iterkeys():
|
||||
for s in refMap.keys():
|
||||
msgs.insert(0, '%s only in reference' % s)
|
||||
if msgs:
|
||||
yield ('warning', 0, ', '.join(msgs), 'css')
|
||||
|
||||
@@ -42,7 +42,7 @@ class Tree(object):
|
||||
old = None
|
||||
new = tuple(parts)
|
||||
t = self
|
||||
for k, v in self.branches.iteritems():
|
||||
for k, v in self.branches.items():
|
||||
for i, part in enumerate(zip(k, parts)):
|
||||
if part[0] != part[1]:
|
||||
i -= 1
|
||||
@@ -79,7 +79,7 @@ class Tree(object):
|
||||
If flag is 'value', key_or_value is a value object, otherwise
|
||||
(flag is 'key') it's a key string.
|
||||
'''
|
||||
keys = self.branches.keys()
|
||||
keys = list(self.branches.keys())
|
||||
keys.sort()
|
||||
if self.value is not None:
|
||||
yield (depth, 'value', self.value)
|
||||
@@ -94,7 +94,7 @@ class Tree(object):
|
||||
Only the values need to take care that they're JSON-able.
|
||||
'''
|
||||
json = {}
|
||||
keys = self.branches.keys()
|
||||
keys = list(self.branches.keys())
|
||||
keys.sort()
|
||||
if self.value is not None:
|
||||
json['value'] = self.value
|
||||
@@ -203,14 +203,14 @@ class Observer(object):
|
||||
|
||||
self.summary = defaultdict(intdict)
|
||||
if 'summary' in state:
|
||||
for loc, stats in state['summary'].iteritems():
|
||||
for loc, stats in state['summary'].items():
|
||||
self.summary[loc].update(stats)
|
||||
self.details = state['details']
|
||||
self.filter = None
|
||||
|
||||
def getSummary(self):
|
||||
plaindict = {}
|
||||
for k, v in self.summary.iteritems():
|
||||
for k, v in self.summary.items():
|
||||
plaindict[k] = dict(v)
|
||||
return plaindict
|
||||
|
||||
@@ -261,7 +261,7 @@ class Observer(object):
|
||||
|
||||
def toExhibit(self):
|
||||
items = []
|
||||
for locale in sorted(self.summary.iterkeys()):
|
||||
for locale in sorted(self.summary.keys()):
|
||||
summary = self.summary[locale]
|
||||
if locale is not None:
|
||||
item = {'id': 'xxx/' + locale,
|
||||
@@ -339,10 +339,10 @@ class Observer(object):
|
||||
return '\n'.join(o)
|
||||
|
||||
out = []
|
||||
for locale, summary in sorted(self.summary.iteritems()):
|
||||
for locale, summary in sorted(self.summary.items()):
|
||||
if locale is not None:
|
||||
out.append(locale + ':')
|
||||
out += [k + ': ' + str(v) for k, v in sorted(summary.iteritems())]
|
||||
out += [k + ': ' + str(v) for k, v in sorted(summary.items())]
|
||||
total = sum([summary[k]
|
||||
for k in ['changed', 'unchanged', 'report', 'missing',
|
||||
'missingInFiles']
|
||||
@@ -453,7 +453,7 @@ class ContentComparer:
|
||||
return
|
||||
self.reference[ref_file] = p.parse()
|
||||
ref = self.reference[ref_file]
|
||||
ref_list = ref[1].keys()
|
||||
ref_list = list(ref[1].keys())
|
||||
ref_list.sort()
|
||||
try:
|
||||
p.readContents(l10n.getContents())
|
||||
@@ -473,7 +473,7 @@ class ContentComparer:
|
||||
return (i, offset - lines[i - 1])
|
||||
return (1, offset)
|
||||
|
||||
l10n_list = l10n_map.keys()
|
||||
l10n_list = list(l10n_map.keys())
|
||||
l10n_list.sort()
|
||||
ar = AddRemove()
|
||||
ar.set_left(ref_list)
|
||||
|
||||
@@ -499,7 +499,7 @@ class BookmarksParser(Parser):
|
||||
t = tks[i]
|
||||
if t._type == START:
|
||||
k.append(t.tag)
|
||||
keys = t.attrs.keys()
|
||||
keys = list(t.attrs.keys())
|
||||
keys.sort()
|
||||
for attrname in keys:
|
||||
yield self.BMEntity('.'.join(k) + '.@' + attrname,
|
||||
|
||||
@@ -355,7 +355,7 @@ class EnumerateApp(object):
|
||||
code and an directory enumerator will be given.
|
||||
'''
|
||||
dirmap = dict(self.config.directories())
|
||||
mods = dirmap.keys()
|
||||
mods = list(dirmap.keys())
|
||||
mods.sort()
|
||||
for mod in mods:
|
||||
if self.reference == 'en-US':
|
||||
|
||||
@@ -22,7 +22,7 @@ class TestFileComparison(unittest.TestCase):
|
||||
filecomp = self.mock_FileComparison(_listdir)
|
||||
filecomp.files()
|
||||
self.assertEqual(filecomp.locales(), [])
|
||||
self.assertEqual(filecomp._reference.keys(), ['my_app'])
|
||||
self.assertEqual(list(filecomp._reference.keys()), ['my_app'])
|
||||
file_ = filecomp._reference['my_app']
|
||||
self.assertEqual(file_.file, 'locales/my_app.en-US.properties')
|
||||
|
||||
@@ -36,6 +36,6 @@ class TestFileComparison(unittest.TestCase):
|
||||
filecomp.files()
|
||||
self.assertEqual(filecomp.locales(),
|
||||
['ar', 'sr-Latn', 'sv-SE'])
|
||||
self.assertEqual(filecomp._files['ar'].keys(), ['my_app'])
|
||||
self.assertEqual(list(filecomp._files['ar'].keys()), ['my_app'])
|
||||
file_ = filecomp._files['ar']['my_app']
|
||||
self.assertEqual(file_.file, 'locales/my_app.ar.properties')
|
||||
@@ -96,11 +96,11 @@ class Manifest(object):
|
||||
rv = defaultdict(dict)
|
||||
localizable = manifest_fragment.pop('locales', {})
|
||||
if localizable:
|
||||
for locale, keyvalue in localizable.iteritems():
|
||||
for key, value in keyvalue.iteritems():
|
||||
for locale, keyvalue in localizable.items():
|
||||
for key, value in keyvalue.items():
|
||||
key = '.'.join(['locales', 'AB_CD', key])
|
||||
rv[locale][key] = value
|
||||
for key, sub_manifest in manifest_fragment.iteritems():
|
||||
for key, sub_manifest in manifest_fragment.items():
|
||||
if not isinstance(sub_manifest, dict):
|
||||
continue
|
||||
subdict = self.extract_manifest_strings(sub_manifest)
|
||||
@@ -108,7 +108,7 @@ class Manifest(object):
|
||||
for locale, keyvalue in subdict:
|
||||
rv[locale].update((key + '.' + subkey, value)
|
||||
for subkey, value
|
||||
in keyvalue.iteritems())
|
||||
in keyvalue.items())
|
||||
return rv
|
||||
|
||||
def compare(self, locales):
|
||||
@@ -166,7 +166,7 @@ class FileComparison(object):
|
||||
'''Get the locales present in the webapp
|
||||
'''
|
||||
self.files()
|
||||
locales = self._files.keys()
|
||||
locales = list(self._files.keys())
|
||||
locales.sort()
|
||||
return locales
|
||||
|
||||
|
||||
@@ -518,7 +518,7 @@ class Section(dict):
|
||||
self._initialise()
|
||||
# we do this explicitly so that __setitem__ is used properly
|
||||
# (rather than just passing to ``dict.__init__``)
|
||||
for entry, value in indict.iteritems():
|
||||
for entry, value in indict.items():
|
||||
self[entry] = value
|
||||
|
||||
|
||||
@@ -721,7 +721,7 @@ class Section(dict):
|
||||
|
||||
def items(self):
|
||||
"""D.items() -> list of D's (key, value) pairs, as 2-tuples"""
|
||||
return list(zip((self.scalars + self.sections), self.values()))
|
||||
return list(zip((self.scalars + self.sections), list(self.values())))
|
||||
|
||||
|
||||
def keys(self):
|
||||
@@ -736,7 +736,7 @@ class Section(dict):
|
||||
|
||||
def iteritems(self):
|
||||
"""D.iteritems() -> an iterator over the (key, value) items of D"""
|
||||
return iter(self.items())
|
||||
return iter(list(self.items()))
|
||||
|
||||
|
||||
def iterkeys(self):
|
||||
@@ -748,7 +748,7 @@ class Section(dict):
|
||||
|
||||
def itervalues(self):
|
||||
"""D.itervalues() -> an iterator over the values of D"""
|
||||
return iter(self.values())
|
||||
return iter(list(self.values()))
|
||||
|
||||
|
||||
def __repr__(self):
|
||||
@@ -814,7 +814,7 @@ class Section(dict):
|
||||
>>> c2
|
||||
ConfigObj({'section1': {'option1': 'False', 'subsection': {'more_options': 'False'}}})
|
||||
"""
|
||||
for key, val in indict.items():
|
||||
for key, val in list(indict.items()):
|
||||
if (key in self and isinstance(self[key], dict) and
|
||||
isinstance(val, dict)):
|
||||
self[key].merge(val)
|
||||
@@ -1224,7 +1224,7 @@ class ConfigObj(Section):
|
||||
for entry in options:
|
||||
if entry not in OPTION_DEFAULTS:
|
||||
raise TypeError('Unrecognised option "%s".' % entry)
|
||||
for entry, value in OPTION_DEFAULTS.items():
|
||||
for entry, value in list(OPTION_DEFAULTS.items()):
|
||||
if entry not in options:
|
||||
options[entry] = value
|
||||
keyword_value = _options[entry]
|
||||
@@ -1423,7 +1423,7 @@ class ConfigObj(Section):
|
||||
enc = BOM_LIST[self.encoding.lower()]
|
||||
if enc == 'utf_16':
|
||||
# For UTF16 we try big endian and little endian
|
||||
for BOM, (encoding, final_encoding) in BOMS.items():
|
||||
for BOM, (encoding, final_encoding) in list(BOMS.items()):
|
||||
if not final_encoding:
|
||||
# skip UTF8
|
||||
continue
|
||||
@@ -1453,7 +1453,7 @@ class ConfigObj(Section):
|
||||
return self._decode(infile, self.encoding)
|
||||
|
||||
# No encoding specified - so we need to check for UTF8/UTF16
|
||||
for BOM, (encoding, final_encoding) in BOMS.items():
|
||||
for BOM, (encoding, final_encoding) in list(BOMS.items()):
|
||||
if not line.startswith(BOM):
|
||||
continue
|
||||
else:
|
||||
@@ -2422,7 +2422,7 @@ def flatten_errors(cfg, res, levels=None, results=None):
|
||||
if levels:
|
||||
levels.pop()
|
||||
return results
|
||||
for (key, val) in res.items():
|
||||
for (key, val) in list(res.items()):
|
||||
if val == True:
|
||||
continue
|
||||
if isinstance(cfg.get(key), dict):
|
||||
|
||||
@@ -615,7 +615,7 @@ class Validator(object):
|
||||
fun_kwargs = dict(fun_kwargs)
|
||||
else:
|
||||
fun_name, fun_args, fun_kwargs, default = self._parse_check(check)
|
||||
fun_kwargs = dict([(str(key), value) for (key, value) in fun_kwargs.items()])
|
||||
fun_kwargs = dict([(str(key), value) for (key, value) in list(fun_kwargs.items())])
|
||||
self._cache[check] = fun_name, list(fun_args), dict(fun_kwargs), default
|
||||
return fun_name, fun_args, fun_kwargs, default
|
||||
|
||||
|
||||
@@ -105,7 +105,7 @@ class ApplicationDigest(univ.Sequence):
|
||||
|
||||
def meets_requirements(items, requirements):
|
||||
for r in requirements:
|
||||
for n, v in r.items():
|
||||
for n, v in list(r.items()):
|
||||
if n not in items or items[n] != v: return False
|
||||
return True
|
||||
|
||||
|
||||
@@ -14,7 +14,7 @@ class CommandContext(object):
|
||||
self.log_manager = log_manager
|
||||
self.commands = commands
|
||||
|
||||
for k,v in kwargs.items():
|
||||
for k,v in list(kwargs.items()):
|
||||
setattr(self, k, v)
|
||||
|
||||
|
||||
|
||||
@@ -19,7 +19,7 @@ class BuiltinCommands(object):
|
||||
@property
|
||||
def command_keys(self):
|
||||
# NOTE 'REMOVED' is a function in testing/mochitest/mach_commands.py
|
||||
return (k for k, v in self.context.commands.command_handlers.items()
|
||||
return (k for k, v in list(self.context.commands.command_handlers.items())
|
||||
if not v.conditions or v.conditions[0].__name__ != 'REMOVED')
|
||||
|
||||
@Command('mach-commands', category='misc',
|
||||
|
||||
@@ -397,10 +397,10 @@ class ConfigSettings(collections.Mapping):
|
||||
meta = self._format_metadata(provider, section, option, *setting[1:])
|
||||
config_settings[section][option] = meta
|
||||
|
||||
for section_name, settings in config_settings.items():
|
||||
for section_name, settings in list(config_settings.items()):
|
||||
section = self._settings.get(section_name, {})
|
||||
|
||||
for k, v in settings.items():
|
||||
for k, v in list(settings.items()):
|
||||
if k in section:
|
||||
raise ConfigException('Setting already registered: %s.%s' %
|
||||
section_name, k)
|
||||
@@ -432,7 +432,7 @@ class ConfigSettings(collections.Mapping):
|
||||
if self._finalized:
|
||||
return
|
||||
|
||||
for section, settings in self._settings.items():
|
||||
for section, settings in list(self._settings.items()):
|
||||
s = ConfigSettings.ConfigSection(self._config, section, settings)
|
||||
self._sections[section] = s
|
||||
|
||||
@@ -445,7 +445,7 @@ class ConfigSettings(collections.Mapping):
|
||||
def __iter__(self):
|
||||
self._finalize()
|
||||
|
||||
return iter(self._sections.keys())
|
||||
return iter(list(self._sections.keys()))
|
||||
|
||||
def __contains__(self, k):
|
||||
return k in self._settings
|
||||
|
||||
@@ -243,7 +243,7 @@ class CommandAction(argparse.Action):
|
||||
r = self._mach_registrar
|
||||
disabled_commands = []
|
||||
|
||||
cats = [(k, v[2]) for k, v in r.categories.items()]
|
||||
cats = [(k, v[2]) for k, v in list(r.categories.items())]
|
||||
sorted_cats = sorted(cats, key=itemgetter(1), reverse=True)
|
||||
for category, priority in sorted_cats:
|
||||
group = None
|
||||
@@ -375,7 +375,7 @@ class CommandAction(argparse.Action):
|
||||
' subcommand [subcommand arguments]'
|
||||
group = parser.add_argument_group('Sub Commands')
|
||||
|
||||
for subcommand, subhandler in sorted(handler.subcommand_handlers.iteritems()):
|
||||
for subcommand, subhandler in sorted(handler.subcommand_handlers.items()):
|
||||
group.add_argument(subcommand, help=subhandler.description,
|
||||
action='store_true')
|
||||
|
||||
@@ -406,7 +406,7 @@ class CommandAction(argparse.Action):
|
||||
|
||||
def _suggest_command(self, command):
|
||||
# Make sure we don't suggest any deprecated commands.
|
||||
names = [h.name for h in self._mach_registrar.command_handlers.values()
|
||||
names = [h.name for h in list(self._mach_registrar.command_handlers.values())
|
||||
if h.cls.__name__ != 'DeprecatedCommands']
|
||||
# We first try to look for a valid command that is very similar to the given command.
|
||||
suggested_commands = difflib.get_close_matches(command, names, cutoff=0.8)
|
||||
|
||||
@@ -108,7 +108,7 @@ class ProcessExecutionMixin(LoggingMixin):
|
||||
# binary. utf-8 is our globally assumed default. If the caller doesn't
|
||||
# want UTF-8, they shouldn't pass in a unicode instance.
|
||||
normalized_env = {}
|
||||
for k, v in use_env.items():
|
||||
for k, v in list(use_env.items()):
|
||||
if isinstance(k, unicode):
|
||||
k = k.encode('utf-8', 'strict')
|
||||
|
||||
|
||||
@@ -27,7 +27,7 @@ def itergraphreport(nodes, describe_edge, name='G'):
|
||||
yield 'digraph %s {\n' % (name,)
|
||||
attr = dict(rankdir='LR', concentrate='true')
|
||||
cpatt = '%s="%s"'
|
||||
for item in attr.iteritems():
|
||||
for item in attr.items():
|
||||
yield '\t%s;\n' % (cpatt % item,)
|
||||
|
||||
# find all packages (subgraphs)
|
||||
@@ -45,7 +45,7 @@ def itergraphreport(nodes, describe_edge, name='G'):
|
||||
node,
|
||||
','.join([
|
||||
(cpatt % item) for item in
|
||||
nodevisitor(node, data, outgoing, incoming).iteritems()
|
||||
nodevisitor(node, data, outgoing, incoming).items()
|
||||
]),
|
||||
)
|
||||
|
||||
@@ -64,7 +64,7 @@ def itergraphreport(nodes, describe_edge, name='G'):
|
||||
yield edgestr % (
|
||||
head,
|
||||
tail,
|
||||
','.join([(cpatt % item) for item in attribs.iteritems()]),
|
||||
','.join([(cpatt % item) for item in attribs.items()]),
|
||||
)
|
||||
|
||||
for s in do_graph(graph, '\t'):
|
||||
|
||||
@@ -183,7 +183,7 @@ def _make():
|
||||
kwargs = args[0]._objects_
|
||||
args = ()
|
||||
self._objects_ = {}
|
||||
iargs = chain(izip(self._names_, args), kwargs.items())
|
||||
iargs = chain(izip(self._names_, args), list(kwargs.items()))
|
||||
for key, value in iargs:
|
||||
if key not in self._names_ and key != "_endian_":
|
||||
raise TypeError
|
||||
|
||||
@@ -64,7 +64,7 @@ def eval_marker(value):
|
||||
|
||||
class M:
|
||||
def __init__(self, **kwds):
|
||||
for k, v in kwds.items():
|
||||
for k, v in list(kwds.items()):
|
||||
setattr(self, k, v)
|
||||
|
||||
variables = {
|
||||
@@ -634,7 +634,7 @@ else:
|
||||
sep_boundary = '\n--' + boundary
|
||||
end_boundary = sep_boundary + '--'
|
||||
body = StringIO.StringIO()
|
||||
for key, value in data.items():
|
||||
for key, value in list(data.items()):
|
||||
if not isinstance(value, list):
|
||||
value = [value]
|
||||
|
||||
|
||||
@@ -607,7 +607,7 @@ class NonCallableMock(Base):
|
||||
self.call_args_list = _CallList()
|
||||
self.method_calls = _CallList()
|
||||
|
||||
for child in self._mock_children.values():
|
||||
for child in list(self._mock_children.values()):
|
||||
if isinstance(child, _SpecState):
|
||||
continue
|
||||
child.reset_mock()
|
||||
@@ -626,7 +626,7 @@ class NonCallableMock(Base):
|
||||
|
||||
>>> attrs = {'method.return_value': 3, 'other.side_effect': KeyError}
|
||||
>>> mock.configure_mock(**attrs)"""
|
||||
for arg, val in sorted(kwargs.items(),
|
||||
for arg, val in sorted(list(kwargs.items()),
|
||||
# we sort on the number of dots so that
|
||||
# attributes are set before we set attributes on
|
||||
# attributes
|
||||
@@ -1942,7 +1942,7 @@ def _format_call_signature(name, args, kwargs):
|
||||
formatted_args = ''
|
||||
args_string = ', '.join([repr(arg) for arg in args])
|
||||
kwargs_string = ', '.join([
|
||||
'%s=%r' % (key, value) for key, value in kwargs.items()
|
||||
'%s=%r' % (key, value) for key, value in list(kwargs.items())
|
||||
])
|
||||
if args_string:
|
||||
formatted_args = args_string
|
||||
|
||||
@@ -68,7 +68,7 @@ def all_dependencies(*targets, **kwargs):
|
||||
del all_targets[dependency]
|
||||
all_targets[dependency] = True
|
||||
|
||||
return all_targets.keys()
|
||||
return list(all_targets.keys())
|
||||
|
||||
def get_components(path):
|
||||
"""Take a path and return all the components of the path."""
|
||||
@@ -114,7 +114,7 @@ def add_extra_dependencies(target_pairs, dependency_map):
|
||||
make_dirs[make_dir] = True
|
||||
|
||||
all_components = []
|
||||
for make_dir in make_dirs.iterkeys():
|
||||
for make_dir in make_dirs.keys():
|
||||
all_components.extend(get_components(make_dir))
|
||||
|
||||
for i in all_dependencies(*all_components, dependency_map=dependency_map):
|
||||
|
||||
@@ -12,5 +12,5 @@ sys.path.append(os.path.join(os.path.dirname(__file__), '..'))
|
||||
|
||||
from shellutil import quote
|
||||
|
||||
for key, value in os.environ.items():
|
||||
for key, value in list(os.environ.items()):
|
||||
print(('%s=%s' % (key, quote(value))))
|
||||
@@ -97,7 +97,7 @@ def main(args):
|
||||
regions = properties.get_dict('browser.search.defaultenginename')
|
||||
|
||||
browsersearch['regions'] = {}
|
||||
for region in regions.keys():
|
||||
for region in list(regions.keys()):
|
||||
region_default = regions[region]
|
||||
region_engines = properties.get_list('browser.search.order.{region}'.format(region=region))
|
||||
|
||||
|
||||
@@ -55,7 +55,7 @@ def process_define_file(output, input):
|
||||
'CONFIGURE_DEFINE_FILE')
|
||||
defines = '\n'.join(sorted(
|
||||
'#define %s %s' % (name, val)
|
||||
for name, val in config.defines.iteritems()
|
||||
for name, val in config.defines.items()
|
||||
if name not in config.non_global_defines))
|
||||
l = l[:m.start('cmd') - 1] \
|
||||
+ defines + l[m.end('name'):]
|
||||
|
||||
@@ -433,7 +433,7 @@ ARCHIVE_FILES = {
|
||||
# "common" is our catch all archive and it ignores things from other archives.
|
||||
# Verify nothing sneaks into ARCHIVE_FILES without a corresponding exclusion
|
||||
# rule in the "common" archive.
|
||||
for k, v in ARCHIVE_FILES.items():
|
||||
for k, v in list(ARCHIVE_FILES.items()):
|
||||
# Skip mozharness because it isn't staged.
|
||||
if k in ('common', 'mozharness'):
|
||||
continue
|
||||
|
||||
@@ -58,7 +58,7 @@ def process(input_dir, inc_paths, cache_dir, header_dir, xpt_dir, deps_dir, modu
|
||||
|
||||
# TODO use FileAvoidWrite once it supports binary mode.
|
||||
xpt_path = os.path.join(xpt_dir, '%s.xpt' % module)
|
||||
xpt_link(xpts.values()).write(xpt_path)
|
||||
xpt_link(list(xpts.values())).write(xpt_path)
|
||||
|
||||
rule.add_targets([xpt_path])
|
||||
if deps_dir:
|
||||
|
||||
@@ -183,7 +183,7 @@ class ArtifactJob(object):
|
||||
|
||||
with JarWriter(file=processed_filename, optimize=False, compress_level=5) as writer:
|
||||
reader = JarReader(filename)
|
||||
for filename, entry in reader.entries.iteritems():
|
||||
for filename, entry in reader.entries.items():
|
||||
for pattern, (src_prefix, dest_prefix) in self.test_artifact_patterns:
|
||||
if not mozpath.match(filename, pattern):
|
||||
continue
|
||||
@@ -552,7 +552,7 @@ class CacheManager(object):
|
||||
|
||||
def print_cache(self):
|
||||
with self:
|
||||
for item in self._cache.items():
|
||||
for item in list(self._cache.items()):
|
||||
self.log(logging.INFO, 'artifact',
|
||||
{'item': item},
|
||||
'{item}')
|
||||
@@ -565,7 +565,7 @@ class CacheManager(object):
|
||||
# We use the persisted LRU caches to our advantage. The first item is
|
||||
# most recent.
|
||||
with self:
|
||||
item = next(self._cache.items(), None)
|
||||
item = next(list(self._cache.items()), None)
|
||||
if item is not None:
|
||||
(name, args, sorted_kwargs), result = item
|
||||
self.print_last_item(args, sorted_kwargs, result)
|
||||
@@ -596,7 +596,7 @@ class PushheadCache(CacheManager):
|
||||
if req.status_code not in list(range(200, 300)):
|
||||
raise ValueError
|
||||
result = req.json()
|
||||
[found_pushid] = result['pushes'].keys()
|
||||
[found_pushid] = list(result['pushes'].keys())
|
||||
return int(found_pushid)
|
||||
|
||||
@cachedmethod(operator.attrgetter('_cache'))
|
||||
@@ -609,7 +609,7 @@ class PushheadCache(CacheManager):
|
||||
headers={'Accept': 'application/json'})
|
||||
result = req.json()
|
||||
return [
|
||||
p['changesets'][-1] for p in result['pushes'].values()
|
||||
p['changesets'][-1] for p in list(result['pushes'].values())
|
||||
]
|
||||
|
||||
class TaskCache(CacheManager):
|
||||
@@ -847,7 +847,7 @@ class Artifacts(object):
|
||||
|
||||
candidate_pushheads = collections.defaultdict(list)
|
||||
|
||||
for tree, pushid in found_pushids.iteritems():
|
||||
for tree, pushid in found_pushids.items():
|
||||
end = pushid
|
||||
start = pushid - NUM_PUSHHEADS_TO_QUERY_PER_PARENT
|
||||
|
||||
|
||||
@@ -252,7 +252,7 @@ class BuildBackend(LoggingMixin):
|
||||
srcdir = mozpath.dirname(obj.input_path)
|
||||
pp.context.update({
|
||||
k: ' '.join(v) if isinstance(v, list) else v
|
||||
for k, v in obj.config.substs.iteritems()
|
||||
for k, v in obj.config.substs.items()
|
||||
})
|
||||
pp.context.update(
|
||||
top_srcdir=obj.topsrcdir,
|
||||
|
||||
@@ -195,11 +195,11 @@ class TestManager(object):
|
||||
def add_defaults(self, manifest):
|
||||
if not hasattr(manifest, 'manifest_defaults'):
|
||||
return
|
||||
for sub_manifest, defaults in manifest.manifest_defaults.items():
|
||||
for sub_manifest, defaults in list(manifest.manifest_defaults.items()):
|
||||
self.manifest_defaults[sub_manifest] = defaults
|
||||
|
||||
def add_installs(self, obj, topsrcdir):
|
||||
for src, (dest, _) in obj.installs.iteritems():
|
||||
for src, (dest, _) in obj.installs.items():
|
||||
key = src[len(topsrcdir)+1:]
|
||||
self.installs_by_path[key].append((src, dest))
|
||||
for src, pat, dest in obj.pattern_installs:
|
||||
@@ -366,7 +366,7 @@ class CommonBackend(BuildBackend):
|
||||
|
||||
path = mozpath.join(self.environment.topobjdir, 'test-installs.pkl')
|
||||
with self._write_file(path, mode='rb') as fh:
|
||||
pickle.dump({k: v for k, v in self._test_manager.installs_by_path.items()
|
||||
pickle.dump({k: v for k, v in list(self._test_manager.installs_by_path.items())
|
||||
if k in self._test_manager.deferred_installs},
|
||||
fh,
|
||||
protocol=2)
|
||||
|
||||
@@ -176,7 +176,7 @@ class ConfigEnvironment(object):
|
||||
except UnicodeDecodeError:
|
||||
return v.decode('utf-8', 'replace')
|
||||
|
||||
for k, v in self.substs.items():
|
||||
for k, v in list(self.substs.items()):
|
||||
if not isinstance(v, StringTypes):
|
||||
if isinstance(v, Iterable):
|
||||
type(v)(decode(i) for i in v)
|
||||
|
||||
@@ -130,12 +130,12 @@ class FasterMakeBackend(CommonBackend, PartialBackend):
|
||||
if value is not None:
|
||||
mk.add_statement('%s = %s' % (var, value))
|
||||
|
||||
install_manifests_bases = self._install_manifests.keys()
|
||||
install_manifests_bases = list(self._install_manifests.keys())
|
||||
|
||||
# Add information for chrome manifest generation
|
||||
manifest_targets = []
|
||||
|
||||
for target, entries in self._manifest_entries.iteritems():
|
||||
for target, entries in self._manifest_entries.items():
|
||||
manifest_targets.append(target)
|
||||
install_target = mozpath.basedir(target, install_manifests_bases)
|
||||
self._install_manifests[install_target].add_content(
|
||||
@@ -144,16 +144,16 @@ class FasterMakeBackend(CommonBackend, PartialBackend):
|
||||
|
||||
# Add information for install manifests.
|
||||
mk.add_statement('INSTALL_MANIFESTS = %s'
|
||||
% ' '.join(self._install_manifests.keys()))
|
||||
% ' '.join(list(self._install_manifests.keys())))
|
||||
|
||||
# Add dependencies we infered:
|
||||
for target, deps in self._dependencies.iteritems():
|
||||
for target, deps in self._dependencies.items():
|
||||
mk.create_rule([target]).add_dependencies(
|
||||
'$(TOPOBJDIR)/%s' % d for d in deps)
|
||||
|
||||
mk.add_statement('include $(TOPSRCDIR)/config/faster/rules.mk')
|
||||
|
||||
for base, install_manifest in self._install_manifests.iteritems():
|
||||
for base, install_manifest in self._install_manifests.items():
|
||||
with self._write_file(
|
||||
mozpath.join(self.environment.topobjdir, 'faster',
|
||||
'install_%s' % base.replace('/', '_'))) as fh:
|
||||
|
||||
@@ -596,7 +596,7 @@ class RecursiveMakeBackend(CommonBackend):
|
||||
convenience variables, and the other dependency definitions for a
|
||||
hopefully proper directory traversal.
|
||||
"""
|
||||
for tier, no_skip in self._no_skip.items():
|
||||
for tier, no_skip in list(self._no_skip.items()):
|
||||
self.log(logging.DEBUG, 'fill_root_mk', {
|
||||
'number': len(no_skip), 'tier': tier
|
||||
}, 'Using {number} directories during {tier}')
|
||||
@@ -642,7 +642,7 @@ class RecursiveMakeBackend(CommonBackend):
|
||||
for tier, filter in filters:
|
||||
main, all_deps = \
|
||||
self._traversal.compute_dependencies(filter)
|
||||
for dir, deps in all_deps.items():
|
||||
for dir, deps in list(all_deps.items()):
|
||||
if deps is not None or (dir in self._idl_dirs \
|
||||
and tier == 'export'):
|
||||
rule = root_deps_mk.create_rule(['%s/%s' % (dir, tier)])
|
||||
@@ -655,7 +655,7 @@ class RecursiveMakeBackend(CommonBackend):
|
||||
rule.add_dependencies('%s/%s' % (d, tier) for d in main)
|
||||
|
||||
all_compile_deps = reduce(lambda x,y: x|y,
|
||||
self._compile_graph.values()) if self._compile_graph else set()
|
||||
list(self._compile_graph.values())) if self._compile_graph else set()
|
||||
compile_roots = set(self._compile_graph.keys()) - all_compile_deps
|
||||
|
||||
rule = root_deps_mk.create_rule(['recurse_compile'])
|
||||
@@ -797,7 +797,7 @@ class RecursiveMakeBackend(CommonBackend):
|
||||
self._fill_root_mk()
|
||||
|
||||
# Make the master test manifest files.
|
||||
for flavor, t in self._test_manifests.items():
|
||||
for flavor, t in list(self._test_manifests.items()):
|
||||
install_prefix, manifests = t
|
||||
manifest_stem = mozpath.join(install_prefix, '%s.ini' % flavor)
|
||||
self._write_master_test_manifest(mozpath.join(
|
||||
@@ -903,7 +903,7 @@ class RecursiveMakeBackend(CommonBackend):
|
||||
for p in ('Makefile', 'backend.mk', '.deps/.mkdir.done'):
|
||||
build_files.add_optional_exists(p)
|
||||
|
||||
for idl in manager.idls.values():
|
||||
for idl in list(manager.idls.values()):
|
||||
self._install_manifests['dist_idl'].add_symlink(idl['source'],
|
||||
idl['basename'])
|
||||
self._install_manifests['dist_include'].add_optional_exists('%s.h'
|
||||
@@ -950,7 +950,7 @@ class RecursiveMakeBackend(CommonBackend):
|
||||
|
||||
interfaces_manifests = []
|
||||
dist_dir = mozpath.join(self.environment.topobjdir, 'dist')
|
||||
for manifest, entries in manager.interface_manifests.items():
|
||||
for manifest, entries in list(manager.interface_manifests.items()):
|
||||
interfaces_manifests.append(mozpath.join('$(DEPTH)', manifest))
|
||||
for xpt in sorted(entries):
|
||||
registered_xpt_files.add(mozpath.join(
|
||||
@@ -1010,7 +1010,7 @@ class RecursiveMakeBackend(CommonBackend):
|
||||
# Don't allow files to be defined multiple times unless it is allowed.
|
||||
# We currently allow duplicates for non-test files or test files if
|
||||
# the manifest is listed as a duplicate.
|
||||
for source, (dest, is_test) in obj.installs.items():
|
||||
for source, (dest, is_test) in list(obj.installs.items()):
|
||||
try:
|
||||
self._install_manifests['_test_files'].add_symlink(source, dest)
|
||||
except ValueError:
|
||||
@@ -1291,7 +1291,7 @@ class RecursiveMakeBackend(CommonBackend):
|
||||
man_dir = mozpath.join(self.environment.topobjdir, '_build_manifests',
|
||||
dest)
|
||||
|
||||
for k, manifest in manifests.items():
|
||||
for k, manifest in list(manifests.items()):
|
||||
with self._write_file(mozpath.join(man_dir, k)) as fh:
|
||||
manifest.write(fileobj=fh)
|
||||
|
||||
|
||||
@@ -253,7 +253,7 @@ class TupOnly(CommonBackend, PartialBackend):
|
||||
backend_file = self._get_backend_file('xpcom/xpidl')
|
||||
backend_file.export_shell()
|
||||
|
||||
for module, data in sorted(manager.modules.iteritems()):
|
||||
for module, data in sorted(manager.modules.items()):
|
||||
dest, idls = data
|
||||
cmd = [
|
||||
'$(PYTHON_PATH)',
|
||||
|
||||
@@ -118,7 +118,7 @@ class CompileDBBackend(CommonBackend):
|
||||
|
||||
db = []
|
||||
|
||||
for (directory, filename), cmd in self._db.iteritems():
|
||||
for (directory, filename), cmd in self._db.items():
|
||||
env = self._envs[directory]
|
||||
cmd = list(cmd)
|
||||
cmd.append(filename)
|
||||
|
||||
@@ -123,18 +123,18 @@ class WarningsDatabase(object):
|
||||
|
||||
def __len__(self):
|
||||
i = 0
|
||||
for value in self._files.values():
|
||||
for value in list(self._files.values()):
|
||||
i += len(value['warnings'])
|
||||
|
||||
return i
|
||||
|
||||
def __iter__(self):
|
||||
for value in self._files.values():
|
||||
for value in list(self._files.values()):
|
||||
for warning in value['warnings']:
|
||||
yield warning
|
||||
|
||||
def __contains__(self, item):
|
||||
for value in self._files.values():
|
||||
for value in list(self._files.values()):
|
||||
for warning in value['warnings']:
|
||||
if warning == item:
|
||||
return True
|
||||
@@ -144,7 +144,7 @@ class WarningsDatabase(object):
|
||||
@property
|
||||
def warnings(self):
|
||||
"""All the CompilerWarning instances in this database."""
|
||||
for value in self._files.values():
|
||||
for value in list(self._files.values()):
|
||||
for w in value['warnings']:
|
||||
yield w
|
||||
|
||||
@@ -152,7 +152,7 @@ class WarningsDatabase(object):
|
||||
"""Returns a mapping of warning types to their counts."""
|
||||
|
||||
types = {}
|
||||
for value in self._files.values():
|
||||
for value in list(self._files.values()):
|
||||
for warning in value['warnings']:
|
||||
if dirpath and not mozpath.normsep(warning['filename']).startswith(dirpath):
|
||||
continue
|
||||
@@ -210,7 +210,7 @@ class WarningsDatabase(object):
|
||||
"""
|
||||
|
||||
# Need to calculate up front since we are mutating original object.
|
||||
filenames = self._files.keys()
|
||||
filenames = list(self._files.keys())
|
||||
for filename in filenames:
|
||||
if not os.path.exists(filename):
|
||||
del self._files[filename]
|
||||
@@ -229,10 +229,10 @@ class WarningsDatabase(object):
|
||||
obj = {'files': {}}
|
||||
|
||||
# All this hackery because JSON can't handle sets.
|
||||
for k, v in self._files.iteritems():
|
||||
for k, v in self._files.items():
|
||||
obj['files'][k] = {}
|
||||
|
||||
for k2, v2 in v.iteritems():
|
||||
for k2, v2 in v.items():
|
||||
normalized = v2
|
||||
|
||||
if k2 == 'warnings':
|
||||
@@ -249,8 +249,8 @@ class WarningsDatabase(object):
|
||||
self._files = obj['files']
|
||||
|
||||
# Normalize data types.
|
||||
for filename, value in self._files.iteritems():
|
||||
for k, v in value.iteritems():
|
||||
for filename, value in self._files.items():
|
||||
for k, v in value.items():
|
||||
if k != 'warnings':
|
||||
continue
|
||||
|
||||
|
||||
@@ -334,7 +334,7 @@ class ConfigureSandbox(dict):
|
||||
if path:
|
||||
self.include_file(path)
|
||||
|
||||
for option in self._options.itervalues():
|
||||
for option in self._options.values():
|
||||
# All options must be referenced by some @depends function
|
||||
if option not in self._seen:
|
||||
raise ConfigureError(
|
||||
@@ -542,7 +542,7 @@ class ConfigureSandbox(dict):
|
||||
'''
|
||||
when = self._normalize_when(kwargs.get('when'), 'option')
|
||||
args = [self._resolve(arg) for arg in args]
|
||||
kwargs = {k: self._resolve(v) for k, v in kwargs.iteritems()
|
||||
kwargs = {k: self._resolve(v) for k, v in kwargs.items()
|
||||
if k != 'when'}
|
||||
option = Option(*args, **kwargs)
|
||||
if when:
|
||||
@@ -641,7 +641,7 @@ class ConfigureSandbox(dict):
|
||||
(k[:-len('_impl')], getattr(self, k))
|
||||
for k in dir(self) if k.endswith('_impl') and k != 'template_impl'
|
||||
)
|
||||
glob.update((k, v) for k, v in self.iteritems() if k not in glob)
|
||||
glob.update((k, v) for k, v in self.items() if k not in glob)
|
||||
|
||||
# Any function argument to the template must be prepared to be sandboxed.
|
||||
# If the template itself returns a function (in which case, it's very
|
||||
@@ -665,7 +665,7 @@ class ConfigureSandbox(dict):
|
||||
def wrapper(*args, **kwargs):
|
||||
args = [maybe_prepare_function(arg) for arg in args]
|
||||
kwargs = {k: maybe_prepare_function(v)
|
||||
for k, v in kwargs.iteritems()}
|
||||
for k, v in kwargs.items()}
|
||||
ret = template(*args, **kwargs)
|
||||
if isfunction(ret):
|
||||
# We can't expect the sandboxed code to think about all the
|
||||
@@ -888,7 +888,7 @@ class ConfigureSandbox(dict):
|
||||
return func, func.func_globals
|
||||
|
||||
glob = SandboxedGlobal(
|
||||
(k, v) for k, v in func.func_globals.iteritems()
|
||||
(k, v) for k, v in func.func_globals.items()
|
||||
if (inspect.isfunction(v) and v not in self._templates) or (
|
||||
inspect.isclass(v) and issubclass(v, Exception))
|
||||
)
|
||||
|
||||
@@ -58,7 +58,7 @@ CPU_bitness = {
|
||||
'x86_64': 64,
|
||||
}
|
||||
|
||||
CPU = EnumString.subclass(*CPU_bitness.keys())
|
||||
CPU = EnumString.subclass(*list(CPU_bitness.keys()))
|
||||
|
||||
Endianness = EnumString.subclass(
|
||||
'big',
|
||||
|
||||
@@ -96,7 +96,7 @@ class ConflictingOptionError(InvalidOptionError):
|
||||
if format_data:
|
||||
message = message.format(**format_data)
|
||||
super(ConflictingOptionError, self).__init__(message)
|
||||
for k, v in format_data.iteritems():
|
||||
for k, v in format_data.items():
|
||||
setattr(self, k, v)
|
||||
|
||||
|
||||
@@ -481,5 +481,5 @@ class CommandLineHelper(object):
|
||||
|
||||
def __iter__(self):
|
||||
for d in (self._args, self._extra_args):
|
||||
for arg, pos in d.itervalues():
|
||||
for arg, pos in d.values():
|
||||
yield arg
|
||||
@@ -108,7 +108,7 @@ class TierStatus(object):
|
||||
"""
|
||||
o = []
|
||||
|
||||
for tier, state in self.tiers.items():
|
||||
for tier, state in list(self.tiers.items()):
|
||||
t_entry = dict(
|
||||
name=tier,
|
||||
start=state['begin_time'],
|
||||
@@ -644,7 +644,7 @@ class CCacheStats(object):
|
||||
return '\n'.join(lines)
|
||||
|
||||
def __nonzero__(self):
|
||||
relative_values = [v for k, v in self._values.items()
|
||||
relative_values = [v for k, v in list(self._values.items())
|
||||
if k not in self.ABSOLUTE_KEYS]
|
||||
return (all(v >= 0 for v in relative_values) and
|
||||
any(v > 0 for v in relative_values))
|
||||
|
||||
@@ -52,7 +52,7 @@ class DotProperties:
|
||||
if not prefix.endswith('.'):
|
||||
prefix = prefix + '.'
|
||||
indexes = []
|
||||
for k, v in self._properties.iteritems():
|
||||
for k, v in self._properties.items():
|
||||
if not k.startswith(prefix):
|
||||
continue
|
||||
key = k[len(prefix):]
|
||||
@@ -73,7 +73,7 @@ class DotProperties:
|
||||
if not prefix.endswith('.'):
|
||||
prefix = prefix + '.'
|
||||
|
||||
D = dict((k[len(prefix):], v) for k, v in self._properties.iteritems()
|
||||
D = dict((k[len(prefix):], v) for k, v in self._properties.items()
|
||||
if k.startswith(prefix) and '.' not in k[len(prefix):])
|
||||
|
||||
for required_key in required_keys:
|
||||
|
||||
@@ -234,15 +234,15 @@ class Context(KeyedDefaultDict):
|
||||
This function is transactional: if setitem fails for one of the values,
|
||||
the context is not updated at all."""
|
||||
if isinstance(iterable, dict):
|
||||
iterable = iterable.items()
|
||||
iterable = list(iterable.items())
|
||||
|
||||
update = {}
|
||||
for key, value in itertools.chain(iterable, kwargs.items()):
|
||||
for key, value in itertools.chain(iterable, list(kwargs.items())):
|
||||
stored_type = self._validate(key, value)
|
||||
# Don't create an instance of stored_type if coercion is needed,
|
||||
# until all values are validated.
|
||||
update[key] = (value, stored_type)
|
||||
for key, (value, stored_type) in update.items():
|
||||
for key, (value, stored_type) in list(update.items()):
|
||||
if not isinstance(value, stored_type):
|
||||
update[key] = stored_type(value)
|
||||
else:
|
||||
@@ -544,7 +544,7 @@ def ContextDerivedTypedRecord(*fields):
|
||||
__slots__ = tuple([name for name, _ in fields])
|
||||
|
||||
def __init__(self, context):
|
||||
for fname, ftype in self._fields.items():
|
||||
for fname, ftype in list(self._fields.items()):
|
||||
if issubclass(ftype, ContextDerivedValue):
|
||||
setattr(self, fname, self._fields[fname](context))
|
||||
else:
|
||||
@@ -764,7 +764,7 @@ class Files(SubContext):
|
||||
self.test_tags |= other.test_tags
|
||||
self.test_flavors |= other.test_flavors
|
||||
|
||||
for k, v in other.items():
|
||||
for k, v in list(other.items()):
|
||||
if k == 'IMPACTED_TESTS':
|
||||
self.test_files |= set(mozpath.relpath(e.full_path, e.context.config.topsrcdir)
|
||||
for e in v.files)
|
||||
@@ -818,7 +818,7 @@ class Files(SubContext):
|
||||
|
||||
bug_components = Counter()
|
||||
|
||||
for f in files.values():
|
||||
for f in list(files.values()):
|
||||
bug_component = f.get('BUG_COMPONENT')
|
||||
if bug_component:
|
||||
bug_components[bug_component] += 1
|
||||
@@ -1758,7 +1758,7 @@ VARIABLES = {
|
||||
}
|
||||
|
||||
# Sanity check: we don't want any variable above to have a list as storage type.
|
||||
for name, (storage_type, input_types, docs) in VARIABLES.items():
|
||||
for name, (storage_type, input_types, docs) in list(VARIABLES.items()):
|
||||
if storage_type == list:
|
||||
raise RuntimeError('%s has a "list" storage type. Use "List" instead.'
|
||||
% name)
|
||||
|
||||
@@ -186,7 +186,7 @@ class BaseDefines(ContextDerived):
|
||||
self.defines = defines
|
||||
|
||||
def get_defines(self):
|
||||
for define, value in self.defines.iteritems():
|
||||
for define, value in self.defines.items():
|
||||
if value is True:
|
||||
yield('-D%s' % define)
|
||||
elif value is False:
|
||||
|
||||
@@ -116,7 +116,7 @@ class TreeMetadataEmitter(LoggingMixin):
|
||||
# arguments. This gross hack works around the problem until we
|
||||
# rid ourselves of 2.6.
|
||||
self.info = {}
|
||||
for k, v in mozinfo.info.items():
|
||||
for k, v in list(mozinfo.info.items()):
|
||||
if isinstance(k, unicode):
|
||||
k = k.encode('ascii')
|
||||
self.info[k] = v
|
||||
@@ -190,7 +190,7 @@ class TreeMetadataEmitter(LoggingMixin):
|
||||
|
||||
def _emit_libs_derived(self, contexts):
|
||||
# First do FINAL_LIBRARY linkage.
|
||||
for lib in (l for libs in self._libs.values() for l in libs):
|
||||
for lib in (l for libs in list(self._libs.values()) for l in libs):
|
||||
if not isinstance(lib, StaticLibrary) or not lib.link_into:
|
||||
continue
|
||||
if lib.link_into not in self._libs:
|
||||
@@ -250,12 +250,12 @@ class TreeMetadataEmitter(LoggingMixin):
|
||||
lib.link_into == outerlib.basename):
|
||||
propagate_defines(lib, defines)
|
||||
|
||||
for lib in (l for libs in self._libs.values() for l in libs):
|
||||
for lib in (l for libs in list(self._libs.values()) for l in libs):
|
||||
if isinstance(lib, Library):
|
||||
propagate_defines(lib, lib.lib_defines)
|
||||
yield lib
|
||||
|
||||
for obj in self._binaries.values():
|
||||
for obj in list(self._binaries.values()):
|
||||
yield obj
|
||||
|
||||
LIBRARY_NAME_VAR = {
|
||||
@@ -314,7 +314,7 @@ class TreeMetadataEmitter(LoggingMixin):
|
||||
libs[key] = l
|
||||
if key not in libs:
|
||||
libs[key] = l
|
||||
candidates = libs.values()
|
||||
candidates = list(libs.values())
|
||||
if force_static and not candidates:
|
||||
if dir:
|
||||
raise SandboxValidationError(
|
||||
@@ -376,7 +376,7 @@ class TreeMetadataEmitter(LoggingMixin):
|
||||
|
||||
def _verify_deps(self, context, crate_dir, crate_name, dependencies, description='Dependency'):
|
||||
"""Verify that a crate's dependencies all specify local paths."""
|
||||
for dep_crate_name, values in dependencies.iteritems():
|
||||
for dep_crate_name, values in dependencies.items():
|
||||
# A simple version number.
|
||||
if isinstance(values, (str, unicode)):
|
||||
raise SandboxValidationError(
|
||||
@@ -667,7 +667,7 @@ class TreeMetadataEmitter(LoggingMixin):
|
||||
assert not gen_sources['UNIFIED_SOURCES']
|
||||
|
||||
no_pgo = context.get('NO_PGO')
|
||||
no_pgo_sources = [f for f, flags in all_flags.iteritems()
|
||||
no_pgo_sources = [f for f, flags in all_flags.items()
|
||||
if flags.no_pgo]
|
||||
if no_pgo:
|
||||
if no_pgo_sources:
|
||||
@@ -694,7 +694,7 @@ class TreeMetadataEmitter(LoggingMixin):
|
||||
|
||||
# The inverse of the above, mapping suffixes to their canonical suffix.
|
||||
canonicalized_suffix_map = {}
|
||||
for suffix, alternatives in suffix_map.iteritems():
|
||||
for suffix, alternatives in suffix_map.items():
|
||||
alternatives.add(suffix)
|
||||
for a in alternatives:
|
||||
canonicalized_suffix_map[a] = suffix
|
||||
@@ -715,7 +715,7 @@ class TreeMetadataEmitter(LoggingMixin):
|
||||
# a directory with mixed C and C++ source, but it's not that important.
|
||||
cxx_sources = defaultdict(bool)
|
||||
|
||||
for variable, (klass, gen_klass, suffixes) in varmap.items():
|
||||
for variable, (klass, gen_klass, suffixes) in list(varmap.items()):
|
||||
allowed_suffixes = set().union(*[suffix_map[s] for s in suffixes])
|
||||
|
||||
# First ensure that we haven't been given filetypes that we don't
|
||||
@@ -741,7 +741,7 @@ class TreeMetadataEmitter(LoggingMixin):
|
||||
obj = cls(*arglist)
|
||||
yield obj
|
||||
|
||||
for f, flags in all_flags.iteritems():
|
||||
for f, flags in all_flags.items():
|
||||
if flags.flags:
|
||||
ext = mozpath.splitext(f)[1]
|
||||
yield PerSourceFlag(context, f, flags.flags)
|
||||
@@ -885,7 +885,7 @@ class TreeMetadataEmitter(LoggingMixin):
|
||||
for obj in self._handle_linkables(context, passthru, generated_files):
|
||||
yield obj
|
||||
|
||||
generated_files.update(['%s%s' % (k, self.config.substs.get('BIN_SUFFIX', '')) for k in self._binaries.keys()])
|
||||
generated_files.update(['%s%s' % (k, self.config.substs.get('BIN_SUFFIX', '')) for k in list(self._binaries.keys())])
|
||||
|
||||
components = []
|
||||
for var, cls in (
|
||||
@@ -982,7 +982,7 @@ class TreeMetadataEmitter(LoggingMixin):
|
||||
for obj in self._process_jar_manifests(context):
|
||||
yield obj
|
||||
|
||||
for name, jar in context.get('JAVA_JAR_TARGETS', {}).items():
|
||||
for name, jar in list(context.get('JAVA_JAR_TARGETS', {}).items()):
|
||||
yield ContextWrapped(context, jar)
|
||||
|
||||
if context.get('USE_YASM') is True:
|
||||
@@ -1076,7 +1076,7 @@ class TreeMetadataEmitter(LoggingMixin):
|
||||
yield GeneratedFile(context, script, method, outputs, inputs)
|
||||
|
||||
def _process_test_manifests(self, context):
|
||||
for prefix, info in TEST_MANIFESTS.items():
|
||||
for prefix, info in list(TEST_MANIFESTS.items()):
|
||||
for path, manifest in context.get('%s_MANIFESTS' % prefix, []):
|
||||
for obj in self._process_test_manifest(context, info, path, manifest):
|
||||
yield obj
|
||||
@@ -1167,7 +1167,7 @@ class TreeMetadataEmitter(LoggingMixin):
|
||||
|
||||
process_support_files(test)
|
||||
|
||||
for path, m_defaults in mpmanifest.manifest_defaults.items():
|
||||
for path, m_defaults in list(mpmanifest.manifest_defaults.items()):
|
||||
process_support_files(m_defaults)
|
||||
|
||||
# We also copy manifests into the output directory,
|
||||
|
||||
@@ -122,7 +122,7 @@ def read_from_gyp(config, path, output, vars, no_chromium, no_unified, action_ov
|
||||
# gyp expects plain str instead of unicode. The frontend code gives us
|
||||
# unicode strings, so convert them.
|
||||
path = encode(path)
|
||||
str_vars = dict((name, encode(value)) for name, value in vars.items())
|
||||
str_vars = dict((name, encode(value)) for name, value in list(vars.items()))
|
||||
if is_msvc:
|
||||
# This isn't actually used anywhere in this generator, but it's needed
|
||||
# to override the registry detection of VC++ in gyp.
|
||||
|
||||
@@ -105,13 +105,13 @@ class MozbuildFileCommands(MachCommandBase):
|
||||
"""
|
||||
components = defaultdict(set)
|
||||
try:
|
||||
for p, m in self._get_files_info(paths, rev=rev).items():
|
||||
for p, m in list(self._get_files_info(paths, rev=rev).items()):
|
||||
components[m.get('BUG_COMPONENT')].add(p)
|
||||
except InvalidPathException as e:
|
||||
print(e.message)
|
||||
return 1
|
||||
|
||||
for component, files in sorted(components.items(), key=lambda x: (x is None, x)):
|
||||
for component, files in sorted(list(components.items()), key=lambda x: (x is None, x)):
|
||||
print('%s :: %s' % (component.product, component.component) if component else 'UNKNOWN')
|
||||
for f in sorted(files):
|
||||
print(' %s' % f)
|
||||
@@ -139,7 +139,7 @@ class MozbuildFileCommands(MachCommandBase):
|
||||
help='Paths whose data to query')
|
||||
def file_info_test_deps(self, paths, rev=None):
|
||||
try:
|
||||
for p, m in self._get_files_info(paths, rev=rev).items():
|
||||
for p, m in list(self._get_files_info(paths, rev=rev).items()):
|
||||
print('%s:' % mozpath.relpath(p, self.topsrcdir))
|
||||
if m.test_files:
|
||||
print('\tTest file patterns:')
|
||||
|
||||
@@ -125,7 +125,7 @@ class EmptyConfig(object):
|
||||
b'JS_STANDALONE': b'1',
|
||||
})
|
||||
udict = {}
|
||||
for k, v in self.substs.items():
|
||||
for k, v in list(self.substs.items()):
|
||||
if isinstance(v, str):
|
||||
udict[k.decode('utf-8')] = v.decode('utf-8')
|
||||
else:
|
||||
@@ -388,7 +388,7 @@ class MozbuildSandbox(Sandbox):
|
||||
klass = self._context.__class__
|
||||
self._context.__class__ = TemplateContext
|
||||
# The sandbox will do all the necessary checks for these merges.
|
||||
for key, value in context.items():
|
||||
for key, value in list(context.items()):
|
||||
if isinstance(value, dict):
|
||||
self[key].update(value)
|
||||
elif isinstance(value, (list, HierarchicalStringList)):
|
||||
@@ -765,7 +765,7 @@ class BuildReaderError(Exception):
|
||||
s.write(' %s\n' % inner.args[2])
|
||||
s.write('\n')
|
||||
close_matches = difflib.get_close_matches(inner.args[2],
|
||||
VARIABLES.keys(), 2)
|
||||
list(VARIABLES.keys()), 2)
|
||||
if close_matches:
|
||||
s.write('Maybe you meant %s?\n' % ' or '.join(close_matches))
|
||||
s.write('\n')
|
||||
@@ -1129,7 +1129,7 @@ class BuildReader(object):
|
||||
context)
|
||||
non_unified_sources.add(source)
|
||||
action_overrides = {}
|
||||
for action, script in gyp_dir.action_overrides.iteritems():
|
||||
for action, script in gyp_dir.action_overrides.items():
|
||||
action_overrides[action] = SourcePath(context, script)
|
||||
time_start = time.time()
|
||||
for gyp_context in read_from_gyp(context.config,
|
||||
@@ -1173,7 +1173,7 @@ class BuildReader(object):
|
||||
|
||||
recurse_info[d][key] = dict(sandbox.metadata[key])
|
||||
|
||||
for path, child_metadata in recurse_info.items():
|
||||
for path, child_metadata in list(recurse_info.items()):
|
||||
child_path = path.join('moz.build').full_path
|
||||
|
||||
# Ensure we don't break out of the topsrcdir. We don't do realpath
|
||||
@@ -1265,7 +1265,7 @@ class BuildReader(object):
|
||||
# There is room to improve this code (and the code in
|
||||
# _find_relevant_mozbuilds) to better handle multiple files in the same
|
||||
# directory. Bug 1136966 tracks.
|
||||
for path, mbpaths in relevants.items():
|
||||
for path, mbpaths in list(relevants.items()):
|
||||
path_mozbuilds[path] = [mozpath.join(topsrcdir, p) for p in mbpaths]
|
||||
|
||||
for i, mbpath in enumerate(mbpaths[0:-1]):
|
||||
@@ -1302,7 +1302,7 @@ class BuildReader(object):
|
||||
all_contexts.append(context)
|
||||
|
||||
result = {}
|
||||
for path, paths in path_mozbuilds.items():
|
||||
for path, paths in list(path_mozbuilds.items()):
|
||||
result[path] = reduce(lambda x, y: x + y, (contexts[p] for p in paths), [])
|
||||
|
||||
return result, all_contexts
|
||||
@@ -1329,7 +1329,7 @@ class BuildReader(object):
|
||||
|
||||
r = {}
|
||||
|
||||
for path, ctxs in paths.items():
|
||||
for path, ctxs in list(paths.items()):
|
||||
flags = Files(Context())
|
||||
|
||||
for ctx in ctxs:
|
||||
|
||||
@@ -116,9 +116,9 @@ class Sandbox(dict):
|
||||
"""Initialize a Sandbox ready for execution.
|
||||
"""
|
||||
self._builtins = ReadOnlyDict(
|
||||
(builtins or self.BUILTINS).viewitems() |
|
||||
(builtins or self.BUILTINS).items() |
|
||||
{b: __builtins__[b] for b in ('__build_class__',)
|
||||
if b in __builtins__}.viewitems())
|
||||
if b in __builtins__}.items())
|
||||
dict.__setitem__(self, '__builtins__', self._builtins)
|
||||
|
||||
assert isinstance(self._builtins, ReadOnlyDict)
|
||||
|
||||
@@ -304,7 +304,7 @@ class JarMaker(object):
|
||||
'''
|
||||
myregister = dict.fromkeys([s.replace('%',
|
||||
chromebasepath) for s in register])
|
||||
addEntriesToListFile(manifestPath, myregister.iterkeys())
|
||||
addEntriesToListFile(manifestPath, iter(myregister.keys()))
|
||||
|
||||
def makeJar(self, infile, jardir):
|
||||
'''makeJar is the main entry point to JarMaker.
|
||||
|
||||
@@ -136,7 +136,7 @@ class BuildProgressFooter(object):
|
||||
# terminal is a blessings.Terminal.
|
||||
self._t = terminal
|
||||
self._fh = sys.stdout
|
||||
self.tiers = monitor.tiers.tier_status.viewitems()
|
||||
self.tiers = monitor.tiers.tier_status.items()
|
||||
|
||||
def clear(self):
|
||||
"""Removes the footer from the current terminal."""
|
||||
@@ -835,7 +835,7 @@ class Warnings(MachCommandBase):
|
||||
dirpath = None
|
||||
|
||||
type_counts = database.type_counts(dirpath)
|
||||
sorted_counts = sorted(type_counts.iteritems(),
|
||||
sorted_counts = sorted(iter(type_counts.items()),
|
||||
key=operator.itemgetter(1))
|
||||
|
||||
total = 0
|
||||
@@ -992,7 +992,7 @@ class GTestCommands(MachCommandBase):
|
||||
processes[i].run()
|
||||
|
||||
exit_code = 0
|
||||
for process in processes.values():
|
||||
for process in list(processes.values()):
|
||||
status = process.wait()
|
||||
if status:
|
||||
exit_code = status
|
||||
|
||||
@@ -311,7 +311,7 @@ class MozconfigLoader(object):
|
||||
|
||||
# Environment variables also appear as shell variables, but that's
|
||||
# uninteresting duplication of information. Filter them out.
|
||||
filt = lambda x, y: {k: v for k, v in x.items() if k not in y}
|
||||
filt = lambda x, y: {k: v for k, v in list(x.items()) if k not in y}
|
||||
result['vars'] = diff_vars(
|
||||
filt(parsed['vars_before'], parsed['env_before']),
|
||||
filt(parsed['vars_after'], parsed['env_after'])
|
||||
|
||||
@@ -278,7 +278,7 @@ class Preprocessor:
|
||||
self.context = Context()
|
||||
for k,v in {'FILE': '',
|
||||
'LINE': 0,
|
||||
'DIRECTORY': os.path.abspath('.')}.iteritems():
|
||||
'DIRECTORY': os.path.abspath('.')}.items():
|
||||
self.context[k] = v
|
||||
self.actionLevel = 0
|
||||
self.disableLevel = 0
|
||||
@@ -306,7 +306,7 @@ class Preprocessor:
|
||||
'unfilter': 0,
|
||||
'include': 0,
|
||||
'includesubst': 0,
|
||||
'error': 0}.iteritems():
|
||||
'error': 0}.items():
|
||||
self.cmds[cmd] = (level, getattr(self, 'do_' + cmd))
|
||||
self.out = sys.stdout
|
||||
self.setMarker(marker)
|
||||
@@ -677,7 +677,7 @@ class Preprocessor:
|
||||
current = dict(self.filters)
|
||||
for f in filters:
|
||||
current[f] = getattr(self, 'filter_' + f)
|
||||
filterNames = current.keys()
|
||||
filterNames = list(current.keys())
|
||||
filterNames.sort()
|
||||
self.filters = [(fn, current[fn]) for fn in filterNames]
|
||||
return
|
||||
@@ -687,7 +687,7 @@ class Preprocessor:
|
||||
for f in filters:
|
||||
if f in current:
|
||||
del current[f]
|
||||
filterNames = current.keys()
|
||||
filterNames = list(current.keys())
|
||||
filterNames.sort()
|
||||
self.filters = [(fn, current[fn]) for fn in filterNames]
|
||||
return
|
||||
|
||||
@@ -11,7 +11,7 @@ import sys
|
||||
def iter_modules_in_path(*paths):
|
||||
paths = [os.path.abspath(os.path.normcase(p)) + os.sep
|
||||
for p in paths]
|
||||
for name, module in sys.modules.items():
|
||||
for name, module in list(sys.modules.items()):
|
||||
if not hasattr(module, '__file__'):
|
||||
continue
|
||||
|
||||
|
||||
@@ -15,7 +15,7 @@ def _tokens2re(**tokens):
|
||||
# which matches the pattern and captures it in a named match group.
|
||||
# The group names and patterns are given as arguments.
|
||||
all_tokens = '|'.join('(?P<%s>%s)' % (name, value)
|
||||
for name, value in tokens.iteritems())
|
||||
for name, value in tokens.items())
|
||||
nonescaped = r'(?<!\\)(?:%s)' % all_tokens
|
||||
|
||||
# The final pattern matches either the above pattern, or an escaped
|
||||
@@ -96,7 +96,7 @@ class _ClineSplitter(object):
|
||||
self.cline = self.cline[m.end():]
|
||||
|
||||
match = {name: value
|
||||
for name, value in m.groupdict().items() if value}
|
||||
for name, value in list(m.groupdict().items()) if value}
|
||||
if 'quote' in match:
|
||||
# " or ' start a quoted string
|
||||
if match['quote'] == '"':
|
||||
@@ -144,7 +144,7 @@ class _ClineSplitter(object):
|
||||
self._push(self.cline[:m.start()])
|
||||
self.cline = self.cline[m.end():]
|
||||
match = {name: value
|
||||
for name, value in m.groupdict().items() if value}
|
||||
for name, value in list(m.groupdict().items()) if value}
|
||||
if 'quote' in match:
|
||||
# a double quote ends the quoted string, so go back to
|
||||
# unquoted parsing
|
||||
|
||||
@@ -57,8 +57,8 @@ class TestPackageFennecAPK(unittest.TestCase):
|
||||
# overrides the first.
|
||||
jarrer = package(inputs=[data('input2.apk'), data('input1.ap_')])
|
||||
|
||||
files1 = JarReader(data('input1.ap_')).entries.keys()
|
||||
files2 = JarReader(data('input2.apk')).entries.keys()
|
||||
files1 = list(JarReader(data('input1.ap_')).entries.keys())
|
||||
files2 = list(JarReader(data('input2.apk')).entries.keys())
|
||||
for name in files2:
|
||||
self.assertTrue(name in files1 or
|
||||
jarrer[name].open().read().startswith('input2/'))
|
||||
|
||||
@@ -331,7 +331,7 @@ class TestRecursiveMakeBackend(BackendTester):
|
||||
],
|
||||
}
|
||||
|
||||
for var, val in expected.items():
|
||||
for var, val in list(expected.items()):
|
||||
# print("test_variable_passthru[%s]" % (var))
|
||||
found = [str for str in lines if str.startswith(var)]
|
||||
self.assertEqual(found, val)
|
||||
@@ -370,7 +370,7 @@ class TestRecursiveMakeBackend(BackendTester):
|
||||
],
|
||||
}
|
||||
|
||||
for var, val in expected.items():
|
||||
for var, val in list(expected.items()):
|
||||
found = [str for str in lines if str.startswith(var)]
|
||||
self.assertEqual(found, val)
|
||||
|
||||
@@ -544,7 +544,7 @@ class TestRecursiveMakeBackend(BackendTester):
|
||||
|
||||
# This is not the most robust test in the world, but it gets the job
|
||||
# done.
|
||||
entries = [e for e in m._dests.keys() if '**' in e]
|
||||
entries = [e for e in list(m._dests.keys()) if '**' in e]
|
||||
self.assertEqual(len(entries), 1)
|
||||
self.assertIn('support/**', entries[0])
|
||||
|
||||
@@ -562,7 +562,7 @@ class TestRecursiveMakeBackend(BackendTester):
|
||||
set(['child/test_sub.js',
|
||||
'child/data/**',
|
||||
'child/another-file.sjs']))
|
||||
for key in test_installs.keys():
|
||||
for key in list(test_installs.keys()):
|
||||
self.assertIn(key, test_installs)
|
||||
|
||||
test_files_manifest = mozpath.join(env.topobjdir,
|
||||
@@ -576,7 +576,7 @@ class TestRecursiveMakeBackend(BackendTester):
|
||||
# Then, synthesize one from the test-installs.pkl file. This should
|
||||
# allow us to re-create a subset of the above.
|
||||
synthesized_manifest = InstallManifest()
|
||||
for item, installs in test_installs.items():
|
||||
for item, installs in list(test_installs.items()):
|
||||
for install_info in installs:
|
||||
if len(install_info) == 3:
|
||||
synthesized_manifest.add_pattern_symlink(*install_info)
|
||||
@@ -584,7 +584,7 @@ class TestRecursiveMakeBackend(BackendTester):
|
||||
synthesized_manifest.add_symlink(*install_info)
|
||||
|
||||
self.assertEqual(len(synthesized_manifest), 3)
|
||||
for item, info in synthesized_manifest._dests.items():
|
||||
for item, info in list(synthesized_manifest._dests.items()):
|
||||
self.assertIn(item, m)
|
||||
self.assertEqual(info, m._dests[item])
|
||||
|
||||
@@ -758,7 +758,7 @@ class TestRecursiveMakeBackend(BackendTester):
|
||||
expected[mozpath.join(env.topobjdir, 'final-target')] = [
|
||||
'FINAL_TARGET = $(DEPTH)/random-final-target'
|
||||
]
|
||||
for key, expected_rules in expected.iteritems():
|
||||
for key, expected_rules in expected.items():
|
||||
backend_path = mozpath.join(key, 'backend.mk')
|
||||
lines = [l.strip() for l in open(backend_path, 'rt').readlines()[2:]]
|
||||
found = [str for str in lines if
|
||||
|
||||
@@ -36,7 +36,7 @@ class MockConfig(object):
|
||||
}, **extra_substs)
|
||||
|
||||
self.substs_unicode = ReadOnlyDict({k.decode('utf-8'): v.decode('utf-8',
|
||||
'replace') for k, v in self.substs.items()})
|
||||
'replace') for k, v in list(self.substs.items())})
|
||||
|
||||
self.defines = self.substs
|
||||
|
||||
|
||||
@@ -78,10 +78,10 @@ class ConfigureTestSandbox(ConfigureSandbox):
|
||||
self._search_path = environ.get('PATH', '').split(os.pathsep)
|
||||
|
||||
self._subprocess_paths = {
|
||||
mozpath.abspath(k): v for k, v in paths.iteritems() if v
|
||||
mozpath.abspath(k): v for k, v in paths.items() if v
|
||||
}
|
||||
|
||||
paths = paths.keys()
|
||||
paths = list(paths.keys())
|
||||
|
||||
environ = dict(environ)
|
||||
if 'CONFIG_SHELL' not in environ:
|
||||
|
||||
@@ -336,7 +336,7 @@ class TestConfigure(unittest.TestCase):
|
||||
self.assertIs(sandbox['foo'](), sandbox)
|
||||
|
||||
# Nothing leaked from the function being executed
|
||||
self.assertEquals(sandbox.keys(), ['__builtins__', 'foo'])
|
||||
self.assertEquals(list(sandbox.keys()), ['__builtins__', 'foo'])
|
||||
self.assertEquals(sandbox['__builtins__'], ConfigureSandbox.BUILTINS)
|
||||
|
||||
exec_(textwrap.dedent('''
|
||||
|
||||
@@ -471,7 +471,7 @@ class LinuxToolchainTest(BaseToolchainTest):
|
||||
# We'll try gcc and clang, but since there is no gcc (gcc-x.y doesn't
|
||||
# count), find clang.
|
||||
paths = {
|
||||
k: v for k, v in self.PATHS.iteritems()
|
||||
k: v for k, v in self.PATHS.items()
|
||||
if os.path.basename(k) not in ('gcc', 'g++')
|
||||
}
|
||||
self.do_toolchain_test(paths, {
|
||||
@@ -506,7 +506,7 @@ class LinuxToolchainTest(BaseToolchainTest):
|
||||
# Even if there are gcc-x.y or clang-x.y compilers available, we
|
||||
# don't try them. This could be considered something to improve.
|
||||
paths = {
|
||||
k: v for k, v in self.PATHS.iteritems()
|
||||
k: v for k, v in self.PATHS.items()
|
||||
if os.path.basename(k) not in ('gcc', 'g++', 'clang', 'clang++')
|
||||
}
|
||||
self.do_toolchain_test(paths, {
|
||||
@@ -687,7 +687,7 @@ class OSXToolchainTest(BaseToolchainTest):
|
||||
def test_not_gcc(self):
|
||||
# We won't pick GCC if it's the only thing available.
|
||||
paths = {
|
||||
k: v for k, v in self.PATHS.iteritems()
|
||||
k: v for k, v in self.PATHS.items()
|
||||
if os.path.basename(k) not in ('clang', 'clang++')
|
||||
}
|
||||
self.do_toolchain_test(paths, {
|
||||
@@ -851,7 +851,7 @@ class WindowsToolchainTest(BaseToolchainTest):
|
||||
def test_clang_cl(self):
|
||||
# We'll pick clang-cl if msvc can't be found.
|
||||
paths = {
|
||||
k: v for k, v in self.PATHS.iteritems()
|
||||
k: v for k, v in self.PATHS.items()
|
||||
if os.path.basename(k) != 'cl'
|
||||
}
|
||||
self.do_toolchain_test(paths, {
|
||||
@@ -862,7 +862,7 @@ class WindowsToolchainTest(BaseToolchainTest):
|
||||
def test_gcc(self):
|
||||
# We'll pick GCC if msvc and clang-cl can't be found.
|
||||
paths = {
|
||||
k: v for k, v in self.PATHS.iteritems()
|
||||
k: v for k, v in self.PATHS.items()
|
||||
if os.path.basename(k) not in ('cl', 'clang-cl')
|
||||
}
|
||||
self.do_toolchain_test(paths, {
|
||||
@@ -881,7 +881,7 @@ class WindowsToolchainTest(BaseToolchainTest):
|
||||
def test_clang(self):
|
||||
# We'll pick clang if nothing else is found.
|
||||
paths = {
|
||||
k: v for k, v in self.PATHS.iteritems()
|
||||
k: v for k, v in self.PATHS.items()
|
||||
if os.path.basename(k) not in ('cl', 'clang-cl', 'gcc')
|
||||
}
|
||||
self.do_toolchain_test(paths, {
|
||||
|
||||
@@ -53,7 +53,7 @@ class CompilerPreprocessor(Preprocessor):
|
||||
return self.HAS_FEATURE.sub(r'\1\2', expr)
|
||||
self.context = self.Context(
|
||||
(normalize_has_feature(k), normalize_numbers(v))
|
||||
for k, v in context.iteritems()
|
||||
for k, v in context.items()
|
||||
)
|
||||
try:
|
||||
return Preprocessor.do_if(self, normalize_has_feature(expression),
|
||||
@@ -164,9 +164,9 @@ class FakeCompiler(dict):
|
||||
'''
|
||||
def __init__(self, *definitions):
|
||||
for definition in definitions:
|
||||
if all(not isinstance(d, dict) for d in definition.itervalues()):
|
||||
if all(not isinstance(d, dict) for d in definition.values()):
|
||||
definition = {None: definition}
|
||||
for key, value in definition.iteritems():
|
||||
for key, value in definition.items():
|
||||
self.setdefault(key, {}).update(value)
|
||||
|
||||
def __call__(self, stdin, args):
|
||||
@@ -178,14 +178,14 @@ class FakeCompiler(dict):
|
||||
pp = CompilerPreprocessor(self[None])
|
||||
|
||||
def apply_defn(defn):
|
||||
for k, v in defn.iteritems():
|
||||
for k, v in defn.items():
|
||||
if v is False:
|
||||
if k in pp.context:
|
||||
del pp.context[k]
|
||||
else:
|
||||
pp.context[k] = v
|
||||
|
||||
for glob, defn in self.iteritems():
|
||||
for glob, defn in self.items():
|
||||
if glob and not glob.startswith('-') and fnmatch(file, glob):
|
||||
apply_defn(defn)
|
||||
|
||||
@@ -370,7 +370,7 @@ class CompilerResult(ReadOnlyNamespace):
|
||||
def __add__(self, other):
|
||||
assert isinstance(other, dict)
|
||||
result = copy.deepcopy(self.__dict__)
|
||||
for k, v in other.iteritems():
|
||||
for k, v in other.items():
|
||||
if k == 'flags':
|
||||
result.setdefault(k, []).extend(v)
|
||||
else:
|
||||
|
||||
@@ -36,7 +36,7 @@ class TestContext(unittest.TestCase):
|
||||
'baz': (dict, dict, ''),
|
||||
})
|
||||
|
||||
self.assertEqual(test.keys(), [])
|
||||
self.assertEqual(list(test.keys()), [])
|
||||
|
||||
self.assertEqual(test['foo'], 0)
|
||||
|
||||
@@ -84,12 +84,12 @@ class TestContext(unittest.TestCase):
|
||||
'baz': (dict, list, ''),
|
||||
})
|
||||
|
||||
self.assertEqual(test.keys(), [])
|
||||
self.assertEqual(list(test.keys()), [])
|
||||
|
||||
with self.assertRaises(ValueError):
|
||||
test.update(bar=True, foo={})
|
||||
|
||||
self.assertEqual(test.keys(), [])
|
||||
self.assertEqual(list(test.keys()), [])
|
||||
|
||||
test.update(bar=True, foo=1)
|
||||
|
||||
@@ -258,19 +258,19 @@ class TestSymbols(unittest.TestCase):
|
||||
self.assertEqual(lines[-1].strip(), '')
|
||||
|
||||
def test_documentation_formatting(self):
|
||||
for typ, inp, doc in VARIABLES.values():
|
||||
for typ, inp, doc in list(VARIABLES.values()):
|
||||
self._verify_doc(doc)
|
||||
|
||||
for attr, args, doc in FUNCTIONS.values():
|
||||
for attr, args, doc in list(FUNCTIONS.values()):
|
||||
self._verify_doc(doc)
|
||||
|
||||
for func, typ, doc in SPECIAL_VARIABLES.values():
|
||||
for func, typ, doc in list(SPECIAL_VARIABLES.values()):
|
||||
self._verify_doc(doc)
|
||||
|
||||
for name, cls in SUBCONTEXTS.items():
|
||||
for name, cls in list(SUBCONTEXTS.items()):
|
||||
self._verify_doc(cls.__doc__)
|
||||
|
||||
for name, v in cls.VARIABLES.items():
|
||||
for name, v in list(cls.VARIABLES.items()):
|
||||
self._verify_doc(v[2])
|
||||
|
||||
|
||||
|
||||
@@ -454,7 +454,7 @@ class TestEmitterBasic(unittest.TestCase):
|
||||
mozpath.join(o.install_prefix, "absolute-support.ini"),
|
||||
mozpath.join(o.install_prefix, "test_file.js"),
|
||||
]
|
||||
paths = sorted([v[0] for v in o.installs.values()])
|
||||
paths = sorted([v[0] for v in list(o.installs.values())])
|
||||
self.assertEqual(paths, expected)
|
||||
|
||||
@unittest.skip('Bug 1304316 - Items in the second set but not the first')
|
||||
@@ -500,7 +500,7 @@ class TestEmitterBasic(unittest.TestCase):
|
||||
mozpath.normpath(mozpath.join(o.install_prefix, "subdir/support.txt")),
|
||||
mozpath.normpath(mozpath.join(o.install_prefix, "subdir/test_foo.html")),
|
||||
]
|
||||
paths = sorted([v[0] for v in o.installs.values()])
|
||||
paths = sorted([v[0] for v in list(o.installs.values())])
|
||||
self.assertEqual(paths, expected)
|
||||
|
||||
def test_test_manifest_install_includes(self):
|
||||
@@ -518,7 +518,7 @@ class TestEmitterBasic(unittest.TestCase):
|
||||
mozpath.normpath(mozpath.join(o.install_prefix, "subdir/mochitest.ini")),
|
||||
mozpath.normpath(mozpath.join(o.install_prefix, "subdir/test_foo.html")),
|
||||
]
|
||||
paths = sorted([v[0] for v in o.installs.values()])
|
||||
paths = sorted([v[0] for v in list(o.installs.values())])
|
||||
self.assertEqual(paths, expected)
|
||||
|
||||
def test_test_manifest_includes(self):
|
||||
@@ -635,7 +635,7 @@ class TestEmitterBasic(unittest.TestCase):
|
||||
self.assertEqual(external_normalized, m.get('external', set()))
|
||||
|
||||
self.assertEqual(len(o.installs), len(m['installs']))
|
||||
for path in o.installs.keys():
|
||||
for path in list(o.installs.keys()):
|
||||
self.assertTrue(path.startswith(o.directory))
|
||||
relpath = path[len(o.directory)+1:]
|
||||
|
||||
@@ -860,7 +860,7 @@ class TestEmitterBasic(unittest.TestCase):
|
||||
'.S': ['g.S'],
|
||||
'.s': ['h.s', 'i.asm'],
|
||||
}
|
||||
for suffix, files in expected.items():
|
||||
for suffix, files in list(expected.items()):
|
||||
sources = suffix_map[suffix]
|
||||
self.assertEqual(
|
||||
sources.files,
|
||||
@@ -913,7 +913,7 @@ class TestEmitterBasic(unittest.TestCase):
|
||||
'.S': ['g.S'],
|
||||
'.s': ['h.s', 'i.asm'],
|
||||
}
|
||||
for suffix, files in expected.items():
|
||||
for suffix, files in list(expected.items()):
|
||||
sources = suffix_map[suffix]
|
||||
self.assertEqual(
|
||||
sources.files,
|
||||
@@ -939,7 +939,7 @@ class TestEmitterBasic(unittest.TestCase):
|
||||
'.c': ['d.c'],
|
||||
'.mm': ['e.mm', 'f.mm'],
|
||||
}
|
||||
for suffix, files in expected.items():
|
||||
for suffix, files in list(expected.items()):
|
||||
sources = suffix_map[suffix]
|
||||
self.assertEqual(
|
||||
sources.files,
|
||||
@@ -964,7 +964,7 @@ class TestEmitterBasic(unittest.TestCase):
|
||||
'.mm': ['objc1.mm', 'objc2.mm'],
|
||||
'.c': ['c1.c', 'c2.c'],
|
||||
}
|
||||
for suffix, files in expected.items():
|
||||
for suffix, files in list(expected.items()):
|
||||
sources = suffix_map[suffix]
|
||||
self.assertEqual(
|
||||
sources.files,
|
||||
@@ -990,7 +990,7 @@ class TestEmitterBasic(unittest.TestCase):
|
||||
'.mm': ['objc1.mm', 'objc2.mm'],
|
||||
'.c': ['c1.c', 'c2.c'],
|
||||
}
|
||||
for suffix, files in expected.items():
|
||||
for suffix, files in list(expected.items()):
|
||||
sources = suffix_map[suffix]
|
||||
self.assertEqual(
|
||||
sources.files,
|
||||
|
||||
@@ -423,7 +423,7 @@ class TestBuildReader(unittest.TestCase):
|
||||
'simple/base.cpp',
|
||||
])
|
||||
|
||||
for path, pattern_set in expected.items():
|
||||
for path, pattern_set in list(expected.items()):
|
||||
self.assertEqual(v[path].test_files,
|
||||
expected[path])
|
||||
|
||||
@@ -438,7 +438,7 @@ class TestBuildReader(unittest.TestCase):
|
||||
'default/tests/reftests/**']),
|
||||
}
|
||||
|
||||
for path, pattern_set in expected.items():
|
||||
for path, pattern_set in list(expected.items()):
|
||||
self.assertEqual(v[path].test_files,
|
||||
expected[path])
|
||||
|
||||
@@ -454,7 +454,7 @@ class TestBuildReader(unittest.TestCase):
|
||||
'tagged/src/bar.jsm': set(['tagged/**.js']),
|
||||
}
|
||||
|
||||
for path, pattern_set in expected_patterns.items():
|
||||
for path, pattern_set in list(expected_patterns.items()):
|
||||
self.assertEqual(v[path].test_files,
|
||||
expected_patterns[path])
|
||||
|
||||
@@ -462,7 +462,7 @@ class TestBuildReader(unittest.TestCase):
|
||||
'tagged/src/submodule/foo.js': set(['submodule']),
|
||||
'tagged/src/bar.jsm': set([]),
|
||||
}
|
||||
for path, pattern_set in expected_tags.items():
|
||||
for path, pattern_set in list(expected_tags.items()):
|
||||
self.assertEqual(v[path].test_tags,
|
||||
expected_tags[path])
|
||||
|
||||
@@ -470,7 +470,7 @@ class TestBuildReader(unittest.TestCase):
|
||||
'tagged/src/bar.jsm': set(['browser-chrome']),
|
||||
'tagged/src/submodule/foo.js': set([]),
|
||||
}
|
||||
for path, pattern_set in expected_flavors.items():
|
||||
for path, pattern_set in list(expected_flavors.items()):
|
||||
self.assertEqual(v[path].test_flavors,
|
||||
expected_flavors[path])
|
||||
|
||||
|
||||
@@ -152,7 +152,7 @@ class TestOrderedDefaultDict(unittest.TestCase):
|
||||
|
||||
self.assertEqual(test['foo'], 1)
|
||||
|
||||
self.assertEqual(test.keys(), ['foo', 'bar' ])
|
||||
self.assertEqual(list(test.keys()), ['foo', 'bar' ])
|
||||
|
||||
def test_defaults(self):
|
||||
test = OrderedDefaultDict(bool, {'foo': 1 })
|
||||
@@ -161,7 +161,7 @@ class TestOrderedDefaultDict(unittest.TestCase):
|
||||
|
||||
self.assertEqual(test['qux'], False)
|
||||
|
||||
self.assertEqual(test.keys(), ['foo', 'qux' ])
|
||||
self.assertEqual(list(test.keys()), ['foo', 'qux' ])
|
||||
|
||||
|
||||
class TestKeyedDefaultDict(unittest.TestCase):
|
||||
|
||||
@@ -122,7 +122,7 @@ class _TreeDiff(dircmp):
|
||||
rv['diff_files'] += [basepath.format(l) for l in dc.diff_files]
|
||||
rv['funny'] += [basepath.format(l) for l in dc.common_funny]
|
||||
rv['funny'] += [basepath.format(l) for l in dc.funny_files]
|
||||
for subdir, _dc in dc.subdirs.iteritems():
|
||||
for subdir, _dc in dc.subdirs.items():
|
||||
self._fillDiff(_dc, rv, basepath.format(subdir + "/{0}"))
|
||||
def allResults(self, left, right):
|
||||
rv = {'right_only':[], 'left_only':[],
|
||||
@@ -295,7 +295,7 @@ class TestJarMaker(unittest.TestCase):
|
||||
('hoge', 'foo', '2'): ('qux', 'foo', '2'),
|
||||
('hoge', 'baz'): ('qux', 'baz'),
|
||||
}
|
||||
for dest, src in expected_symlinks.iteritems():
|
||||
for dest, src in expected_symlinks.items():
|
||||
srcpath = os.path.join(self.srcdir, *src)
|
||||
destpath = os.path.join(self.builddir, 'chrome', 'test', 'dir',
|
||||
*dest)
|
||||
|
||||
@@ -62,7 +62,7 @@ class TestMetadata(object):
|
||||
if test_defaults:
|
||||
with open(test_defaults, 'rb') as fh:
|
||||
defaults = pickle.load(fh)
|
||||
for path, tests in test_data.items():
|
||||
for path, tests in list(test_data.items()):
|
||||
for metadata in tests:
|
||||
if defaults:
|
||||
manifest = metadata['manifest']
|
||||
@@ -302,7 +302,7 @@ REFTEST_FLAVORS = ('crashtest', 'reftest')
|
||||
WEB_PLATFORM_TESTS_FLAVORS = ('web-platform-tests',)
|
||||
|
||||
def all_test_flavors():
|
||||
return ([v[0] for v in TEST_MANIFESTS.values()] +
|
||||
return ([v[0] for v in list(TEST_MANIFESTS.values())] +
|
||||
list(REFTEST_FLAVORS) +
|
||||
list(WEB_PLATFORM_TESTS_FLAVORS) +
|
||||
['python'])
|
||||
@@ -444,7 +444,7 @@ def install_test_files(topsrcdir, topobjdir, tests_root, test_objs):
|
||||
only a few tests need to be run.
|
||||
"""
|
||||
flavor_info = {flavor: (root, prefix, install)
|
||||
for (flavor, root, prefix, install) in TEST_MANIFESTS.values()}
|
||||
for (flavor, root, prefix, install) in list(TEST_MANIFESTS.values())}
|
||||
objdir_dest = mozpath.join(topobjdir, tests_root)
|
||||
|
||||
converter = SupportFilesConverter()
|
||||
|
||||
@@ -92,7 +92,7 @@ class EmptyValue(unicode):
|
||||
class ReadOnlyNamespace(object):
|
||||
"""A class for objects with immutable attributes set at initialization."""
|
||||
def __init__(self, **kwargs):
|
||||
for k, v in kwargs.iteritems():
|
||||
for k, v in kwargs.items():
|
||||
super(ReadOnlyNamespace, self).__setattr__(k, v)
|
||||
|
||||
def __delattr__(self, key):
|
||||
@@ -542,14 +542,14 @@ def FlagsFactory(flags):
|
||||
functions below.
|
||||
"""
|
||||
assert isinstance(flags, dict)
|
||||
assert all(isinstance(v, type) for v in flags.values())
|
||||
assert all(isinstance(v, type) for v in list(flags.values()))
|
||||
|
||||
class Flags(object):
|
||||
__slots__ = flags.keys()
|
||||
__slots__ = list(flags.keys())
|
||||
_flags = flags
|
||||
|
||||
def update(self, **kwargs):
|
||||
for k, v in kwargs.iteritems():
|
||||
for k, v in kwargs.items():
|
||||
setattr(self, k, v)
|
||||
|
||||
def __getattr__(self, name):
|
||||
@@ -1196,7 +1196,7 @@ _INDENTED_REPR_TABLE = {
|
||||
}
|
||||
# Regexp matching all characters to escape.
|
||||
_INDENTED_REPR_RE = re.compile(
|
||||
'([' + ''.join(_INDENTED_REPR_TABLE.values()) + ']+)')
|
||||
'([' + ''.join(list(_INDENTED_REPR_TABLE.values())) + ']+)')
|
||||
|
||||
|
||||
def indented_repr(o, indent=4):
|
||||
@@ -1252,7 +1252,7 @@ def encode(obj, encoding='utf-8'):
|
||||
if isinstance(obj, dict):
|
||||
return {
|
||||
encode(k, encoding): encode(v, encoding)
|
||||
for k, v in obj.iteritems()
|
||||
for k, v in obj.items()
|
||||
}
|
||||
if isinstance(obj, bytes):
|
||||
return obj
|
||||
|
||||
@@ -250,7 +250,7 @@ class Flags(OrderedDict):
|
||||
flags.match(application='foo', appversion='3.5') returns True
|
||||
flags.match(application='foo', appversion='3.0') returns False
|
||||
'''
|
||||
for name, value in filter.iteritems():
|
||||
for name, value in filter.items():
|
||||
if not name in self:
|
||||
continue
|
||||
if not self[name].matches(value):
|
||||
|
||||
@@ -321,7 +321,7 @@ class ManifestContract(ManifestEntry):
|
||||
return self.serialize(self.contractID, self.cid)
|
||||
|
||||
# All manifest classes by their type name.
|
||||
MANIFESTS_TYPES = dict([(c.type, c) for c in globals().values()
|
||||
MANIFESTS_TYPES = dict([(c.type, c) for c in list(globals().values())
|
||||
if type(c) == type and issubclass(c, ManifestEntry)
|
||||
and hasattr(c, 'type') and c.type])
|
||||
|
||||
|
||||
@@ -109,7 +109,7 @@ class FileRegistry(object):
|
||||
'''
|
||||
Return all paths stored in the container, in the order they were added.
|
||||
'''
|
||||
return self._files.keys()
|
||||
return list(self._files.keys())
|
||||
|
||||
def __len__(self):
|
||||
'''
|
||||
@@ -142,7 +142,7 @@ class FileRegistry(object):
|
||||
for path, file in registry:
|
||||
(...)
|
||||
'''
|
||||
return self._files.iteritems()
|
||||
return iter(self._files.items())
|
||||
|
||||
def required_directories(self):
|
||||
'''
|
||||
@@ -151,7 +151,7 @@ class FileRegistry(object):
|
||||
unspecified (virtual) root directory (and do not include said root
|
||||
directory).
|
||||
'''
|
||||
return set(k for k, v in self._required_directories.items() if v > 0)
|
||||
return set(k for k, v in list(self._required_directories.items()) if v > 0)
|
||||
|
||||
|
||||
class FileRegistrySubtree(object):
|
||||
|
||||
@@ -1016,7 +1016,7 @@ class ComposedFinder(BaseFinder):
|
||||
from mozpack.copier import FileRegistry
|
||||
self.files = FileRegistry()
|
||||
|
||||
for base, finder in sorted(finders.iteritems()):
|
||||
for base, finder in sorted(finders.items()):
|
||||
if self.files.contains(base):
|
||||
self.files.remove(base)
|
||||
for p, f in finder.find(''):
|
||||
|
||||
@@ -71,7 +71,7 @@ class JarStruct(object):
|
||||
an instance with empty fields.
|
||||
'''
|
||||
assert self.MAGIC and isinstance(self.STRUCT, OrderedDict)
|
||||
self.size_fields = set(t for t in self.STRUCT.itervalues()
|
||||
self.size_fields = set(t for t in self.STRUCT.values()
|
||||
if not t in JarStruct.TYPE_MAPPING)
|
||||
self._values = {}
|
||||
if data:
|
||||
@@ -93,7 +93,7 @@ class JarStruct(object):
|
||||
# For all fields used as other fields sizes, keep track of their value
|
||||
# separately.
|
||||
sizes = dict((t, 0) for t in self.size_fields)
|
||||
for name, t in self.STRUCT.iteritems():
|
||||
for name, t in self.STRUCT.items():
|
||||
if t in JarStruct.TYPE_MAPPING:
|
||||
value, size = JarStruct.get_data(t, data[offset:])
|
||||
else:
|
||||
@@ -112,7 +112,7 @@ class JarStruct(object):
|
||||
Initialize an instance with empty fields.
|
||||
'''
|
||||
self.signature = self.MAGIC
|
||||
for name, t in self.STRUCT.iteritems():
|
||||
for name, t in self.STRUCT.items():
|
||||
if name in self.size_fields:
|
||||
continue
|
||||
self._values[name] = 0 if t in JarStruct.TYPE_MAPPING else ''
|
||||
@@ -137,9 +137,9 @@ class JarStruct(object):
|
||||
from self.STRUCT.
|
||||
'''
|
||||
serialized = struct.pack('<I', self.signature)
|
||||
sizes = dict((t, name) for name, t in self.STRUCT.iteritems()
|
||||
sizes = dict((t, name) for name, t in self.STRUCT.items()
|
||||
if not t in JarStruct.TYPE_MAPPING)
|
||||
for name, t in self.STRUCT.iteritems():
|
||||
for name, t in self.STRUCT.items():
|
||||
if t in JarStruct.TYPE_MAPPING:
|
||||
format, size = JarStruct.TYPE_MAPPING[t]
|
||||
if name in sizes:
|
||||
@@ -158,7 +158,7 @@ class JarStruct(object):
|
||||
variable length fields.
|
||||
'''
|
||||
size = JarStruct.TYPE_MAPPING['uint32'][1]
|
||||
for name, type in self.STRUCT.iteritems():
|
||||
for name, type in self.STRUCT.items():
|
||||
if type in JarStruct.TYPE_MAPPING:
|
||||
size += JarStruct.TYPE_MAPPING[type][1]
|
||||
else:
|
||||
@@ -179,7 +179,7 @@ class JarStruct(object):
|
||||
return key in self._values
|
||||
|
||||
def __iter__(self):
|
||||
return self._values.iteritems()
|
||||
return iter(self._values.items())
|
||||
|
||||
def __repr__(self):
|
||||
return "<%s %s>" % (self.__class__.__name__,
|
||||
@@ -373,7 +373,7 @@ class JarReader(object):
|
||||
entries = self.entries
|
||||
if not entries:
|
||||
return JAR_STORED
|
||||
return max(f['compression'] for f in entries.itervalues())
|
||||
return max(f['compression'] for f in entries.values())
|
||||
|
||||
@property
|
||||
def entries(self):
|
||||
@@ -451,7 +451,7 @@ class JarReader(object):
|
||||
for file in jarReader:
|
||||
...
|
||||
'''
|
||||
for entry in self.entries.itervalues():
|
||||
for entry in self.entries.values():
|
||||
yield self._getreader(entry)
|
||||
|
||||
def __getitem__(self, name):
|
||||
@@ -546,7 +546,7 @@ class JarWriter(object):
|
||||
headers = {}
|
||||
preload_size = 0
|
||||
# Prepare central directory entries
|
||||
for entry, content in self._contents.itervalues():
|
||||
for entry, content in self._contents.values():
|
||||
header = JarLocalFileHeader()
|
||||
for name in entry.STRUCT:
|
||||
if name in header:
|
||||
@@ -561,7 +561,7 @@ class JarWriter(object):
|
||||
end['disk_entries'] = len(self._contents)
|
||||
end['cdir_entries'] = end['disk_entries']
|
||||
end['cdir_size'] = reduce(lambda x, y: x + y[0].size,
|
||||
self._contents.values(), 0)
|
||||
list(self._contents.values()), 0)
|
||||
# On optimized archives, store the preloaded size and the central
|
||||
# directory entries, followed by the first end of central directory.
|
||||
if self._optimize:
|
||||
@@ -570,18 +570,18 @@ class JarWriter(object):
|
||||
if preload_size:
|
||||
preload_size += offset
|
||||
self._data.write(struct.pack('<I', preload_size))
|
||||
for entry, _ in self._contents.itervalues():
|
||||
for entry, _ in self._contents.values():
|
||||
entry['offset'] += offset
|
||||
self._data.write(entry.serialize())
|
||||
self._data.write(end.serialize())
|
||||
# Store local file entries followed by compressed data
|
||||
for entry, content in self._contents.itervalues():
|
||||
for entry, content in self._contents.values():
|
||||
self._data.write(headers[entry].serialize())
|
||||
self._data.write(content)
|
||||
# On non optimized archives, store the central directory entries.
|
||||
if not self._optimize:
|
||||
end['cdir_offset'] = offset
|
||||
for entry, _ in self._contents.itervalues():
|
||||
for entry, _ in self._contents.values():
|
||||
self._data.write(entry.serialize())
|
||||
# Store the end of central directory.
|
||||
self._data.write(end.serialize())
|
||||
|
||||
@@ -118,7 +118,7 @@ class Component(object):
|
||||
destdir = options.pop('destdir', '')
|
||||
if options:
|
||||
errors.fatal('Malformed manifest: options %s not recognized'
|
||||
% options.keys())
|
||||
% list(options.keys()))
|
||||
return Component(name, destdir=destdir)
|
||||
|
||||
|
||||
@@ -328,7 +328,7 @@ class SimplePackager(object):
|
||||
|
||||
bases = self.get_bases()
|
||||
broken_bases = sorted(
|
||||
m for m, includer in self._included_manifests.iteritems()
|
||||
m for m, includer in self._included_manifests.items()
|
||||
if mozpath.basedir(m, bases) != mozpath.basedir(includer, bases))
|
||||
for m in broken_bases:
|
||||
errors.fatal('"%s" is included from "%s", which is outside "%s"' %
|
||||
|
||||
@@ -89,7 +89,7 @@ class PiecemealFormatter(object):
|
||||
Return the deepest base directory containing the given path.
|
||||
'''
|
||||
self._frozen_bases = True
|
||||
base = mozpath.basedir(path, self._sub_formatter.keys())
|
||||
base = mozpath.basedir(path, list(self._sub_formatter.keys()))
|
||||
relpath = mozpath.relpath(path, base) if base else path
|
||||
return base, relpath
|
||||
|
||||
|
||||
@@ -163,7 +163,7 @@ def _repack(app_finder, l10n_finder, copier, formatter, non_chrome=set()):
|
||||
if not path:
|
||||
continue
|
||||
else:
|
||||
base = mozpath.basedir(p, paths.keys())
|
||||
base = mozpath.basedir(p, list(paths.keys()))
|
||||
if base:
|
||||
subpath = mozpath.relpath(p, base)
|
||||
path = mozpath.normpath(mozpath.join(paths[base],
|
||||
@@ -207,7 +207,7 @@ def _repack(app_finder, l10n_finder, copier, formatter, non_chrome=set()):
|
||||
formatter.add(p, f)
|
||||
|
||||
# Transplant jar preloading information.
|
||||
for path, log in app_finder.jarlogs.iteritems():
|
||||
for path, log in app_finder.jarlogs.items():
|
||||
assert isinstance(copier[path], Jarrer)
|
||||
copier[path].preload([l.replace(locale, l10n_locale) for l in log])
|
||||
|
||||
@@ -238,7 +238,7 @@ def repack(source, l10n, extra_l10n={}, non_resources=[], non_chrome=set()):
|
||||
finders = {
|
||||
'': l10n_finder,
|
||||
}
|
||||
for base, path in extra_l10n.iteritems():
|
||||
for base, path in extra_l10n.items():
|
||||
finders[base] = UnpackFinder(path)
|
||||
l10n_finder = ComposedFinder(finders)
|
||||
copier = FileCopier()
|
||||
|
||||
@@ -148,7 +148,7 @@ class UnpackFinder(BaseFinder):
|
||||
self.optimizedjars = True
|
||||
self.compressed = max(self.compressed, jar.compression)
|
||||
if jar.last_preloaded:
|
||||
jarlog = jar.entries.keys()
|
||||
jarlog = list(jar.entries.keys())
|
||||
self.jarlogs[path] = jarlog[:jarlog.index(jar.last_preloaded) + 1]
|
||||
return jar
|
||||
|
||||
|
||||
@@ -127,7 +127,7 @@ class TestFileRegistry(BaseTestFileRegistry, unittest.TestCase):
|
||||
'bar': [],
|
||||
}
|
||||
reg = FileRegistry()
|
||||
for path, parts in cases.iteritems():
|
||||
for path, parts in cases.items():
|
||||
self.assertEqual(reg._partial_paths(path), parts)
|
||||
|
||||
def test_file_registry(self):
|
||||
|
||||
@@ -128,7 +128,7 @@ for addon in ('addon0', 'addon1'):
|
||||
'foo': read_interfaces(foo2_xpt.open())['foo'],
|
||||
'bar': read_interfaces(bar_xpt.open())['bar'],
|
||||
},
|
||||
}.iteritems()
|
||||
}.items()
|
||||
})
|
||||
|
||||
RESULT_JAR = {
|
||||
@@ -174,7 +174,7 @@ RESULT_JAR.update({
|
||||
},
|
||||
'addon1.xpi': {
|
||||
mozpath.relpath(p, 'addon1'): f
|
||||
for p, f in RESULT_FLAT.iteritems()
|
||||
for p, f in RESULT_FLAT.items()
|
||||
if p.startswith('addon1/')
|
||||
},
|
||||
})
|
||||
@@ -234,7 +234,7 @@ RESULT_OMNIJAR['omni.foo'].update({
|
||||
CONTENTS_WITH_BASE = {
|
||||
'bases': {
|
||||
mozpath.join('base/root', b) if b else 'base/root': a
|
||||
for b, a in CONTENTS['bases'].iteritems()
|
||||
for b, a in CONTENTS['bases'].items()
|
||||
},
|
||||
'manifests': [
|
||||
m.move(mozpath.join('base/root', m.base))
|
||||
@@ -242,7 +242,7 @@ CONTENTS_WITH_BASE = {
|
||||
],
|
||||
'files': {
|
||||
mozpath.join('base/root', p): f
|
||||
for p, f in CONTENTS['files'].iteritems()
|
||||
for p, f in CONTENTS['files'].items()
|
||||
},
|
||||
}
|
||||
|
||||
@@ -255,7 +255,7 @@ CONTENTS_WITH_BASE['files'].update(EXTRA_CONTENTS)
|
||||
def result_with_base(results):
|
||||
result = {
|
||||
mozpath.join('base/root', p): v
|
||||
for p, v in results.iteritems()
|
||||
for p, v in results.items()
|
||||
}
|
||||
result.update(EXTRA_CONTENTS)
|
||||
return result
|
||||
@@ -271,13 +271,13 @@ class MockDest(MockDest):
|
||||
|
||||
|
||||
def fill_formatter(formatter, contents):
|
||||
for base, is_addon in contents['bases'].items():
|
||||
for base, is_addon in list(contents['bases'].items()):
|
||||
formatter.add_base(base, is_addon)
|
||||
|
||||
for manifest in contents['manifests']:
|
||||
formatter.add_manifest(manifest)
|
||||
|
||||
for k, v in contents['files'].iteritems():
|
||||
for k, v in contents['files'].items():
|
||||
if k.endswith('.xpt'):
|
||||
formatter.add_interfaces(k, v)
|
||||
else:
|
||||
|
||||
@@ -118,7 +118,7 @@ class TestL10NRepack(unittest.TestCase):
|
||||
|
||||
self.assertEqual(
|
||||
dict((p, f.open().read()) for p, f in copier),
|
||||
dict((p, f.open().read()) for p, f in repacked.iteritems())
|
||||
dict((p, f.open().read()) for p, f in repacked.items())
|
||||
)
|
||||
|
||||
|
||||
|
||||
@@ -82,7 +82,7 @@ class StylishFormatter(object):
|
||||
|
||||
num_errors = 0
|
||||
num_warnings = 0
|
||||
for path, errors in sorted(result.iteritems()):
|
||||
for path, errors in sorted(result.items()):
|
||||
self._reset_max()
|
||||
|
||||
message.append(self.term.underline(path))
|
||||
|
||||
@@ -18,7 +18,7 @@ class TreeherderFormatter(object):
|
||||
|
||||
def __call__(self, result):
|
||||
message = []
|
||||
for path, errors in sorted(result.iteritems()):
|
||||
for path, errors in sorted(result.items()):
|
||||
for err in errors:
|
||||
assert isinstance(err, ResultContainer)
|
||||
|
||||
|
||||
@@ -149,6 +149,6 @@ class LintRoller(object):
|
||||
results, return_code = worker.get()
|
||||
if results or return_code:
|
||||
self.return_code = 1
|
||||
for k, v in results.iteritems():
|
||||
for k, v in results.items():
|
||||
all_results[k].extend(v)
|
||||
return all_results
|
||||
@@ -81,7 +81,7 @@ def test_json_formatter(results):
|
||||
assert set(formatted.keys()) == set(results.keys())
|
||||
|
||||
slots = ResultContainer.__slots__
|
||||
for errors in formatted.values():
|
||||
for errors in list(formatted.values()):
|
||||
for err in errors:
|
||||
assert all(s in err for s in slots)
|
||||
|
||||
|
||||
@@ -29,7 +29,7 @@ def test_roll_successful(lint, linters, files):
|
||||
assert len(result) == 1
|
||||
assert lint.return_code == 1
|
||||
|
||||
path = result.keys()[0]
|
||||
path = list(result.keys())[0]
|
||||
assert os.path.basename(path) == 'foobar.js'
|
||||
|
||||
errors = result[path]
|
||||
|
||||
@@ -57,7 +57,7 @@ duplex_map = {
|
||||
|
||||
def main():
|
||||
stats = psutil.net_if_stats()
|
||||
for nic, addrs in psutil.net_if_addrs().items():
|
||||
for nic, addrs in list(psutil.net_if_addrs().items()):
|
||||
if nic in stats:
|
||||
print("%s (speed=%sMB, duplex=%s, mtu=%s, up=%s):" % (
|
||||
nic, stats[nic].speed, duplex_map[stats[nic].duplex],
|
||||
|
||||
@@ -159,7 +159,7 @@ def print_header(procs_status, num_procs):
|
||||
|
||||
# processes number and status
|
||||
st = []
|
||||
for x, y in procs_status.items():
|
||||
for x, y in list(procs_status.items()):
|
||||
if y:
|
||||
st.append("%s=%s" % (x, y))
|
||||
st.sort(key=lambda x: x[:3] in ('run', 'sle'), reverse=1)
|
||||
|
||||
@@ -799,7 +799,7 @@ class Process(object):
|
||||
pass
|
||||
else:
|
||||
# Windows only (faster)
|
||||
for pid, ppid in ppid_map.items():
|
||||
for pid, ppid in list(ppid_map.items()):
|
||||
if ppid == self.pid:
|
||||
try:
|
||||
child = Process(pid)
|
||||
@@ -820,7 +820,7 @@ class Process(object):
|
||||
except (NoSuchProcess, ZombieProcess):
|
||||
pass
|
||||
else:
|
||||
for pid, ppid in ppid_map.items():
|
||||
for pid, ppid in list(ppid_map.items()):
|
||||
try:
|
||||
p = Process(pid)
|
||||
table[ppid].append(p)
|
||||
@@ -1674,11 +1674,11 @@ def disk_io_counters(perdisk=False):
|
||||
if not rawdict:
|
||||
raise RuntimeError("couldn't find any physical disk")
|
||||
if perdisk:
|
||||
for disk, fields in rawdict.items():
|
||||
for disk, fields in list(rawdict.items()):
|
||||
rawdict[disk] = _common.sdiskio(*fields)
|
||||
return rawdict
|
||||
else:
|
||||
return _common.sdiskio(*[sum(x) for x in zip(*rawdict.values())])
|
||||
return _common.sdiskio(*[sum(x) for x in zip(*list(rawdict.values()))])
|
||||
|
||||
|
||||
# =====================================================================
|
||||
@@ -1709,11 +1709,11 @@ def net_io_counters(pernic=False):
|
||||
if not rawdict:
|
||||
raise RuntimeError("couldn't find any network interface")
|
||||
if pernic:
|
||||
for nic, fields in rawdict.items():
|
||||
for nic, fields in list(rawdict.items()):
|
||||
rawdict[nic] = _common.snetio(*fields)
|
||||
return rawdict
|
||||
else:
|
||||
return _common.snetio(*[sum(x) for x in zip(*rawdict.values())])
|
||||
return _common.snetio(*[sum(x) for x in zip(*list(rawdict.values()))])
|
||||
|
||||
|
||||
def net_connections(kind='inet'):
|
||||
|
||||
@@ -216,7 +216,7 @@ def net_connections(kind):
|
||||
|
||||
def net_if_stats():
|
||||
"""Get NIC stats (isup, duplex, speed, mtu)."""
|
||||
names = net_io_counters().keys()
|
||||
names = list(net_io_counters().keys())
|
||||
ret = {}
|
||||
for name in names:
|
||||
isup, duplex, speed, mtu = cext_posix.net_if_stats(name)
|
||||
|
||||
@@ -601,7 +601,7 @@ def net_if_stats():
|
||||
duplex_map = {cext.DUPLEX_FULL: NIC_DUPLEX_FULL,
|
||||
cext.DUPLEX_HALF: NIC_DUPLEX_HALF,
|
||||
cext.DUPLEX_UNKNOWN: NIC_DUPLEX_UNKNOWN}
|
||||
names = net_io_counters().keys()
|
||||
names = list(net_io_counters().keys())
|
||||
ret = {}
|
||||
for name in names:
|
||||
isup, duplex, speed, mtu = cext.net_if_stats(name)
|
||||
|
||||
@@ -170,7 +170,7 @@ def net_connections(kind='inet'):
|
||||
|
||||
def net_if_stats():
|
||||
"""Get NIC stats (isup, duplex, speed, mtu)."""
|
||||
names = net_io_counters().keys()
|
||||
names = list(net_io_counters().keys())
|
||||
ret = {}
|
||||
for name in names:
|
||||
isup, duplex, speed, mtu = cext_posix.net_if_stats(name)
|
||||
|
||||
@@ -237,7 +237,7 @@ def net_connections(kind, _pid=-1):
|
||||
def net_if_stats():
|
||||
"""Get NIC stats (isup, duplex, speed, mtu)."""
|
||||
ret = cext.net_if_stats()
|
||||
for name, items in ret.items():
|
||||
for name, items in list(ret.items()):
|
||||
isup, duplex, speed, mtu = items
|
||||
if hasattr(_common, 'NicDuplex'):
|
||||
duplex = _common.NicDuplex(duplex)
|
||||
|
||||
@@ -215,7 +215,7 @@ def net_connections(kind, _pid=-1):
|
||||
|
||||
def net_if_stats():
|
||||
ret = cext.net_if_stats()
|
||||
for name, items in ret.items():
|
||||
for name, items in list(ret.items()):
|
||||
isup, duplex, speed, mtu = items
|
||||
if hasattr(_common, 'NicDuplex'):
|
||||
duplex = _common.NicDuplex(duplex)
|
||||
|
||||
@@ -192,7 +192,7 @@ class LinuxSpecificTestCase(unittest.TestCase):
|
||||
self.assertNotIn('guest_nice', fields)
|
||||
|
||||
def test_net_if_addrs_ips(self):
|
||||
for name, addrs in psutil.net_if_addrs().items():
|
||||
for name, addrs in list(psutil.net_if_addrs().items()):
|
||||
for addr in addrs:
|
||||
if addr.family == psutil.AF_LINK:
|
||||
self.assertEqual(addr.address, get_mac_address(name))
|
||||
@@ -211,7 +211,7 @@ class LinuxSpecificTestCase(unittest.TestCase):
|
||||
if re.search("^\d+:", line):
|
||||
found += 1
|
||||
name = line.split(':')[1].strip()
|
||||
self.assertIn(name, nics.keys())
|
||||
self.assertIn(name, list(nics.keys()))
|
||||
self.assertEqual(len(nics), found, msg="%s\n---\n%s" % (
|
||||
pprint.pformat(nics), out))
|
||||
|
||||
|
||||
@@ -186,7 +186,7 @@ class PosixSpecificTestCase(unittest.TestCase):
|
||||
output = p.communicate()[0].strip()
|
||||
if PY3:
|
||||
output = str(output, sys.stdout.encoding)
|
||||
for nic in psutil.net_io_counters(pernic=True).keys():
|
||||
for nic in list(psutil.net_io_counters(pernic=True).keys()):
|
||||
for line in output.split():
|
||||
if line.startswith(nic):
|
||||
break
|
||||
|
||||
@@ -91,7 +91,7 @@ class WindowsSpecificTestCase(unittest.TestCase):
|
||||
out = p.communicate()[0]
|
||||
if PY3:
|
||||
out = str(out, sys.stdout.encoding)
|
||||
nics = psutil.net_io_counters(pernic=True).keys()
|
||||
nics = list(psutil.net_io_counters(pernic=True).keys())
|
||||
for nic in nics:
|
||||
if "pseudo-interface" in nic.replace(' ', '-').lower():
|
||||
continue
|
||||
|
||||
@@ -990,7 +990,7 @@ class TestSystemAPIs(unittest.TestCase):
|
||||
self.assertIn(conn.type, types_, msg=conn)
|
||||
|
||||
from psutil._common import conn_tmap
|
||||
for kind, groups in conn_tmap.items():
|
||||
for kind, groups in list(conn_tmap.items()):
|
||||
if SUNOS and kind == 'unix':
|
||||
continue
|
||||
families, types_ = groups
|
||||
@@ -1035,7 +1035,7 @@ class TestSystemAPIs(unittest.TestCase):
|
||||
# sorted(psutil.net_io_counters(pernic=True).keys()))
|
||||
|
||||
families = set([socket.AF_INET, AF_INET6, psutil.AF_LINK])
|
||||
for nic, addrs in nics.items():
|
||||
for nic, addrs in list(nics.items()):
|
||||
self.assertEqual(len(set(addrs)), len(addrs))
|
||||
for addr in addrs:
|
||||
self.assertIsInstance(addr.family, int)
|
||||
@@ -1080,7 +1080,7 @@ class TestSystemAPIs(unittest.TestCase):
|
||||
all_duplexes = (psutil.NIC_DUPLEX_FULL,
|
||||
psutil.NIC_DUPLEX_HALF,
|
||||
psutil.NIC_DUPLEX_UNKNOWN)
|
||||
for nic, stats in nics.items():
|
||||
for nic, stats in list(nics.items()):
|
||||
isup, duplex, speed, mtu = stats
|
||||
self.assertIsInstance(isup, bool)
|
||||
self.assertIn(duplex, all_duplexes)
|
||||
@@ -1120,7 +1120,7 @@ class TestSystemAPIs(unittest.TestCase):
|
||||
# https://github.com/giampaolo/psutil/issues/338
|
||||
while key[-1].isdigit():
|
||||
key = key[:-1]
|
||||
self.assertNotIn(key, ret.keys())
|
||||
self.assertNotIn(key, list(ret.keys()))
|
||||
|
||||
def test_users(self):
|
||||
users = psutil.users()
|
||||
@@ -2085,7 +2085,7 @@ class TestProcess(unittest.TestCase):
|
||||
except psutil.Error:
|
||||
pass
|
||||
# this is the one, now let's make sure there are no duplicates
|
||||
pid = sorted(table.items(), key=lambda x: x[1])[-1][0]
|
||||
pid = sorted(list(table.items()), key=lambda x: x[1])[-1][0]
|
||||
p = psutil.Process(pid)
|
||||
try:
|
||||
c = p.children(recursive=True)
|
||||
|
||||
@@ -72,10 +72,10 @@ class ApiModule(ModuleType):
|
||||
self.__map__ = {}
|
||||
self.__implprefix__ = implprefix or name
|
||||
if attr:
|
||||
for name, val in attr.items():
|
||||
for name, val in list(attr.items()):
|
||||
# print "setting", self.__name__, name, val
|
||||
setattr(self, name, val)
|
||||
for name, importspec in importspec.items():
|
||||
for name, importspec in list(importspec.items()):
|
||||
if isinstance(importspec, dict):
|
||||
subname = '%s.%s' % (self.__name__, name)
|
||||
apimod = ApiModule(subname, importspec, implprefix)
|
||||
|
||||
@@ -227,10 +227,10 @@ class Or(Interpretable):
|
||||
|
||||
# == Unary operations ==
|
||||
keepalive = []
|
||||
for astclass, astpattern in {
|
||||
for astclass, astpattern in list({
|
||||
ast.Not : 'not __exprinfo_expr',
|
||||
ast.Invert : '(~__exprinfo_expr)',
|
||||
}.items():
|
||||
}.items()):
|
||||
|
||||
class UnaryArith(Interpretable):
|
||||
__view__ = astclass
|
||||
@@ -251,14 +251,14 @@ for astclass, astpattern in {
|
||||
keepalive.append(UnaryArith)
|
||||
|
||||
# == Binary operations ==
|
||||
for astclass, astpattern in {
|
||||
for astclass, astpattern in list({
|
||||
ast.Add : '(__exprinfo_left + __exprinfo_right)',
|
||||
ast.Sub : '(__exprinfo_left - __exprinfo_right)',
|
||||
ast.Mul : '(__exprinfo_left * __exprinfo_right)',
|
||||
ast.Div : '(__exprinfo_left / __exprinfo_right)',
|
||||
ast.Mod : '(__exprinfo_left % __exprinfo_right)',
|
||||
ast.Power : '(__exprinfo_left ** __exprinfo_right)',
|
||||
}.items():
|
||||
}.items()):
|
||||
|
||||
class BinaryArith(Interpretable):
|
||||
__view__ = astclass
|
||||
|
||||
Loaded 100 of 422 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user