remove dependency on IPython

- Standalone traitlets has been released, use it directly.
- Copy url_path_join from notebook
This commit is contained in:
Min RK
2015-06-22 15:50:37 -07:00
parent 7acaf8ce52
commit c289cdfaec
8 changed files with 32 additions and 23 deletions

View File

@@ -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