##// END OF EJS Templates
Change functions,...
Srinivas Reddy Thatiparthy -
Show More
@@ -20,7 +20,7 b' Authors:'
20 20
21 21 from traitlets.config.configurable import Configurable
22 22
23 from IPython.utils.py3compat import builtin_mod, iteritems
23 from IPython.utils.py3compat import builtin_mod
24 24 from traitlets import Instance
25 25
26 26 #-----------------------------------------------------------------------------
@@ -90,14 +90,14 b' class BuiltinTrap(Configurable):'
90 90 """Store ipython references in the __builtin__ namespace."""
91 91
92 92 add_builtin = self.add_builtin
93 for name, func in iteritems(self.auto_builtins):
93 for name, func in self.auto_builtins.items():
94 94 add_builtin(name, func)
95 95
96 96 def deactivate(self):
97 97 """Remove any builtins which might have been added by add_builtins, or
98 98 restore overwritten ones to their previous values."""
99 99 remove_builtin = self.remove_builtin
100 for key, val in iteritems(self._orig_builtins):
100 for key, val in self._orig_builtins.items():
101 101 remove_builtin(key, val)
102 102 self._orig_builtins.clear()
103 103 self._builtins_added = False
@@ -68,7 +68,7 b' from IPython.paths import get_ipython_dir'
68 68 from IPython.utils.path import get_home_dir, get_py_filename, ensure_dir_exists
69 69 from IPython.utils.process import system, getoutput
70 70 from IPython.utils.py3compat import (builtin_mod, unicode_type, string_types,
71 with_metaclass, iteritems)
71 with_metaclass)
72 72 from IPython.utils.strdispatch import StrDispatch
73 73 from IPython.utils.syspathcontext import prepended_to_syspath
74 74 from IPython.utils.text import format_screen, LSString, SList, DollarFormatter
@@ -733,7 +733,7 b' class InteractiveShell(SingletonConfigurable):'
733 733 def restore_sys_module_state(self):
734 734 """Restore the state of the sys module."""
735 735 try:
736 for k, v in iteritems(self._orig_sys_module_state):
736 for k, v in self._orig_sys_module_state.items():
737 737 setattr(sys, k, v)
738 738 except AttributeError:
739 739 pass
@@ -1255,7 +1255,7 b' class InteractiveShell(SingletonConfigurable):'
1255 1255 # Also check in output history
1256 1256 ns_refs.append(self.history_manager.output_hist)
1257 1257 for ns in ns_refs:
1258 to_delete = [n for n, o in iteritems(ns) if o is obj]
1258 to_delete = [n for n, o in ns.items() if o is obj]
1259 1259 for name in to_delete:
1260 1260 del ns[name]
1261 1261
@@ -1347,7 +1347,7 b' class InteractiveShell(SingletonConfigurable):'
1347 1347 variables : dict
1348 1348 A dictionary mapping object names (as strings) to the objects.
1349 1349 """
1350 for name, obj in iteritems(variables):
1350 for name, obj in variables.items():
1351 1351 if name in self.user_ns and self.user_ns[name] is obj:
1352 1352 del self.user_ns[name]
1353 1353 self.user_ns_hidden.pop(name, None)
@@ -2382,7 +2382,7 b' class InteractiveShell(SingletonConfigurable):'
2382 2382 user_ns = self.user_ns
2383 2383 global_ns = self.user_global_ns
2384 2384
2385 for key, expr in iteritems(expressions):
2385 for key, expr in expressions.items():
2386 2386 try:
2387 2387 value = self._format_user_obj(eval(expr, global_ns, user_ns))
2388 2388 except:
@@ -24,7 +24,7 b' from IPython.core.inputsplitter import ESC_MAGIC, ESC_MAGIC2'
24 24 from decorator import decorator
25 25 from IPython.utils.ipstruct import Struct
26 26 from IPython.utils.process import arg_split
27 from IPython.utils.py3compat import string_types, iteritems
27 from IPython.utils.py3compat import string_types
28 28 from IPython.utils.text import dedent
29 29 from traitlets import Bool, Dict, Instance, observe
30 30 from logging import error
@@ -344,7 +344,7 b' class MagicsManager(Configurable):'
344 344 docs = {}
345 345 for m_type in self.magics:
346 346 m_docs = {}
347 for m_name, m_func in iteritems(self.magics[m_type]):
347 for m_name, m_func in self.magics[m_type].items():
348 348 if m_func.__doc__:
349 349 if brief:
350 350 m_docs[m_name] = m_func.__doc__.split('\n', 1)[0]
@@ -510,7 +510,7 b' class Magics(Configurable):'
510 510 for mtype in magic_kinds:
511 511 tab = self.magics[mtype] = {}
512 512 cls_tab = class_magics[mtype]
513 for magic_name, meth_name in iteritems(cls_tab):
513 for magic_name, meth_name in cls_tab.items():
514 514 if isinstance(meth_name, string_types):
515 515 # it's a method name, grab it
516 516 tab[magic_name] = getattr(self, meth_name)
@@ -36,7 +36,7 b' from IPython.core.magic import (Magics, magics_class, line_magic, cell_magic,'
36 36 line_cell_magic, on_off, needs_local_scope)
37 37 from IPython.testing.skipdoctest import skip_doctest
38 38 from IPython.utils import py3compat
39 from IPython.utils.py3compat import builtin_mod, iteritems, PY3
39 from IPython.utils.py3compat import builtin_mod, PY3
40 40 from IPython.utils.contexts import preserve_keys
41 41 from IPython.utils.capture import capture_output
42 42 from IPython.utils.ipstruct import Struct
@@ -1271,8 +1271,7 b' python-profiler package from non-free.""")'
1271 1271 """
1272 1272 opts,args = self.parse_options(parameter_s,'rq',mode='list')
1273 1273 if not args: # List existing macros
1274 return sorted(k for k,v in iteritems(self.shell.user_ns) if\
1275 isinstance(v, Macro))
1274 return sorted(k for k,v in self.shell.user_ns.items() if isinstance(v, Macro))
1276 1275 if len(args) == 1:
1277 1276 raise UsageError(
1278 1277 "%macro insufficient args; usage '%macro name n1-n2 n3-4...")
@@ -771,7 +771,6 b' except AttributeError: # Python 3'
771 771 _type_pprinters[slice] = _repr_pprint
772 772
773 773 try:
774 _type_pprinters[xrange] = _repr_pprint
775 774 _type_pprinters[long] = _repr_pprint
776 775 _type_pprinters[unicode] = _repr_pprint
777 776 except NameError:
@@ -9,7 +9,6 b''
9 9 # the file COPYING, distributed as part of this software.
10 10 #-----------------------------------------------------------------------------
11 11
12 from .py3compat import xrange
13 12
14 13 def uniq_stable(elems):
15 14 """uniq_stable(elems) -> list
@@ -32,6 +31,6 b' def flatten(seq):'
32 31
33 32 def chop(seq, size):
34 33 """Chop a sequence into chunks of the given size."""
35 return [seq[i:i+size] for i in xrange(0,len(seq),size)]
34 return [seq[i:i+size] for i in range(0,len(seq),size)]
36 35
37 36
@@ -619,10 +619,10 b' def _col_chunks(l, max_rows, row_first=False):'
619 619 """Yield successive max_rows-sized column chunks from l."""
620 620 if row_first:
621 621 ncols = (len(l) // max_rows) + (len(l) % max_rows > 0)
622 for i in py3compat.xrange(ncols):
623 yield [l[j] for j in py3compat.xrange(i, len(l), ncols)]
622 for i in range(ncols):
623 yield [l[j] for j in range(i, len(l), ncols)]
624 624 else:
625 for i in py3compat.xrange(0, len(l), max_rows):
625 for i in range(0, len(l), max_rows):
626 626 yield l[i:(i + max_rows)]
627 627
628 628
@@ -16,8 +16,6 b' Utilities for timing code execution.'
16 16
17 17 import time
18 18
19 from .py3compat import xrange
20
21 19 #-----------------------------------------------------------------------------
22 20 # Code
23 21 #-----------------------------------------------------------------------------
@@ -89,7 +87,7 b' def timings_out(reps,func,*args,**kw):'
89 87 out = func(*args,**kw)
90 88 tot_time = clock()-start
91 89 else:
92 rng = xrange(reps-1) # the last time is executed separately to store output
90 rng = range(reps-1) # the last time is executed separately to store output
93 91 start = clock()
94 92 for dummy in rng: func(*args,**kw)
95 93 out = func(*args,**kw) # one last time
@@ -18,7 +18,6 b' import re'
18 18 import types
19 19
20 20 from IPython.utils.dir2 import dir2
21 from .py3compat import iteritems
22 21
23 22 def create_typestr2type_dicts(dont_include_in_type2typestr=["lambda"]):
24 23 """Return dictionaries mapping lower case typename (e.g. 'tuple') to type
@@ -83,7 +82,7 b' def filter_ns(ns, name_pattern="*", type_pattern="all", ignore_case=True,'
83 82 reg = re.compile(pattern+"$")
84 83
85 84 # Check each one matches regex; shouldn't be hidden; of correct type.
86 return dict((key,obj) for key, obj in iteritems(ns) if reg.match(key) \
85 return dict((key,obj) for key, obj in ns.items() if reg.match(key) \
87 86 and show_hidden(key, show_all) \
88 87 and is_type(obj, type_pattern) )
89 88
@@ -103,10 +102,10 b' def list_namespace(namespace, type_pattern, filter, ignore_case=False, show_all='
103 102 type_pattern="all",
104 103 ignore_case=ignore_case, show_all=show_all)
105 104 results = {}
106 for name, obj in iteritems(filtered):
105 for name, obj in filtered.items():
107 106 ns = list_namespace(dict_dir(obj), type_pattern,
108 107 ".".join(pattern_list[1:]),
109 108 ignore_case=ignore_case, show_all=show_all)
110 for inner_name, inner_obj in iteritems(ns):
109 for inner_name, inner_obj in ns.items():
111 110 results["%s.%s"%(name,inner_name)] = inner_obj
112 111 return results
General Comments 0
You need to be logged in to leave comments. Login now