Permalink
Browse files

2to3: dict fixer

  • Loading branch information...
1 parent 68e9a0b commit 29da19d1e9aa95b8551827c800c4fd0fb2b3e540 @bfroehle committed Sep 27, 2012
Showing with 222 additions and 222 deletions.
  1. +1 −1 IPython/__init__.py
  2. +7 −7 IPython/config/application.py
  3. +3 −3 IPython/config/configurable.py
  4. +7 −7 IPython/config/loader.py
  5. +3 −3 IPython/config/tests/test_loader.py
  6. +1 −1 IPython/core/alias.py
  7. +2 −2 IPython/core/builtin_trap.py
  8. +4 −4 IPython/core/completer.py
  9. +2 −2 IPython/core/completerlib.py
  10. +2 −2 IPython/core/formatters.py
  11. +6 −6 IPython/core/interactiveshell.py
  12. +3 −3 IPython/core/magic.py
  13. +1 −1 IPython/core/magics/basic.py
  14. +1 −1 IPython/core/magics/osm.py
  15. +1 −1 IPython/core/oinspect.py
  16. +1 −1 IPython/core/profileapp.py
  17. +1 −1 IPython/core/prompts.py
  18. +1 −1 IPython/core/pylabtools.py
  19. +5 −5 IPython/core/tests/test_inputsplitter.py
  20. +1 −1 IPython/core/tests/test_magic.py
  21. +1 −1 IPython/deathrow/gui/wx/ipython_history.py
  22. +2 −2 IPython/deathrow/gui/wx/ipython_view.py
  23. +1 −1 IPython/deathrow/gui/wx/thread_ex.py
  24. +3 −3 IPython/deathrow/ibrowse.py
  25. +7 −7 IPython/deathrow/ipipe.py
  26. +1 −1 IPython/deathrow/ipy_vimserver.py
  27. +3 −3 IPython/deathrow/oldfrontend/cocoa/cocoa_frontend.py
  28. +1 −1 IPython/deathrow/oldfrontend/process/winprocess.py
  29. +7 −7 IPython/extensions/autoreload.py
  30. +1 −1 IPython/extensions/cythonmagic.py
  31. +1 −1 IPython/extensions/rmagic.py
  32. +1 −1 IPython/extensions/storemagic.py
  33. +1 −1 IPython/external/argparse/_argparse.py
  34. +2 −2 IPython/external/pexpect/_pexpect.py
  35. +1 −1 IPython/frontend/html/notebook/azurenbmanager.py
  36. +1 −1 IPython/frontend/html/notebook/clustermanager.py
  37. +2 −2 IPython/frontend/html/notebook/kernelmanager.py
  38. +1 −1 IPython/frontend/qt/console/console_widget.py
  39. +1 −1 IPython/frontend/qt/console/mainwindow.py
  40. +2 −2 IPython/frontend/qt/console/pygments_highlighter.py
  41. +1 −1 IPython/frontend/qt/util.py
  42. +1 −1 IPython/lib/inputhook.py
  43. +1 −1 IPython/lib/pretty.py
  44. +1 −1 IPython/nbformat/v1/nbbase.py
  45. +1 −1 IPython/nbformat/v2/nbbase.py
  46. +1 −1 IPython/nbformat/v3/nbbase.py
  47. +1 −1 IPython/nbformat/v3/tests/test_nbpy.py
  48. +1 −1 IPython/parallel/apps/ipclusterapp.py
  49. +5 −5 IPython/parallel/apps/launcher.py
  50. +1 −1 IPython/parallel/apps/winhpcjob.py
  51. +6 −6 IPython/parallel/client/client.py
  52. +2 −2 IPython/parallel/client/view.py
  53. +5 −5 IPython/parallel/controller/dictdb.py
  54. +8 −8 IPython/parallel/controller/hub.py
  55. +4 −4 IPython/parallel/controller/scheduler.py
  56. +2 −2 IPython/parallel/controller/sqlitedb.py
  57. +1 −1 IPython/parallel/error.py
  58. +1 −1 IPython/parallel/tests/test_asyncresult.py
  59. +4 −4 IPython/parallel/tests/test_client.py
  60. +3 −3 IPython/parallel/tests/test_db.py
  61. +1 −1 IPython/parallel/tests/test_newserialized.py
  62. +4 −4 IPython/parallel/util.py
  63. +2 −2 IPython/quarantine/envpersist.py
  64. +1 −1 IPython/quarantine/ipy_exportdb.py
  65. +1 −1 IPython/quarantine/ipy_extutil.py
  66. +1 −1 IPython/quarantine/ipy_lookfor.py
  67. +1 −1 IPython/quarantine/ipy_which.py
  68. +1 −1 IPython/testing/iptest.py
  69. +1 −1 IPython/testing/ipunittest.py
  70. +2 −2 IPython/testing/plugin/ipdoctest.py
  71. +1 −1 IPython/utils/autoattr.py
  72. +2 −2 IPython/utils/coloransi.py
  73. +3 −3 IPython/utils/io.py
  74. +4 −4 IPython/utils/ipstruct.py
  75. +4 −4 IPython/utils/jsonutil.py
  76. +5 −5 IPython/utils/pickleutil.py
  77. +1 −1 IPython/utils/strdispatch.py
  78. +3 −3 IPython/utils/tests/test_jsonutil.py
  79. +1 −1 IPython/utils/tests/test_path.py
  80. +4 −4 IPython/utils/tests/test_traitlets.py
  81. +10 −10 IPython/utils/tests/test_wildcard.py
  82. +11 −11 IPython/utils/traitlets.py
  83. +3 −3 IPython/utils/wildcard.py
  84. +1 −1 IPython/zmq/datapub.py
  85. +1 −1 IPython/zmq/ipkernel.py
  86. +1 −1 IPython/zmq/kernelmanager.py
  87. +2 −2 IPython/zmq/serialize.py
  88. +3 −3 IPython/zmq/session.py
  89. +2 −2 IPython/zmq/tests/test_message_spec.py
  90. +2 −2 IPython/zmq/tests/test_serialize.py
View
@@ -53,7 +53,7 @@
# Release data
__author__ = ''
-for author, email in release.authors.itervalues():
+for author, email in release.authors.values():
__author__ += author + ' <' + email + '>\n'
__license__ = release.license
__version__ = release.version
@@ -167,7 +167,7 @@ def _log_default(self):
flags = Dict()
def _flags_changed(self, name, old, new):
"""ensure flags dict is valid"""
- for key,value in new.iteritems():
+ for key,value in new.items():
assert len(value) == 2, "Bad flag: %r:%s"%(key,value)
assert isinstance(value[0], (dict, Config)), "Bad flag: %r:%s"%(key,value)
assert isinstance(value[1], basestring), "Bad flag: %r:%s"%(key,value)
@@ -227,7 +227,7 @@ def print_alias_help(self):
for c in cls.mro()[:-3]:
classdict[c.__name__] = c
- for alias, longname in self.aliases.iteritems():
+ for alias, longname in self.aliases.items():
classname, traitname = longname.split('.',1)
cls = classdict[classname]
@@ -247,7 +247,7 @@ def print_flag_help(self):
return
lines = []
- for m, (cfg,help) in self.flags.iteritems():
+ for m, (cfg,help) in self.flags.items():
prefix = '--' if len(m) > 1 else '-'
lines.append(prefix+m)
lines.append(indent(dedent(help.strip())))
@@ -279,7 +279,7 @@ def print_subcommands(self):
for p in wrap_paragraphs(self.subcommand_description):
lines.append(p)
lines.append('')
- for subc, (cls, help) in self.subcommands.iteritems():
+ for subc, (cls, help) in self.subcommands.items():
lines.append(subc)
if help:
lines.append(indent(dedent(help.strip())))
@@ -381,7 +381,7 @@ def flatten_flags(self):
# flatten aliases, which have the form:
# { 'alias' : 'Class.trait' }
aliases = {}
- for alias, cls_trait in self.aliases.iteritems():
+ for alias, cls_trait in self.aliases.items():
cls,trait = cls_trait.split('.',1)
children = mro_tree[cls]
if len(children) == 1:
@@ -392,9 +392,9 @@ def flatten_flags(self):
# flatten flags, which are of the form:
# { 'key' : ({'Cls' : {'trait' : value}}, 'help')}
flags = {}
- for key, (flagdict, help) in self.flags.iteritems():
+ for key, (flagdict, help) in self.flags.items():
newflag = {}
- for cls, subdict in flagdict.iteritems():
+ for cls, subdict in flagdict.items():
children = mro_tree[cls]
# exactly one descendent, promote flag section
if len(children) == 1:
@@ -113,7 +113,7 @@ def _config_changed(self, name, old, new):
# dynamically create the section with name self.__class__.__name__.
if new._has_section(sname):
my_config = new[sname]
- for k, v in traits.iteritems():
+ for k, v in traits.items():
# Don't allow traitlets with config=True to start with
# uppercase. Otherwise, they are confused with Config
# subsections. But, developers shouldn't have uppercase
@@ -160,7 +160,7 @@ class defaults.
final_help = []
final_help.append(u'%s options' % cls.__name__)
final_help.append(len(final_help[0])*u'-')
- for k,v in sorted(cls.class_traits(config=True).iteritems()):
+ for k,v in sorted(cls.class_traits(config=True).items()):
help = cls.class_get_trait_help(v, inst)
final_help.append(help)
return '\n'.join(final_help)
@@ -240,7 +240,7 @@ def c(s):
lines.append(c('%s will inherit config from: %s'%(cls.__name__, pstr)))
lines.append('')
- for name,trait in cls.class_traits(config=True).iteritems():
+ for name,trait in cls.class_traits(config=True).items():
help = trait.get_metadata('help') or ''
lines.append(c(help))
lines.append('# c.%s.%s = %r'%(cls.__name__, name, trait.get_default_value()))
@@ -85,7 +85,7 @@ def __init__(self, *args, **kwds):
def _merge(self, other):
to_update = {}
- for k, v in other.iteritems():
+ for k, v in other.items():
if k not in self:
to_update[k] = v
else: # I have this key
@@ -126,7 +126,7 @@ def __copy__(self):
def __deepcopy__(self, memo):
import copy
- return type(self)(copy.deepcopy(self.items()))
+ return type(self)(copy.deepcopy(list(self.items())))
def __getitem__(self, key):
# We cannot use directly self._is_section_key, because it triggers
@@ -362,7 +362,7 @@ def _load_flag(self, cfg):
if isinstance(cfg, (dict, Config)):
# don't clobber whole config sections, update
# each section from config:
- for sec,c in cfg.iteritems():
+ for sec,c in cfg.items():
self.config[sec].update(c)
else:
raise TypeError("Invalid flag: %r" % cfg)
@@ -612,7 +612,7 @@ def _parse_args(self, args):
def _convert_to_config(self):
"""self.parsed_data->self.config"""
- for k, v in vars(self.parsed_data).iteritems():
+ for k, v in vars(self.parsed_data).items():
py3compat.exec_("self.config.%s = v"%k, locals(), globals())
class KVArgParseConfigLoader(ArgParseConfigLoader):
@@ -629,7 +629,7 @@ def _add_arguments(self, aliases=None, flags=None):
if flags is None:
flags = self.flags
paa = self.parser.add_argument
- for key,value in aliases.iteritems():
+ for key,value in aliases.items():
if key in flags:
# flags
nargs = '?'
@@ -639,7 +639,7 @@ def _add_arguments(self, aliases=None, flags=None):
paa('-'+key, '--'+key, type=unicode, dest=value, nargs=nargs)
else:
paa('--'+key, type=unicode, dest=value, nargs=nargs)
- for key, (value, help) in flags.iteritems():
+ for key, (value, help) in flags.items():
if key in self.aliases:
#
self.alias_flags[self.aliases[key]] = value
@@ -658,7 +658,7 @@ def _convert_to_config(self):
else:
subcs = []
- for k, v in vars(self.parsed_data).iteritems():
+ for k, v in vars(self.parsed_data).items():
if v is None:
# it was a flag that shares the name of an alias
subcs.append(self.alias_flags[k])
@@ -96,8 +96,8 @@ def test_basic(self):
self.assertEqual(config.n, True)
self.assertEqual(config.Global.bam, 'wow')
config = cl.load_config(['wow'])
- self.assertEqual(config.keys(), ['Global'])
- self.assertEqual(config.Global.keys(), ['bam'])
+ self.assertEqual(list(config.keys()), ['Global'])
+ self.assertEqual(list(config.Global.keys()), ['bam'])
self.assertEqual(config.Global.bam, 'wow')
def test_add_arguments(self):
@@ -216,7 +216,7 @@ def test_auto_section(self):
self.assertEqual(c._has_section('A'), True)
self.assertEqual(c.A.foo, 'hi there')
del c.A
- self.assertEqual(len(c.A.keys()),0)
+ self.assertEqual(len(list(c.A.keys())),0)
def test_merge_doesnt_exist(self):
c1 = Config()
@@ -130,7 +130,7 @@ def __contains__(self, name):
@property
def aliases(self):
- return [(item[0], item[1][1]) for item in self.alias_table.iteritems()]
+ return [(item[0], item[1][1]) for item in self.alias_table.items()]
def exclude_aliases(self):
# set of things NOT to alias (keywords, builtins and some magics)
@@ -103,14 +103,14 @@ def activate(self):
"""Store ipython references in the builtin_mod namespace."""
add_builtin = self.add_builtin
- for name, func in self.auto_builtins.iteritems():
+ for name, func in self.auto_builtins.items():
add_builtin(name, func)
def deactivate(self):
"""Remove any builtins which might have been added by add_builtins, or
restore overwritten ones to their previous values."""
remove_builtin = self.remove_builtin
- for key, val in self._orig_builtins.iteritems():
+ for key, val in self._orig_builtins.items():
remove_builtin(key, val)
self._orig_builtins.clear()
self._builtins_added = False
@@ -319,9 +319,9 @@ def global_matches(self, text):
match_append = matches.append
n = len(text)
for lst in [keyword.kwlist,
- builtin_mod.__dict__.keys(),
- self.namespace.keys(),
- self.global_namespace.keys()]:
+ list(builtin_mod.__dict__.keys()),
+ list(self.namespace.keys()),
+ list(self.global_namespace.keys())]:
for word in lst:
if word[:n] == text and word != "__builtins__":
match_append(word)
@@ -637,7 +637,7 @@ def alias_matches(self, text):
if ' ' in main_text and not main_text.startswith('sudo'):
return []
text = os.path.expanduser(text)
- aliases = self.alias_table.keys()
+ aliases = list(self.alias_table.keys())
if text == '':
return aliases
else:
@@ -280,7 +280,7 @@ def cd_completer(self, event):
# return only bookmark completions
bkms = self.db.get('bookmarks', None)
if bkms:
- return bkms.keys()
+ return list(bkms.keys())
else:
return []
@@ -315,7 +315,7 @@ def cd_completer(self, event):
return [compress_user(relpath, tilde_expand, tilde_val)]
# if no completions so far, try bookmarks
- bks = self.db.get('bookmarks',{}).iterkeys()
+ bks = iter(self.db.get('bookmarks',{}).keys())
bkmatches = [s for s in bks if s.startswith(event.symbol)]
if bkmatches:
return bkmatches
@@ -118,7 +118,7 @@ def format(self, obj, include=None, exclude=None):
format_dict['text/plain'] = data
return format_dict
- for format_type, formatter in self.formatters.items():
+ for format_type, formatter in list(self.formatters.items()):
if include is not None:
if format_type not in include:
continue
@@ -137,7 +137,7 @@ def format(self, obj, include=None, exclude=None):
@property
def format_types(self):
"""Return the format types (MIME types) of the active formatters."""
- return self.formatters.keys()
+ return list(self.formatters.keys())
#-----------------------------------------------------------------------------
@@ -743,7 +743,7 @@ def save_sys_module_state(self):
def restore_sys_module_state(self):
"""Restore the state of the sys module."""
try:
- for k, v in self._orig_sys_module_state.iteritems():
+ for k, v in self._orig_sys_module_state.items():
setattr(sys, k, v)
except AttributeError:
pass
@@ -1175,7 +1175,7 @@ def all_ns_refs(self):
Note that this does not include the displayhook, which also caches
objects from the output."""
return [self.user_ns, self.user_global_ns,
- self._user_main_module.__dict__] + self._main_ns_cache.values()
+ self._user_main_module.__dict__] + list(self._main_ns_cache.values())
def reset(self, new_session=True):
"""Clear all internal namespaces, and attempt to release references to
@@ -1255,7 +1255,7 @@ def del_var(self, varname, by_name=False):
# Also check in output history
ns_refs.append(self.history_manager.output_hist)
for ns in ns_refs:
- to_delete = [n for n, o in ns.iteritems() if o is obj]
+ to_delete = [n for n, o in ns.items() if o is obj]
for name in to_delete:
del ns[name]
@@ -1346,7 +1346,7 @@ def drop_by_id(self, variables):
variables : dict
A dictionary mapping object names (as strings) to the objects.
"""
- for name, obj in variables.iteritems():
+ for name, obj in variables.items():
if name in self.user_ns and self.user_ns[name] is obj:
del self.user_ns[name]
self.user_ns_hidden.discard(name)
@@ -2395,7 +2395,7 @@ def user_expressions(self, expressions):
out = {}
user_ns = self.user_ns
global_ns = self.user_global_ns
- for key, expr in expressions.iteritems():
+ for key, expr in expressions.items():
try:
value = repr(eval(expr, global_ns, user_ns))
except:
@@ -2636,7 +2636,7 @@ def run_cell(self, raw_cell, store_history=False, silent=False):
# Execute any registered post-execution functions.
# unless we are silent
- post_exec = [] if silent else self._post_execute.iteritems()
+ post_exec = [] if silent else iter(self._post_execute.items())
for func, status in post_exec:
if self.disable_failing_post_execute and not status:
@@ -327,7 +327,7 @@ def auto_status(self):
def lsmagic_info(self):
magic_list = []
for m_type in self.magics :
- for m_name,mgc in self.magics[m_type].items():
+ for m_name,mgc in list(self.magics[m_type].items()):
try :
magic_list.append({'name':m_name,'type':m_type,'class':mgc.im_class.__name__})
except AttributeError :
@@ -355,7 +355,7 @@ def lsmagic_docs(self, brief=False, missing=''):
docs = {}
for m_type in self.magics:
m_docs = {}
- for m_name, m_func in self.magics[m_type].iteritems():
+ for m_name, m_func in self.magics[m_type].items():
if m_func.__doc__:
if brief:
m_docs[m_name] = m_func.__doc__.split('\n', 1)[0]
@@ -531,7 +531,7 @@ def __init__(self, shell):
for mtype in magic_kinds:
tab = self.magics[mtype] = {}
cls_tab = class_magics[mtype]
- for magic_name, meth_name in cls_tab.iteritems():
+ for magic_name, meth_name in cls_tab.items():
if isinstance(meth_name, basestring):
# it's a method name, grab it
tab[magic_name] = getattr(self, meth_name)
@@ -87,7 +87,7 @@ def alias_magic(self, line=''):
args = magic_arguments.parse_argstring(self.alias_magic, line)
shell = self.shell
mman = self.shell.magics_manager
- escs = ''.join(magic_escapes.values())
+ escs = ''.join(list(magic_escapes.values()))
target = args.target.lstrip(escs)
name = args.name.lstrip(escs)
@@ -648,7 +648,7 @@ def bookmark(self, parameter_s=''):
elif 'r' in opts:
bkms = {}
elif 'l' in opts:
- bks = bkms.keys()
+ bks = list(bkms.keys())
bks.sort()
if bks:
size = max(map(len, bks))
@@ -855,7 +855,7 @@ def psearch(self,pattern,ns_table,ns_search=[],
for name in ns_search:
if name not in ns_table:
raise ValueError('invalid namespace <%s>. Valid names: %s' %
- (name,ns_table.keys()))
+ (name,list(ns_table.keys())))
#print 'type_pattern:',type_pattern # dbg
search_result, namespaces_seen = set(), set()
@@ -297,7 +297,7 @@ class ProfileApp(Application):
def start(self):
if self.subapp is None:
- print("No subcommand specified. Must specify one of: %s"%(self.subcommands.keys()))
+ print("No subcommand specified. Must specify one of: %s"%(list(self.subcommands.keys())))
print()
self.print_description()
self.print_subcommands()
@@ -111,7 +111,7 @@ def multiple_replace(dict, text):
# http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/81330
# Create a regular expression from the dictionary keys
- regex = re.compile("(%s)" % "|".join(map(re.escape, dict.keys())))
+ regex = re.compile("(%s)" % "|".join(map(re.escape, list(dict.keys()))))
# For each match, look-up corresponding value in dictionary
return regex.sub(lambda mo: dict[mo.string[mo.start():mo.end()]], text)
@@ -39,7 +39,7 @@
# GUI support to activate based on the desired matplotlib backend. For the
# most part it's just a reverse of the above dict, but we also need to add a
# few others that map to the same GUI manually:
-backend2gui = dict(zip(backends.values(), backends.keys()))
+backend2gui = dict(zip(list(backends.values()), list(backends.keys())))
# In the reverse mapping, there are a few extra valid matplotlib backends that
# map to the same GUI support
backend2gui['GTK'] = backend2gui['GTKCairo'] = 'gtk'
Oops, something went wrong. Retry.

0 comments on commit 29da19d

Please sign in to comment.