updates per review

a few more notebook mentions in docstrings,
and inappropriate use of setdefault.
MinRK 12 years ago
parent 2ea31b5ee0
commit bec995aa63

@ -309,10 +309,10 @@ class FileContentsManager(ContentsManager):
"""Save the file model and return the model with no content."""
path = path.strip('/')
if 'content' not in model:
raise web.HTTPError(400, u'No file content provided')
if 'type' not in model:
raise web.HTTPError(400, u'No file type provided')
if 'content' not in model and model['type'] != 'directory':
raise web.HTTPError(400, u'No file content provided')
# One checkpoint should always exist
if self.file_exists(name, path) and not self.list_checkpoints(name, path):

@ -165,16 +165,16 @@ class ContentsManager(LoggingConfigurable):
path = path.strip('/')
if model is None:
model = {}
if 'content' not in model:
if 'content' not in model and model.get('type', None) != 'directory':
if ext == '.ipynb':
metadata = current.new_metadata(name=u'')
model['content'] = current.new_notebook(metadata=metadata)
model.setdefault('type', 'notebook')
model.setdefault('format', 'json')
model['type'] = 'notebook'
model['format'] = 'json'
else:
model['content'] = ''
model.setdefault('type', 'file')
model.setdefault('format', 'text')
model['type'] = 'file'
model['format'] = 'text'
if 'name' not in model:
model['name'] = self.increment_filename('Untitled' + ext, path)
@ -185,7 +185,7 @@ class ContentsManager(LoggingConfigurable):
def copy(self, from_name, to_name=None, path=''):
"""Copy an existing file and return its new model.
If to_name not specified, increment `from_name-Copy#.ipynb`.
If to_name not specified, increment `from_name-Copy#.ext`.
"""
path = path.strip('/')
model = self.get_model(from_name, path)

Loading…
Cancel
Save