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