Show More
@@ -26,7 +26,7 b' from tornado import web' | |||||
26 |
|
26 | |||
27 | from IPython.config.configurable import LoggingConfigurable |
|
27 | from IPython.config.configurable import LoggingConfigurable | |
28 | from IPython.nbformat import current |
|
28 | from IPython.nbformat import current | |
29 | from IPython.utils.traitlets import Unicode, List, Dict, Bool |
|
29 | from IPython.utils.traitlets import Unicode, List, Dict, Bool, TraitError | |
30 |
|
30 | |||
31 | #----------------------------------------------------------------------------- |
|
31 | #----------------------------------------------------------------------------- | |
32 | # Classes |
|
32 | # Classes | |
@@ -37,6 +37,16 b' class NotebookManager(LoggingConfigurable):' | |||||
37 | notebook_dir = Unicode(os.getcwdu(), config=True, help=""" |
|
37 | notebook_dir = Unicode(os.getcwdu(), config=True, help=""" | |
38 | The directory to use for notebooks. |
|
38 | The directory to use for notebooks. | |
39 | """) |
|
39 | """) | |
|
40 | def _notebook_dir_changed(self, name, old, new): | |||
|
41 | """do a bit of validation of the notebook dir""" | |||
|
42 | if os.path.exists(new) and not os.path.isdir(new): | |||
|
43 | raise TraitError("notebook dir %r is not a directory" % new) | |||
|
44 | if not os.path.exists(new): | |||
|
45 | self.log.info("Creating notebook dir %s", new) | |||
|
46 | try: | |||
|
47 | os.mkdir(new) | |||
|
48 | except: | |||
|
49 | raise TraitError("Couldn't create notebook dir %r" % new) | |||
40 |
|
50 | |||
41 | save_script = Bool(False, config=True, |
|
51 | save_script = Bool(False, config=True, | |
42 | help="""Automatically create a Python script when saving the notebook. |
|
52 | help="""Automatically create a Python script when saving the notebook. |
General Comments 0
You need to be logged in to leave comments.
Login now