diff options
author | Greg Noel <GregNoel@tigris.org> | 2010-04-23 02:58:45 (GMT) |
---|---|---|
committer | Greg Noel <GregNoel@tigris.org> | 2010-04-23 02:58:45 (GMT) |
commit | 591b78f0f314f11192fdf13d3baa66f81b160e44 (patch) | |
tree | a8babbca715c6770a4f2d0cf59ba5bdc16a53b71 | |
parent | c86e4726d30ec4d7086f7fb002e960a2dc570490 (diff) | |
download | SCons-591b78f0f314f11192fdf13d3baa66f81b160e44.zip SCons-591b78f0f314f11192fdf13d3baa66f81b160e44.tar.gz SCons-591b78f0f314f11192fdf13d3baa66f81b160e44.tar.bz2 |
http://scons.tigris.org/issues/show_bug.cgi?id=2317
Apply the refactorings from the 'dict' fixer, less occurrences that were
manually audited to be safe. Also pick up changes in bin/sfsum, a Python
file that was not being scanned before.
28 files changed, 44 insertions, 44 deletions
diff --git a/QMTest/scons_tdb.py b/QMTest/scons_tdb.py index b5788c0..e56af3d 100644 --- a/QMTest/scons_tdb.py +++ b/QMTest/scons_tdb.py @@ -494,7 +494,7 @@ class Database(database.Database): dirs = [d for d in dircache.listdir(path) if os.path.isdir(os.path.join(path, d))] else: - dirs = self.is_a_test.keys() + dirs = list(self.is_a_test.keys()) dirs.sort() return dirs @@ -524,7 +524,7 @@ class Database(database.Database): for d in dircache.listdir(path) if os.path.isdir(os.path.join(path, d))] else: - ids = self.is_a_test.keys() + ids = list(self.is_a_test.keys()) if scan_subdirs: for d in dircache.listdir(path): diff --git a/bench/env.__setitem__.py b/bench/env.__setitem__.py index 831a507..54ac92f 100644 --- a/bench/env.__setitem__.py +++ b/bench/env.__setitem__.py @@ -102,7 +102,7 @@ class Environment: 'SOURCE' : None, 'SOURCES' : None, } - _special_set_keys = _special_set.keys() + _special_set_keys = list(_special_set.keys()) _valid_var = re.compile(r'[_a-zA-Z]\w*$') def __init__(self, **kw): self._dict = kw diff --git a/bin/SConsDoc.py b/bin/SConsDoc.py index 298e252..4429fd2 100644 --- a/bin/SConsDoc.py +++ b/bin/SConsDoc.py @@ -218,7 +218,7 @@ class SConsDocHandler(xml.sax.handler.ContentHandler, def __init__(self): self._start_dispatch = {} self._end_dispatch = {} - keys = self.__class__.__dict__.keys() + keys = list(self.__class__.__dict__.keys()) start_tag_method_names = [k for k in keys if k[:6] == 'start_'] end_tag_method_names = [k for k in keys if k[:4] == 'end_'] for method_name in start_tag_method_names: @@ -119,9 +119,9 @@ if __name__ == '__main__': # Hard-coded search for 'Open' bugs. This should be easily # generalized once we figure out other things for this script to do. - bugs = filter(lambda x: x.status == 'Open', Artifacts['Bugs']) + bugs = [x for x in Artifacts['Bugs'] if x.status == 'Open'] - print Artifacts.keys() + print list(Artifacts.keys()) print "%d open bugs" % len(bugs) diff --git a/src/engine/SCons/Action.py b/src/engine/SCons/Action.py index 6b04612..e121752 100644 --- a/src/engine/SCons/Action.py +++ b/src/engine/SCons/Action.py @@ -1150,7 +1150,7 @@ class ListAction(ActionBase): for act in self.list: for var in act.get_varlist(target, source, env, executor): result[var] = True - return result.keys() + return list(result.keys()) class ActionCaller: """A class for delaying calling an Action function with specific diff --git a/src/engine/SCons/ActionTests.py b/src/engine/SCons/ActionTests.py index 4ffbdec..f31d7da 100644 --- a/src/engine/SCons/ActionTests.py +++ b/src/engine/SCons/ActionTests.py @@ -152,7 +152,7 @@ class Environment: def get(self, key, value=None): return self.d.get(key, value) def items(self): - return self.d.items() + return list(self.d.items()) def Dictionary(self): return self.d def Clone(self, **kw): diff --git a/src/engine/SCons/Builder.py b/src/engine/SCons/Builder.py index 6317a44..2e068c2 100644 --- a/src/engine/SCons/Builder.py +++ b/src/engine/SCons/Builder.py @@ -138,7 +138,7 @@ class DictCmdGenerator(SCons.Util.Selector): self.source_ext_match = source_ext_match def src_suffixes(self): - return self.keys() + return list(self.keys()) def add_action(self, suffix, action): """Add a suffix-action pair to the mapping. @@ -173,7 +173,7 @@ class DictCmdGenerator(SCons.Util.Selector): raise UserError("Ambiguous suffixes after environment substitution: %s == %s == %s" % (e.args[0], e.args[1], e.args[2])) if ret is None: raise UserError("While building `%s' from `%s': Don't know how to build from a source file with suffix `%s'. Expected a suffix in this list: %s." % \ - (repr(list(map(str, target))), repr(list(map(str, source))), ext, repr(self.keys()))) + (repr(list(map(str, target))), repr(list(map(str, source))), ext, repr(list(self.keys())))) return ret class CallableSelector(SCons.Util.Selector): @@ -440,8 +440,8 @@ class BuilderBase: name (if there is one) or the name of the class (by default).""" try: - index = env['BUILDERS'].values().index(self) - return env['BUILDERS'].keys()[index] + index = list(env['BUILDERS'].values()).index(self) + return list(env['BUILDERS'].keys())[index] except (AttributeError, KeyError, TypeError, ValueError): try: return self.name diff --git a/src/engine/SCons/BuilderTests.py b/src/engine/SCons/BuilderTests.py index 50cf778..b1443bc 100644 --- a/src/engine/SCons/BuilderTests.py +++ b/src/engine/SCons/BuilderTests.py @@ -124,7 +124,7 @@ class Environment: def has_key(self, item): return item in self.d def keys(self): - return self.d.keys() + return list(self.d.keys()) def get(self, key, value=None): return self.d.get(key, value) def Override(self, overrides): @@ -135,7 +135,7 @@ class Environment: def _update(self, dict): self.d.update(dict) def items(self): - return self.d.items() + return list(self.d.items()) def sig_dict(self): d = {} for k,v in self.items(): d[k] = v diff --git a/src/engine/SCons/Environment.py b/src/engine/SCons/Environment.py index d9db852..7dc20dc 100644 --- a/src/engine/SCons/Environment.py +++ b/src/engine/SCons/Environment.py @@ -395,7 +395,7 @@ class SubstitutionEnvironment: # Freeze the keys of self._special_set in a list for use by # methods that need to check. (Empirically, list scanning has # gotten better than dict.has_key() in Python 2.5.) - self._special_set_keys = self._special_set.keys() + self._special_set_keys = list(self._special_set.keys()) def __cmp__(self, other): return cmp(self._dict, other._dict) @@ -446,7 +446,7 @@ class SubstitutionEnvironment: return self._dict.__contains__(key) def items(self): - return self._dict.items() + return list(self._dict.items()) def arg2nodes(self, args, node_factory=_null, lookup_list=_null, **kw): if node_factory is _null: @@ -984,9 +984,9 @@ class Base(SubstitutionEnvironment): variables = kw['options'] del kw['options'] self.Replace(**kw) - keys = kw.keys() + keys = list(kw.keys()) if variables: - keys = keys + variables.keys() + keys = keys + list(variables.keys()) variables.Update(self) save = {} @@ -2250,7 +2250,7 @@ class OverrideEnvironment(Base): return d def items(self): """Emulates the items() method of dictionaries.""" - return self.Dictionary().items() + return list(self.Dictionary().items()) # Overridden private construction environment methods. def _update(self, dict): diff --git a/src/engine/SCons/EnvironmentTests.py b/src/engine/SCons/EnvironmentTests.py index 99b3d93..ddaa2ef 100644 --- a/src/engine/SCons/EnvironmentTests.py +++ b/src/engine/SCons/EnvironmentTests.py @@ -40,7 +40,7 @@ def diff_env(env1, env2): s1 = "env1 = {\n" s2 = "env2 = {\n" d = {} - for k in env1._dict.keys() + env2._dict.keys(): + for k in list(env1._dict.keys()) + list(env2._dict.keys()): d[k] = None for k in sorted(d.keys()): if k in env1: @@ -60,7 +60,7 @@ def diff_dict(d1, d2): s1 = "d1 = {\n" s2 = "d2 = {\n" d = {} - for k in d1.keys() + d2.keys(): + for k in list(d1.keys()) + list(d2.keys()): d[k] = None for k in sorted(d.keys()): if k in d1: @@ -250,7 +250,7 @@ class SubstitutionTestCase(unittest.TestCase): """Test the SubstitutionEnvironment items() method """ env = SubstitutionEnvironment(XXX = 'x', YYY = 'y') - items = env.items() + items = list(env.items()) assert items == [('XXX','x'), ('YYY','y')], items def test_arg2nodes(self): diff --git a/src/engine/SCons/Node/FS.py b/src/engine/SCons/Node/FS.py index b961092..3175328 100644 --- a/src/engine/SCons/Node/FS.py +++ b/src/engine/SCons/Node/FS.py @@ -1905,7 +1905,7 @@ class Dir(Base): in any way (or ignored, passing None is common). """ entries = self.entries - names = entries.keys() + names = list(entries.keys()) names.remove('.') names.remove('..') func(arg, self, names) diff --git a/src/engine/SCons/Scanner/Dir.py b/src/engine/SCons/Scanner/Dir.py index 3a0767a..f02904f 100644 --- a/src/engine/SCons/Scanner/Dir.py +++ b/src/engine/SCons/Scanner/Dir.py @@ -101,7 +101,7 @@ def scan_in_memory(node, env, path=()): # mixed Node types (Dirs and Files, for example) has a Dir as # the first entry. return [] - entry_list = sorted(filter(do_not_scan, entries.keys())) + entry_list = sorted(filter(do_not_scan, list(entries.keys()))) return [entries[n] for n in entry_list] # Local Variables: diff --git a/src/engine/SCons/Scanner/LaTeX.py b/src/engine/SCons/Scanner/LaTeX.py index 622f2a3..904d612 100644 --- a/src/engine/SCons/Scanner/LaTeX.py +++ b/src/engine/SCons/Scanner/LaTeX.py @@ -164,7 +164,7 @@ class LaTeX(SCons.Scanner.Base): 'bibliographystyle': 'BSTINPUTS', 'usepackage': 'TEXINPUTS', 'lstinputlisting': 'TEXINPUTS'} - env_variables = SCons.Util.unique(keyword_paths.values()) + env_variables = SCons.Util.unique(list(keyword_paths.values())) def __init__(self, name, suffixes, graphics_extensions, *args, **kw): diff --git a/src/engine/SCons/Scanner/ScannerTests.py b/src/engine/SCons/Scanner/ScannerTests.py index 922c221..a356308 100644 --- a/src/engine/SCons/Scanner/ScannerTests.py +++ b/src/engine/SCons/Scanner/ScannerTests.py @@ -244,7 +244,7 @@ class BaseTestCase(unittest.TestCase): dict = {} dict[s] = 777 i = hash(id(s)) - h = hash(dict.keys()[0]) + h = hash(list(dict.keys())[0]) self.failUnless(h == i, "hash Scanner base class expected %s, got %s" % (i, h)) diff --git a/src/engine/SCons/Scanner/__init__.py b/src/engine/SCons/Scanner/__init__.py index 3cfe4b7..dcee1f1 100644 --- a/src/engine/SCons/Scanner/__init__.py +++ b/src/engine/SCons/Scanner/__init__.py @@ -170,7 +170,7 @@ class Base: if skeys is _null: if SCons.Util.is_Dict(function): - skeys = function.keys() + skeys = list(function.keys()) else: skeys = [] self.skeys = skeys @@ -281,7 +281,7 @@ class Selector(Base): def __init__(self, dict, *args, **kw): Base.__init__(self, None, *args, **kw) self.dict = dict - self.skeys = dict.keys() + self.skeys = list(dict.keys()) def __call__(self, node, env, path = ()): return self.select(node)(node, env, path) diff --git a/src/engine/SCons/Script/SConsOptions.py b/src/engine/SCons/Script/SConsOptions.py index 246d4eb..7f78a71 100644 --- a/src/engine/SCons/Script/SConsOptions.py +++ b/src/engine/SCons/Script/SConsOptions.py @@ -604,7 +604,7 @@ def Parser(version): debug_options = ["count", "explain", "findlibs", "includes", "memoizer", "memory", "objects", "pdb", "presub", "stacktrace", - "time"] + deprecated_debug_options.keys() + "time"] + list(deprecated_debug_options.keys()) def opt_debug(option, opt, value, parser, debug_options=debug_options, diff --git a/src/engine/SCons/Tool/intelc.py b/src/engine/SCons/Tool/intelc.py index fffda70..9f782ee 100644 --- a/src/engine/SCons/Tool/intelc.py +++ b/src/engine/SCons/Tool/intelc.py @@ -69,7 +69,7 @@ def uniquify(s): u = {} for x in s: u[x] = 1 - return u.keys() + return list(u.keys()) def linux_ver_normalize(vstr): """Normalize a Linux compiler version number. @@ -118,7 +118,7 @@ def check_abi(abi): abi = valid_abis[abi] except KeyError: raise SCons.Errors.UserError("Intel compiler: Invalid ABI %s, valid values are %s"% \ - (abi, valid_abis.keys())) + (abi, list(valid_abis.keys()))) return abi def vercmp(a, b): diff --git a/src/engine/SCons/Tool/javac.py b/src/engine/SCons/Tool/javac.py index 6cc0779..6692a97 100644 --- a/src/engine/SCons/Tool/javac.py +++ b/src/engine/SCons/Tool/javac.py @@ -85,7 +85,7 @@ def emit_java_classes(target, source, env): find_java_files(result, dirpath, filenames) entry.walk(find_java_files, result) - slist.extend(result.keys()) + slist.extend(list(result.keys())) else: raise SCons.Errors.UserError("Java source must be File or Dir, not '%s'" % entry.__class__) diff --git a/src/engine/SCons/Tool/packaging/rpm.py b/src/engine/SCons/Tool/packaging/rpm.py index 7480542..d5c1c71 100644 --- a/src/engine/SCons/Tool/packaging/rpm.py +++ b/src/engine/SCons/Tool/packaging/rpm.py @@ -333,7 +333,7 @@ class SimpleTagCompiler: def strip_country_code(tag): return tag[:-2] - replacements = self.tagset.items() + replacements = list(self.tagset.items()) str = "" #domestic = [ (k,v) for k,v in replacements if not is_international(k) ] diff --git a/src/engine/SCons/Tool/textfile.py b/src/engine/SCons/Tool/textfile.py index 5733014..8dc8f4b 100644 --- a/src/engine/SCons/Tool/textfile.py +++ b/src/engine/SCons/Tool/textfile.py @@ -89,7 +89,7 @@ def _action(target, source, env): else: d = env['SUBST_DICT'] if is_Dict(d): - d = d.items() + d = list(d.items()) elif is_Sequence(d): pass else: diff --git a/src/engine/SCons/Util.py b/src/engine/SCons/Util.py index 1167f3a..d11d779 100644 --- a/src/engine/SCons/Util.py +++ b/src/engine/SCons/Util.py @@ -1085,7 +1085,7 @@ class OrderedDict(UserDict): return dict def items(self): - return list(zip(self._keys, self.values())) + return list(zip(self._keys, list(self.values()))) def keys(self): return self._keys[:] @@ -1212,7 +1212,7 @@ def unique(s): except TypeError: pass # move on to the next method else: - return u.keys() + return list(u.keys()) del u # We can't hash all the elements. Second fastest is to sort, diff --git a/src/engine/SCons/Variables/VariablesTests.py b/src/engine/SCons/Variables/VariablesTests.py index 4fa0879..6df1571 100644 --- a/src/engine/SCons/Variables/VariablesTests.py +++ b/src/engine/SCons/Variables/VariablesTests.py @@ -70,7 +70,7 @@ class VariablesTestCase(unittest.TestCase): "42", check, lambda x: int(x) + 12) - keys = opts.keys() + keys = list(opts.keys()) assert keys == ['VAR1', 'VAR2'], keys def test_Add(self): diff --git a/src/engine/SCons/compat/_scons_sets.py b/src/engine/SCons/compat/_scons_sets.py index 54450b3..0fde994 100644 --- a/src/engine/SCons/compat/_scons_sets.py +++ b/src/engine/SCons/compat/_scons_sets.py @@ -90,7 +90,7 @@ class BaseSet(object): __str__ = __repr__ def _repr(self, sort_them=False): - elements = self._data.keys() + elements = list(self._data.keys()) if sort_them: elements.sort() return '%s(%r)' % (self.__class__.__name__, elements) diff --git a/src/engine/SCons/dblite.py b/src/engine/SCons/dblite.py index 71aaff3..4f19ce6 100644 --- a/src/engine/SCons/dblite.py +++ b/src/engine/SCons/dblite.py @@ -151,7 +151,7 @@ class dblite: self._needs_sync = 0001 def keys(self): - return self._dict.keys() + return list(self._dict.keys()) def has_key(self, key): return key in self._dict diff --git a/test/ARGUMENTS.py b/test/ARGUMENTS.py index 801d83a..4bd2f78 100644 --- a/test/ARGUMENTS.py +++ b/test/ARGUMENTS.py @@ -30,7 +30,7 @@ test = TestSCons.TestSCons() test.write('SConstruct', """ foo = open('foo.out', 'wb') -for k in sorted(list(ARGUMENTS.keys())): +for k in sorted(ARGUMENTS.keys()): foo.write(k + " = " + ARGUMENTS[k] + "\\n") foo.close() """) diff --git a/test/LoadableModule.py b/test/LoadableModule.py index b28a565..40f9ce8 100644 --- a/test/LoadableModule.py +++ b/test/LoadableModule.py @@ -45,7 +45,7 @@ dlopen_line = { 'freebsd4' : no_dl_lib, 'linux2' : use_dl_lib, } -platforms_with_dlopen = dlopen_line.keys() +platforms_with_dlopen = list(dlopen_line.keys()) test.write('SConstruct', """ env = Environment() diff --git a/test/SConscript/variables.py b/test/SConscript/variables.py index 828a62c..0bb3cd0 100644 --- a/test/SConscript/variables.py +++ b/test/SConscript/variables.py @@ -44,7 +44,7 @@ assert y == 'zoom' test.write("SConstruct", """ x = 'x' y = 'zoom' -Export(globals().keys()) +Export(list(globals().keys())) SConscript('SConscript') """) @@ -54,7 +54,7 @@ test.run(arguments = ".") test.write("SConstruct", """ x = 'x' y = 'zoom' -SConscript('SConscript', globals().keys()) +SConscript('SConscript', list(globals().keys())) """) test.run(arguments = ".") diff --git a/test/scons-time/help/all-subcommands.py b/test/scons-time/help/all-subcommands.py index 8641d71..43db3ae 100644 --- a/test/scons-time/help/all-subcommands.py +++ b/test/scons-time/help/all-subcommands.py @@ -45,7 +45,7 @@ try: eval(c, globals) except: pass # Extract all subcommands from the the do_*() functions. -functions = globals['SConsTimer'].__dict__.keys() +functions = list(globals['SConsTimer'].__dict__.keys()) do_funcs = [x for x in functions if x[:3] == 'do_'] subcommands = [x[3:] for x in do_funcs] |