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