Skip to content

Commit

Permalink
"save" returns the value that corresponds to the current path #180
Browse files Browse the repository at this point in the history
  • Loading branch information
mwouts committed Mar 12, 2019
1 parent f000380 commit 894b9c5
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions jupytext/contentsmanager.py
Original file line number Diff line number Diff line change
Expand Up @@ -237,15 +237,17 @@ def save(self, model, path=''):
self.update_paired_notebooks(path, fmt, jupytext_formats)

# Save as ipynb first
latest_result = None
return_value = None
for fmt in jupytext_formats[::-1]:
if fmt['extension'] != '.ipynb':
continue

alt_path = full_path(base, fmt)
self.create_prefix_dir(alt_path, fmt)
self.log.info("Saving %s", os.path.basename(alt_path))
latest_result = super(TextFileContentsManager, self).save(model, alt_path)
value = super(TextFileContentsManager, self).save(model, alt_path)
if alt_path == path:
return_value = value

# And then to the other formats, in reverse order so that
# the first format is the most recent
Expand All @@ -262,9 +264,11 @@ def save(self, model, path=''):
else:
self.log.info("Saving %s", os.path.basename(alt_path))
with mock.patch('nbformat.writes', _jupytext_writes(fmt)):
latest_result = super(TextFileContentsManager, self).save(model, alt_path)
value = super(TextFileContentsManager, self).save(model, alt_path)
if alt_path == path:
return_value = value

return latest_result
return return_value

except Exception as err:
raise HTTPError(400, str(err))
Expand Down

0 comments on commit 894b9c5

Please sign in to comment.