Show More
@@ -21,6 +21,7 b' import io' | |||||
21 | import os |
|
21 | import os | |
22 | import glob |
|
22 | import glob | |
23 | import shutil |
|
23 | import shutil | |
|
24 | from unicodedata import normalize | |||
24 |
|
25 | |||
25 | from tornado import web |
|
26 | from tornado import web | |
26 |
|
27 | |||
@@ -78,7 +79,7 b' class FileNotebookManager(NotebookManager):' | |||||
78 | """List all notebook names in the notebook dir.""" |
|
79 | """List all notebook names in the notebook dir.""" | |
79 | names = glob.glob(os.path.join(self.notebook_dir, |
|
80 | names = glob.glob(os.path.join(self.notebook_dir, | |
80 | '*' + self.filename_ext)) |
|
81 | '*' + self.filename_ext)) | |
81 | names = [os.path.splitext(os.path.basename(name))[0] |
|
82 | names = [normalize('NFC', os.path.splitext(os.path.basename(name))[0]) | |
82 | for name in names] |
|
83 | for name in names] | |
83 | return names |
|
84 | return names | |
84 |
|
85 | |||
@@ -161,7 +162,7 b' class FileNotebookManager(NotebookManager):' | |||||
161 | def write_notebook_object(self, nb, notebook_id=None): |
|
162 | def write_notebook_object(self, nb, notebook_id=None): | |
162 | """Save an existing notebook object by notebook_id.""" |
|
163 | """Save an existing notebook object by notebook_id.""" | |
163 | try: |
|
164 | try: | |
164 | new_name = nb.metadata.name |
|
165 | new_name = normalize('NFC', nb.metadata.name) | |
165 | except AttributeError: |
|
166 | except AttributeError: | |
166 | raise web.HTTPError(400, u'Missing notebook name') |
|
167 | raise web.HTTPError(400, u'Missing notebook name') | |
167 |
|
168 | |||
@@ -263,7 +264,7 b' class FileNotebookManager(NotebookManager):' | |||||
263 |
|
264 | |||
264 | def get_checkpoint_path_by_name(self, name, checkpoint_id): |
|
265 | def get_checkpoint_path_by_name(self, name, checkpoint_id): | |
265 | """Return a full path to a notebook checkpoint, given its name and checkpoint id.""" |
|
266 | """Return a full path to a notebook checkpoint, given its name and checkpoint id.""" | |
266 | filename = "{name}-{checkpoint_id}{ext}".format( |
|
267 | filename = u"{name}-{checkpoint_id}{ext}".format( | |
267 | name=name, |
|
268 | name=name, | |
268 | checkpoint_id=checkpoint_id, |
|
269 | checkpoint_id=checkpoint_id, | |
269 | ext=self.filename_ext, |
|
270 | ext=self.filename_ext, | |
@@ -294,7 +295,7 b' class FileNotebookManager(NotebookManager):' | |||||
294 | """Create a checkpoint from the current state of a notebook""" |
|
295 | """Create a checkpoint from the current state of a notebook""" | |
295 | nb_path = self.get_path(notebook_id) |
|
296 | nb_path = self.get_path(notebook_id) | |
296 | # only the one checkpoint ID: |
|
297 | # only the one checkpoint ID: | |
297 | checkpoint_id = "checkpoint" |
|
298 | checkpoint_id = u"checkpoint" | |
298 | cp_path = self.get_checkpoint_path(notebook_id, checkpoint_id) |
|
299 | cp_path = self.get_checkpoint_path(notebook_id, checkpoint_id) | |
299 | self.log.debug("creating checkpoint for notebook %s", notebook_id) |
|
300 | self.log.debug("creating checkpoint for notebook %s", notebook_id) | |
300 | if not os.path.exists(self.checkpoint_dir): |
|
301 | if not os.path.exists(self.checkpoint_dir): | |
@@ -309,7 +310,7 b' class FileNotebookManager(NotebookManager):' | |||||
309 |
|
310 | |||
310 | This notebook manager currently only supports one checkpoint per notebook. |
|
311 | This notebook manager currently only supports one checkpoint per notebook. | |
311 | """ |
|
312 | """ | |
312 | checkpoint_id = "checkpoint" |
|
313 | checkpoint_id = u"checkpoint" | |
313 | path = self.get_checkpoint_path(notebook_id, checkpoint_id) |
|
314 | path = self.get_checkpoint_path(notebook_id, checkpoint_id) | |
314 | if not os.path.exists(path): |
|
315 | if not os.path.exists(path): | |
315 | return [] |
|
316 | return [] |
General Comments 0
You need to be logged in to leave comments.
Login now