Skip to content

Commit 95d3dac

Browse files
vibvibgyorkevin-bates
authored andcommitted
changed default filename for a copied notebook (#4618)
1 parent cc1084e commit 95d3dac

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

jupyter_server/services/contents/manager.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -331,7 +331,10 @@ def increment_filename(self, filename, path='', insert=''):
331331
"""
332332
# Extract the full suffix from the filename (e.g. .tar.gz)
333333
path = path.strip('/')
334-
basename, dot, ext = filename.partition('.')
334+
basename, dot, ext = filename.rpartition('.')
335+
if ext != 'ipynb':
336+
basename, dot, ext = filename.partition('.')
337+
335338
suffix = dot + ext
336339

337340
for i in itertools.count():
@@ -425,6 +428,8 @@ def copy(self, from_path, to_path=None):
425428
426429
If to_path not specified, it will be the parent directory of from_path.
427430
If to_path is a directory, filename will increment `from_path-Copy#.ext`.
431+
Considering multi-part extensions, the Copy# part will be placed before the first dot for all the extensions except `ipynb`.
432+
For easier manual searching in case of notebooks, the Copy# part will be placed before the last dot.
428433
429434
from_path must be a full path to a file.
430435
"""

0 commit comments

Comments
 (0)