From a636c47cd9d4acf9e8487cdfb275437abb3f5730 Mon Sep 17 00:00:00 2001 From: vibvibgyor Date: Fri, 28 Jun 2019 02:01:30 +0530 Subject: [PATCH] changed default filename for a copied notebook --- notebook/services/contents/manager.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/notebook/services/contents/manager.py b/notebook/services/contents/manager.py index df59ae7c05..b556abc1d3 100644 --- a/notebook/services/contents/manager.py +++ b/notebook/services/contents/manager.py @@ -331,7 +331,10 @@ def increment_filename(self, filename, path='', insert=''): """ # Extract the full suffix from the filename (e.g. .tar.gz) path = path.strip('/') - basename, dot, ext = filename.partition('.') + basename, dot, ext = filename.rpartition('.') + if ext != 'ipynb': + basename, dot, ext = filename.partition('.') + suffix = dot + ext for i in itertools.count(): @@ -425,6 +428,8 @@ def copy(self, from_path, to_path=None): If to_path not specified, it will be the parent directory of from_path. If to_path is a directory, filename will increment `from_path-Copy#.ext`. + Considering multi-part extensions, the Copy# part will be placed before the first dot for all the extensions except `ipynb`. + For easier manual searching in case of notebooks, the Copy# part will be placed before the last dot. from_path must be a full path to a file. """