Skip to content

Commit

Permalink
Removed leading slash in notebook paths
Browse files Browse the repository at this point in the history
  • Loading branch information
mwouts committed Mar 7, 2020
1 parent b75ed4b commit 709c2a7
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 2 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
1.3.4+dev (2020-03-??)
----------------------

**Fixed**
- Removed leading slash in notebook paths (#444)


1.3.4 (2020-02-18)
------------------

Expand Down
5 changes: 4 additions & 1 deletion jupytext/contentsmanager.py
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,7 @@ def save(self, model, path=''):
if model['type'] != 'notebook':
return super(JupytextContentsManager, self).save(model, path)

path = path.strip('/')
nbk = model['content']
try:
metadata = nbk.get('metadata')
Expand Down Expand Up @@ -284,7 +285,9 @@ def save(self, model, path=''):

def get(self, path, content=True, type=None, format=None, load_alternative_format=True):
""" Takes a path for an entity and returns its model"""
os_path = self._get_os_path(path.strip('/'))
path = path.strip('/')

os_path = self._get_os_path(path)
ext = os.path.splitext(path)[1]

# Not a notebook?
Expand Down
2 changes: 1 addition & 1 deletion tests/test_paired_paths.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ def test_prefix_on_root_174():
formats = long_form_multiple_formats(short_formats)
assert short_form_multiple_formats(formats) == short_formats

expected_paths = ['/Untitled.ipynb', '/python/Untitled.py']
expected_paths = ['Untitled.ipynb', 'python/Untitled.py']
for fmt, path in zip(formats, expected_paths):
compare(paired_paths(path, fmt, formats), list(zip(expected_paths, formats)))

Expand Down

0 comments on commit 709c2a7

Please sign in to comment.