You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

17 lines
556 B

import os
def get_server_root_dir(settings):
# notebook >= 5.0.0 has this in the settings
if 'server_root_dir' in settings:
return settings['server_root_dir']
# This copies the logic added in the notebook in
# https://github.com/jupyter/notebook/pull/2234
contents_manager = settings['contents_manager']
root_dir = contents_manager.root_dir
home = os.path.expanduser('~')
if root_dir.startswith(home + os.path.sep):
# collapse $HOME to ~
root_dir = '~' + root_dir[len(home):]
return root_dir