basabuuka_prototyp/venv/lib/python3.5/site-packages/voila/utils.py

18 lines
556 B
Python
Raw Normal View History

2020-08-16 19:36:44 +02:00
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