##// END OF EJS Templates
ipapi.get() only returns dummy obj when asked for
vivainio -
Show More
@@ -103,18 +103,22 b' class IPythonNotRunning:'
103 """Dummy function, which doesn't do anything but warn."""
103 """Dummy function, which doesn't do anything but warn."""
104 warn("IPython is not running, this is a dummy no-op function")
104 warn("IPython is not running, this is a dummy no-op function")
105
105
106 _recent = IPythonNotRunning()
106 _recent = None
107
107
108 def get():
108
109 def get(allow_dummy=False):
109 """Get an IPApi object.
110 """Get an IPApi object.
110
111
111 Returns an instance of IPythonNotRunning if not running under IPython.
112 If allow_dummy is true, returns an instance of IPythonNotRunning
113 instead of None if not running under IPython.
112
114
113 Running this should be the first thing you do when writing extensions that
115 Running this should be the first thing you do when writing extensions that
114 can be imported as normal modules. You can then direct all the
116 can be imported as normal modules. You can then direct all the
115 configuration operations against the returned object.
117 configuration operations against the returned object.
116 """
118 """
117
119 global _recent
120 if allow_dummy and not _recent:
121 _recent = IPythonNotRunning()
118 return _recent
122 return _recent
119
123
120 class IPApi:
124 class IPApi:
General Comments 0
You need to be logged in to leave comments. Login now