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

@@ -31,15 +31,11 @@ from tornado.ioloop import IOLoop, PeriodicCallback
from tornado.log import app_log, access_log, gen_log
from tornado import gen, web
import IPython
if V(IPython.__version__) < V('3.0'):
raise ImportError("JupyterHub Requires IPython >= 3.0, found %s" % IPython.__version__)
from IPython.utils.traitlets import (
from traitlets import (
Unicode, Integer, Dict, TraitError, List, Bool, Any,
Type, Set, Instance, Bytes, Float,
)
from IPython.config import Application, catch_config_error
from traitlets.config import Application, catch_config_error
here = os.path.dirname(__file__)

View File

@@ -10,8 +10,8 @@ from subprocess import check_call, check_output, CalledProcessError
from tornado import gen
import simplepam
from IPython.config import LoggingConfigurable
from IPython.utils.traitlets import Bool, Set, Unicode, Any
from traitlets.config import LoggingConfigurable
from traitlets import Bool, Set, Unicode, Any
from .handlers.login import LoginHandler
from .utils import url_path_join

View File

@@ -17,7 +17,7 @@ from jinja2 import ChoiceLoader, FunctionLoader
from tornado import ioloop
from tornado.web import HTTPError
from IPython.utils.traitlets import (
from traitlets import (
Integer,
Unicode,
CUnicode,

View File

@@ -16,8 +16,8 @@ from tempfile import TemporaryDirectory
from tornado import gen
from tornado.ioloop import IOLoop, PeriodicCallback
from IPython.config import LoggingConfigurable
from IPython.utils.traitlets import (
from traitlets.config import LoggingConfigurable
from traitlets import (
Any, Bool, Dict, Enum, Instance, Integer, Float, List, Unicode,
)

View File

@@ -1,7 +1,4 @@
try:
from traitlets import HasTraits
except ImportError:
from IPython.utils.traitlets import HasTraits
from traitlets import HasTraits
from jupyterhub.traitlets import URLPrefix, Command

View File

@@ -2,7 +2,7 @@
# Copyright (c) Jupyter Development Team.
# Distributed under the terms of the Modified BSD License.
from IPython.utils.traitlets import List, Unicode
from traitlets import List, Unicode
class URLPrefix(Unicode):
def validate(self, obj, value):

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"""
@@ -174,3 +169,24 @@ def compare_token(compare, token):
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

View File

@@ -1,4 +1,4 @@
ipython>=3
traitlets>=4
tornado>=4
jinja2
simplepam