mirror of
https://github.com/jupyter/notebook.git
synced 2025-03-01 12:56:54 +08:00
rm dependences of py2 in base path.
This commit is contained in:
parent
4a9cfa7518
commit
ebfe75b6df
@ -11,7 +11,6 @@ import json
|
||||
import os
|
||||
import copy
|
||||
|
||||
from six import PY3
|
||||
from traitlets.config import LoggingConfigurable
|
||||
from traitlets.traitlets import Unicode, Bool
|
||||
|
||||
@ -119,10 +118,7 @@ class BaseJSONConfigManager(LoggingConfigurable):
|
||||
# in order to avoid writing half-finished corrupted data to disk.
|
||||
json_content = json.dumps(data, indent=2)
|
||||
|
||||
if PY3:
|
||||
f = io.open(filename, 'w', encoding='utf-8')
|
||||
else:
|
||||
f = open(filename, 'wb')
|
||||
f = io.open(filename, 'w', encoding='utf-8')
|
||||
with f:
|
||||
f.write(json_content)
|
||||
|
||||
|
@ -23,32 +23,16 @@ import time
|
||||
from io import BytesIO
|
||||
from threading import Thread, Lock, Event
|
||||
|
||||
try:
|
||||
from unittest.mock import patch
|
||||
except ImportError:
|
||||
from mock import patch # py3
|
||||
from unittest.mock import patch
|
||||
|
||||
from jupyter_core.paths import jupyter_runtime_dir
|
||||
from ipython_genutils.py3compat import bytes_to_str, which
|
||||
from notebook._sysinfo import get_sys_info
|
||||
from ipython_genutils.tempdir import TemporaryDirectory
|
||||
|
||||
try:
|
||||
# Python >= 3.3
|
||||
from subprocess import TimeoutExpired
|
||||
def popen_wait(p, timeout):
|
||||
return p.wait(timeout)
|
||||
except ImportError:
|
||||
class TimeoutExpired(Exception):
|
||||
pass
|
||||
def popen_wait(p, timeout):
|
||||
"""backport of Popen.wait from Python 3"""
|
||||
for i in range(int(10 * timeout)):
|
||||
if p.poll() is not None:
|
||||
return
|
||||
time.sleep(0.1)
|
||||
if p.poll() is None:
|
||||
raise TimeoutExpired
|
||||
from subprocess import TimeoutExpired
|
||||
def popen_wait(p, timeout):
|
||||
return p.wait(timeout)
|
||||
|
||||
NOTEBOOK_SHUTDOWN_TIMEOUT = 10
|
||||
|
||||
|
@ -13,13 +13,8 @@ import tarfile
|
||||
import zipfile
|
||||
from os.path import basename, join as pjoin, normpath
|
||||
|
||||
try:
|
||||
from urllib.parse import urlparse # Py3
|
||||
from urllib.request import urlretrieve
|
||||
except ImportError:
|
||||
from urlparse import urlparse
|
||||
from urllib import urlretrieve
|
||||
|
||||
from urllib.parse import urlparse
|
||||
from urllib.request import urlretrieve
|
||||
from jupyter_core.paths import (
|
||||
jupyter_data_dir, jupyter_config_path, jupyter_path,
|
||||
SYSTEM_JUPYTER_PATH, ENV_JUPYTER_PATH,
|
||||
|
@ -32,10 +32,7 @@ import time
|
||||
import warnings
|
||||
import webbrowser
|
||||
|
||||
try: #PY3
|
||||
from base64 import encodebytes
|
||||
except ImportError: #PY2
|
||||
from base64 import encodestring as encodebytes
|
||||
from base64 import encodebytes
|
||||
|
||||
|
||||
from jinja2 import Environment, FileSystemLoader
|
||||
@ -71,10 +68,7 @@ from notebook import (
|
||||
)
|
||||
|
||||
# py23 compatibility
|
||||
try:
|
||||
raw_input = raw_input
|
||||
except NameError:
|
||||
raw_input = input
|
||||
raw_input = input
|
||||
|
||||
from .base.handlers import Template404, RedirectWithParams
|
||||
from .log import log_request
|
||||
|
@ -16,13 +16,8 @@ import sys
|
||||
from distutils.version import LooseVersion
|
||||
|
||||
|
||||
try:
|
||||
from urllib.parse import quote, unquote, urlparse, urljoin
|
||||
from urllib.request import pathname2url
|
||||
except ImportError:
|
||||
from urllib import quote, unquote, pathname2url
|
||||
from urlparse import urlparse, urljoin
|
||||
|
||||
from urllib.parse import quote, unquote, urlparse, urljoin
|
||||
from urllib.request import pathname2url
|
||||
# tornado.concurrent.Future is asyncio.Future
|
||||
# in tornado >=5 with Python 3
|
||||
from tornado.concurrent import Future as TornadoFuture
|
||||
|
Loading…
Reference in New Issue
Block a user