##// END OF EJS Templates
cleaning up named_notebook_path
Paul Ivanov -
Show More
@@ -41,15 +41,29 b' class NotebookManager(LoggingConfigurable):'
41 notebook_dir = Unicode(os.getcwdu(), config=True, help="""
41 notebook_dir = Unicode(os.getcwdu(), config=True, help="""
42 The directory to use for notebooks.
42 The directory to use for notebooks.
43 """)
43 """)
44
44
45 def named_notebook_path(self, notebook_path):
45 def named_notebook_path(self, notebook_path):
46
46 """Given a notebook_path name, returns a (name, path) tuple, where
47 name is a .ipynb file, and path is the directory for the file.
48
49 Parameters
50 ----------
51 notebook_path : string
52 A path that may be a .ipynb name or a directory
53
54 Returns
55 -------
56 name : string or None
57 the filename of the notebook, or None if not a .ipynb extesnsion
58 path : string or None
59 the path to the directory which contains the notebook
60 """
47 names = notebook_path.split('/')
61 names = notebook_path.split('/')
48 if len(names) > 1:
62 if len(names) > 1:
49 name = names[-1]
63 name = names[-1]
50 if name.endswith(".ipynb"):
64 if name.endswith(".ipynb"):
51 name = name
65 name = name
52 path = notebook_path[0:-len(name)-1]+'/'
66 path = notebook_path[:-1]+'/'
53 else:
67 else:
54 name = None
68 name = None
55 path = notebook_path+'/'
69 path = notebook_path+'/'
General Comments 0
You need to be logged in to leave comments. Login now