##// END OF EJS Templates
Small cleanups, no functional changes.
Fernando Perez -
Show More
@@ -68,9 +68,6 b' from IPython.utils.traitlets import (Int, Str, CBool, CaselessStrEnum, Enum,'
68 from IPython.utils.warn import warn, error, fatal
68 from IPython.utils.warn import warn, error, fatal
69 import IPython.core.hooks
69 import IPython.core.hooks
70
70
71 # from IPython.utils import growl
72 # growl.start("IPython")
73
74 #-----------------------------------------------------------------------------
71 #-----------------------------------------------------------------------------
75 # Globals
72 # Globals
76 #-----------------------------------------------------------------------------
73 #-----------------------------------------------------------------------------
@@ -287,7 +284,8 b' class InteractiveShell(Configurable, Magic):'
287 # Now make sure that the instance will also be returned by
284 # Now make sure that the instance will also be returned by
288 # the subclasses instance attribute.
285 # the subclasses instance attribute.
289 for subclass in cls.mro():
286 for subclass in cls.mro():
290 if issubclass(cls, subclass) and issubclass(subclass, InteractiveShell):
287 if issubclass(cls, subclass) and \
288 issubclass(subclass, InteractiveShell):
291 subclass._instance = inst
289 subclass._instance = inst
292 else:
290 else:
293 break
291 break
@@ -546,7 +544,8 b' class InteractiveShell(Configurable, Magic):'
546
544
547 dp = getattr(self.hooks, name, None)
545 dp = getattr(self.hooks, name, None)
548 if name not in IPython.core.hooks.__all__:
546 if name not in IPython.core.hooks.__all__:
549 print "Warning! Hook '%s' is not one of %s" % (name, IPython.core.hooks.__all__ )
547 print "Warning! Hook '%s' is not one of %s" % \
548 (name, IPython.core.hooks.__all__ )
550 if not dp:
549 if not dp:
551 dp = IPython.core.hooks.CommandChainDispatcher()
550 dp = IPython.core.hooks.CommandChainDispatcher()
552
551
@@ -725,7 +724,8 b' class InteractiveShell(Configurable, Magic):'
725 # These routines return properly built dicts as needed by the rest of
724 # These routines return properly built dicts as needed by the rest of
726 # the code, and can also be used by extension writers to generate
725 # the code, and can also be used by extension writers to generate
727 # properly initialized namespaces.
726 # properly initialized namespaces.
728 user_ns, user_global_ns = self.make_user_namespaces(user_ns, user_global_ns)
727 user_ns, user_global_ns = self.make_user_namespaces(user_ns,
728 user_global_ns)
729
729
730 # Assign namespaces
730 # Assign namespaces
731 # This is the namespace where all normal user variables live
731 # This is the namespace where all normal user variables live
@@ -956,13 +956,14 b' class InteractiveShell(Configurable, Magic):'
956 self.alias_manager.init_aliases()
956 self.alias_manager.init_aliases()
957
957
958 def reset_selective(self, regex=None):
958 def reset_selective(self, regex=None):
959 """Clear selective variables from internal namespaces based on a specified regular expression.
959 """Clear selective variables from internal namespaces based on a
960 specified regular expression.
960
961
961 Parameters
962 Parameters
962 ----------
963 ----------
963 regex : string or compiled pattern, optional
964 regex : string or compiled pattern, optional
964 A regular expression pattern that will be used in searching variable names in the users
965 A regular expression pattern that will be used in searching
965 namespaces.
966 variable names in the users namespaces.
966 """
967 """
967 if regex is not None:
968 if regex is not None:
968 try:
969 try:
@@ -982,12 +983,12 b' class InteractiveShell(Configurable, Magic):'
982 Parameters
983 Parameters
983 ----------
984 ----------
984 variables : dict, str or list/tuple of str
985 variables : dict, str or list/tuple of str
985 The variables to inject into the user's namespace. If a dict,
986 The variables to inject into the user's namespace. If a dict, a
986 a simple update is done. If a str, the string is assumed to
987 simple update is done. If a str, the string is assumed to have
987 have variable names separated by spaces. A list/tuple of str
988 variable names separated by spaces. A list/tuple of str can also
988 can also be used to give the variable names. If just the variable
989 be used to give the variable names. If just the variable names are
989 names are give (list/tuple/str) then the variable values looked
990 give (list/tuple/str) then the variable values looked up in the
990 up in the callers frame.
991 callers frame.
991 interactive : bool
992 interactive : bool
992 If True (default), the variables will be listed with the ``who``
993 If True (default), the variables will be listed with the ``who``
993 magic.
994 magic.
@@ -1286,7 +1287,8 b' class InteractiveShell(Configurable, Magic):'
1286 elif isinstance(index, tuple) and len(index) == 2:
1287 elif isinstance(index, tuple) and len(index) == 2:
1287 start=index[0]; stop=index[1]
1288 start=index[0]; stop=index[1]
1288 else:
1289 else:
1289 raise IndexError('Not a valid index for the input history: %r' % index)
1290 raise IndexError('Not a valid index for the input history: %r'
1291 % index)
1290 hist = {}
1292 hist = {}
1291 for i in range(start, stop):
1293 for i in range(start, stop):
1292 if output:
1294 if output:
@@ -1721,8 +1723,8 b' class InteractiveShell(Configurable, Magic):'
1721 def magic(self,arg_s):
1723 def magic(self,arg_s):
1722 """Call a magic function by name.
1724 """Call a magic function by name.
1723
1725
1724 Input: a string containing the name of the magic function to call and any
1726 Input: a string containing the name of the magic function to call and
1725 additional arguments to be passed to the magic.
1727 any additional arguments to be passed to the magic.
1726
1728
1727 magic('name -opt foo bar') is equivalent to typing at the ipython
1729 magic('name -opt foo bar') is equivalent to typing at the ipython
1728 prompt:
1730 prompt:
@@ -2052,9 +2054,9 b' class InteractiveShell(Configurable, Magic):'
2052 more = 0
2054 more = 0
2053 with nested(self.builtin_trap, self.display_trap):
2055 with nested(self.builtin_trap, self.display_trap):
2054 for line in lines:
2056 for line in lines:
2055 # skip blank lines so we don't mess up the prompt counter, but do
2057 # skip blank lines so we don't mess up the prompt counter, but
2056 # NOT skip even a blank line if we are in a code block (more is
2058 # do NOT skip even a blank line if we are in a code block (more
2057 # true)
2059 # is true)
2058
2060
2059 if line or more:
2061 if line or more:
2060 # push to raw history, so hist line numbers stay in sync
2062 # push to raw history, so hist line numbers stay in sync
@@ -2063,8 +2065,9 b' class InteractiveShell(Configurable, Magic):'
2063 more)
2065 more)
2064 more = self.push_line(prefiltered)
2066 more = self.push_line(prefiltered)
2065 # IPython's runsource returns None if there was an error
2067 # IPython's runsource returns None if there was an error
2066 # compiling the code. This allows us to stop processing right
2068 # compiling the code. This allows us to stop processing
2067 # away, so the user gets the error message at the right place.
2069 # right away, so the user gets the error message at the
2070 # right place.
2068 if more is None:
2071 if more is None:
2069 break
2072 break
2070 else:
2073 else:
General Comments 0
You need to be logged in to leave comments. Login now