mirror of
https://github.com/jupyter/notebook.git
synced 2025-01-24 12:05:22 +08:00
Clean up logic
This commit is contained in:
parent
e95cd6d820
commit
e1533d5398
@ -327,9 +327,7 @@ class ContentsManager(LoggingConfigurable):
|
|||||||
"""
|
"""
|
||||||
# Extract the full suffix from the filename (e.g. .tar.gz)
|
# Extract the full suffix from the filename (e.g. .tar.gz)
|
||||||
path = path.strip('/')
|
path = path.strip('/')
|
||||||
dirname, basename = os.path.split(filename)
|
name, dot, ext = filename.partition('.')
|
||||||
name, dot, ext = basename.partition('.')
|
|
||||||
basename = os.path.join(dirname, name)
|
|
||||||
suffix = dot + ext
|
suffix = dot + ext
|
||||||
|
|
||||||
for i in itertools.count():
|
for i in itertools.count():
|
||||||
@ -337,9 +335,9 @@ class ContentsManager(LoggingConfigurable):
|
|||||||
insert_i = '{}{}'.format(insert, i)
|
insert_i = '{}{}'.format(insert, i)
|
||||||
else:
|
else:
|
||||||
insert_i = ''
|
insert_i = ''
|
||||||
name = u'{basename}{insert}{suffix}'.format(basename=basename,
|
name = u'{name}{insert}{suffix}'.format(name=name,
|
||||||
insert=insert_i, suffix=suffix)
|
insert=insert_i, suffix=suffix)
|
||||||
if not self.exists(os.path.join(path, name)):
|
if not self.exists(u'{}/{}'.format(path, name)):
|
||||||
break
|
break
|
||||||
return name
|
return name
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user