Show More
@@ -131,14 +131,18 class NotebookManager(LoggingConfigurable): | |||
|
131 | 131 | model = self.save_notebook_model(model, model['name'], model['path']) |
|
132 | 132 | return model |
|
133 | 133 | |
|
134 | def copy_notebook(self, name, path=''): | |
|
135 |
"""Copy an existing notebook and return its new model. |
|
|
134 | def copy_notebook(self, from_name, to_name=None, path=''): | |
|
135 | """Copy an existing notebook and return its new model. | |
|
136 | ||
|
137 | If to_name not specified, increment `from_name-Copy#.ipynb`. | |
|
138 | """ | |
|
136 | 139 | path = path.strip('/') |
|
137 | model = self.get_notebook_model(name, path) | |
|
138 | name = os.path.splitext(name)[0] + '-Copy' | |
|
139 | name = self.increment_filename(name, path) | |
|
140 | model['name'] = name | |
|
141 | model = self.save_notebook_model(model, name, path) | |
|
140 | model = self.get_notebook_model(from_name, path) | |
|
141 | if not to_name: | |
|
142 | base = os.path.splitext(from_name)[0] + '-Copy' | |
|
143 | to_name = self.increment_filename(base, path) | |
|
144 | model['name'] = to_name | |
|
145 | model = self.save_notebook_model(model, to_name, path) | |
|
142 | 146 | return model |
|
143 | 147 | |
|
144 | 148 | # Checkpoint-related |
General Comments 0
You need to be logged in to leave comments.
Login now