Show More
@@ -82,16 +82,6 b' class FileNotebookManager(NotebookManager):' | |||||
82 | for name in names] |
|
82 | for name in names] | |
83 | return names |
|
83 | return names | |
84 |
|
84 | |||
85 | def increment_filename(self, basename, path='', ext='.ipynb'): |
|
|||
86 | """Return a non-used filename of the form basename<int>.""" |
|
|||
87 | path = path.strip('/') |
|
|||
88 | for i in itertools.count(): |
|
|||
89 | name = u'{basename}{i}{ext}'.format(basename=basename, i=i, ext=ext) |
|
|||
90 | os_path = self.get_os_path(name, path) |
|
|||
91 | if not os.path.isfile(os_path): |
|
|||
92 | break |
|
|||
93 | return name |
|
|||
94 |
|
||||
95 | def path_exists(self, path): |
|
85 | def path_exists(self, path): | |
96 | """Does the API-style path (directory) actually exist? |
|
86 | """Does the API-style path (directory) actually exist? | |
97 |
|
87 |
@@ -17,6 +17,7 b' Authors:' | |||||
17 | # Imports |
|
17 | # Imports | |
18 | #----------------------------------------------------------------------------- |
|
18 | #----------------------------------------------------------------------------- | |
19 |
|
19 | |||
|
20 | import itertools | |||
20 | import os |
|
21 | import os | |
21 |
|
22 | |||
22 | from IPython.config.configurable import LoggingConfigurable |
|
23 | from IPython.config.configurable import LoggingConfigurable | |
@@ -126,8 +127,20 b' class NotebookManager(LoggingConfigurable):' | |||||
126 | The name of a notebook without the ``.ipynb`` file extension. |
|
127 | The name of a notebook without the ``.ipynb`` file extension. | |
127 | path : unicode |
|
128 | path : unicode | |
128 | The URL path of the notebooks directory |
|
129 | The URL path of the notebooks directory | |
|
130 | ||||
|
131 | Returns | |||
|
132 | ------- | |||
|
133 | name : unicode | |||
|
134 | A notebook name (with the .ipynb extension) that starts | |||
|
135 | with basename and does not refer to any existing notebook. | |||
129 | """ |
|
136 | """ | |
130 | return basename |
|
137 | path = path.strip('/') | |
|
138 | for i in itertools.count(): | |||
|
139 | name = u'{basename}{i}{ext}'.format(basename=basename, i=i, | |||
|
140 | ext=self.filename_ext) | |||
|
141 | if not self.notebook_exists(name, path): | |||
|
142 | break | |||
|
143 | return name | |||
131 |
|
144 | |||
132 | def notebook_exists(self, name, path=''): |
|
145 | def notebook_exists(self, name, path=''): | |
133 | """Returns a True if the notebook exists. Else, returns False. |
|
146 | """Returns a True if the notebook exists. Else, returns False. |
General Comments 0
You need to be logged in to leave comments.
Login now