MCPcopy Create free account
hub / github.com/ipython/ipython / _ipython_dir_changed

Method _ipython_dir_changed

IPython/core/application.py:266–287  ·  view source on GitHub ↗
(self, change)

Source from the content-addressed store, hash-verified

264
265 @observe('ipython_dir')
266 def _ipython_dir_changed(self, change):
267 old = change['old']
268 new = change['new']
269 if old is not Undefined:
270 str_old = os.path.abspath(old)
271 if str_old in sys.path:
272 sys.path.remove(str_old)
273 str_path = os.path.abspath(new)
274 sys.path.append(str_path)
275 ensure_dir_exists(new)
276 readme = os.path.join(new, 'README')
277 readme_src = os.path.join(get_ipython_package_dir(), u'config', u'profile', 'README')
278 if not os.path.exists(readme) and os.path.exists(readme_src):
279 shutil.copy(readme_src, readme)
280 for d in ('extensions', 'nbextensions'):
281 path = os.path.join(new, d)
282 try:
283 ensure_dir_exists(path)
284 except OSError as e:
285 # this will not be EEXIST
286 self.log.error("couldn't create path %s: %s", path, e)
287 self.log.debug("IPYTHONDIR set to: %s" % new)
288
289 def load_config_file(self, suppress_errors=IPYTHON_SUPPRESS_CONFIG_ERRORS):
290 """Load the config file.

Callers 1

_ipython_dir_defaultMethod · 0.95

Calls 6

ensure_dir_existsFunction · 0.90
get_ipython_package_dirFunction · 0.90
errorMethod · 0.80
debugMethod · 0.80
removeMethod · 0.45
copyMethod · 0.45

Tested by

no test coverage detected