mirror of
https://github.com/jupyterhub/jupyterhub.git
synced 2025-10-19 16:03:00 +00:00
remove dependency on IPython
- Standalone traitlets has been released, use it directly. - Copy url_path_join from notebook
This commit is contained in:
@@ -14,11 +14,6 @@ from tornado import web, gen, ioloop
|
||||
from tornado.httpclient import AsyncHTTPClient, HTTPError
|
||||
from tornado.log import app_log
|
||||
|
||||
try:
|
||||
from jupyter_notebook.utils import url_path_join
|
||||
except:
|
||||
from IPython.html.utils import url_path_join
|
||||
|
||||
|
||||
def random_port():
|
||||
"""get a single random port"""
|
||||
@@ -172,5 +167,26 @@ def compare_token(compare, token):
|
||||
if compare == hashed:
|
||||
return True
|
||||
return False
|
||||
|
||||
|
||||
|
||||
def url_path_join(*pieces):
|
||||
"""Join components of url into a relative url
|
||||
|
||||
Use to prevent double slash when joining subpath. This will leave the
|
||||
initial and final / in place
|
||||
|
||||
Copied from notebook.utils.url_path_join
|
||||
"""
|
||||
initial = pieces[0].startswith('/')
|
||||
final = pieces[-1].endswith('/')
|
||||
stripped = [ s.strip('/') for s in pieces ]
|
||||
result = '/'.join(s for s in stripped if s)
|
||||
|
||||
if initial:
|
||||
result = '/' + result
|
||||
if final:
|
||||
result = result + '/'
|
||||
if result == '//':
|
||||
result = '/'
|
||||
|
||||
return result
|
||||
|
Reference in New Issue
Block a user