Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove leading slash in notebook path #445

Merged
merged 3 commits into from
Mar 7, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
2 changes: 1 addition & 1 deletion environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ channels:
- default
- conda-forge
dependencies:
- python==3.7
- python
- jupyter
- jupyterlab
- pyyaml
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 jupytext/version.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
"""Jupytext's version number"""

__version__ = '1.3.4'
__version__ = '1.3.4+dev'
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