(self, change)
| 292 | |
| 293 | @observe('ipython_dir') |
| 294 | def _ipython_dir_changed(self, change): |
| 295 | old = change['old'] |
| 296 | new = change['new'] |
| 297 | if old is not Undefined: |
| 298 | str_old = os.path.abspath(old) |
| 299 | if str_old in sys.path: |
| 300 | sys.path.remove(str_old) |
| 301 | if self.add_ipython_dir_to_sys_path: |
| 302 | str_path = os.path.abspath(new) |
| 303 | sys.path.append(str_path) |
| 304 | ensure_dir_exists(new) |
| 305 | readme = os.path.join(new, "README") |
| 306 | readme_src = os.path.join( |
| 307 | get_ipython_package_dir(), "config", "profile", "README" |
| 308 | ) |
| 309 | if not os.path.exists(readme) and os.path.exists(readme_src): |
| 310 | shutil.copy(readme_src, readme) |
| 311 | for d in ("extensions", "nbextensions"): |
| 312 | path = os.path.join(new, d) |
| 313 | try: |
| 314 | ensure_dir_exists(path) |
| 315 | except OSError as e: |
| 316 | # this will not be EEXIST |
| 317 | self.log.error("couldn't create path %s: %s", path, e) |
| 318 | self.log.debug("IPYTHONDIR set to: %s", new) |
| 319 | |
| 320 | def load_config_file(self, suppress_errors=IPYTHON_SUPPRESS_CONFIG_ERRORS): |
| 321 | """Load the config file. |
no test coverage detected