Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 2 additions & 4 deletions notebook/auth/login.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,8 @@
import re
import os

try:
from urllib.parse import urlparse # Py 3
except ImportError:
from urlparse import urlparse # Py 2
from urllib.parse import urlparse

import uuid

from tornado.escape import url_escape
Expand Down
20 changes: 4 additions & 16 deletions notebook/base/handlers.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,18 +14,10 @@
import traceback
import types
import warnings
try:
# py3
from http.client import responses
from http.cookies import Morsel
except ImportError:
from httplib import responses
from Cookie import Morsel
try:
from urllib.parse import urlparse # Py 3
except ImportError:
from urlparse import urlparse # Py 2
from http.client import responses
from http.cookies import Morsel

from urllib.parse import urlparse
from jinja2 import TemplateNotFound
from tornado import web, gen, escape, httputil
from tornado.log import app_log
Expand All @@ -35,7 +27,7 @@

from traitlets.config import Application
from ipython_genutils.path import filefind
from ipython_genutils.py3compat import string_types, PY3
from ipython_genutils.py3compat import string_types

import notebook
from notebook._tz import utcnow
Expand Down Expand Up @@ -479,10 +471,6 @@ def check_host(self):
if host.startswith('[') and host.endswith(']'):
host = host[1:-1]

if not PY3:
# ip_address only accepts unicode on Python 2
host = host.decode('utf8', 'replace')

try:
addr = ipaddress.ip_address(host)
except ValueError:
Expand Down
6 changes: 2 additions & 4 deletions notebook/bundler/tests/test_bundler_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,8 @@
new_notebook, new_markdown_cell, new_code_cell, new_output,
)

try:
from unittest.mock import patch
except ImportError:
from mock import patch # py3
from unittest.mock import patch


def bundle(handler, model):
"""Bundler test stub. Echo the notebook path."""
Expand Down
6 changes: 1 addition & 5 deletions notebook/bundler/tests/test_bundlerextension.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,7 @@
import shutil
import unittest

try:
from unittest.mock import patch
except ImportError:
from mock import patch # py2

from unittest.mock import patch
from ipython_genutils.tempdir import TemporaryDirectory
from ipython_genutils import py3compat

Expand Down
7 changes: 1 addition & 6 deletions notebook/nbconvert/tests/test_nbconvert_handlers.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,7 @@

from ipython_genutils.testing.decorators import onlyif_cmds_exist

try: #PY3
from base64 import encodebytes
except ImportError: #PY2
from base64 import encodestring as encodebytes


from base64 import encodebytes


class NbconvertAPI(object):
Expand Down
1 change: 0 additions & 1 deletion notebook/services/config/handlers.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
import errno
from tornado import web

from ipython_genutils.py3compat import PY3
from ...base.handlers import APIHandler

class ConfigHandler(APIHandler):
Expand Down
5 changes: 1 addition & 4 deletions notebook/services/contents/fileio.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,7 @@
from traitlets.config import Configurable
from traitlets import Bool

try: #PY3
from base64 import encodebytes, decodebytes
except ImportError: #PY2
from base64 import encodestring as encodebytes, decodestring as decodebytes
from base64 import encodebytes, decodebytes


def replace_file(src, dst):
Expand Down
6 changes: 1 addition & 5 deletions notebook/services/contents/filemanager.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,7 @@
from notebook.base.handlers import AuthenticatedFileHandler
from notebook.transutils import _

try:
from os.path import samefile
except ImportError:
# windows + py2
from notebook.utils import samefile_simple as samefile
from os.path import samefile

_script_exporter = None

Expand Down
5 changes: 1 addition & 4 deletions notebook/tests/launchnotebook.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,7 @@

pjoin = os.path.join

try:
from unittest.mock import patch
except ImportError:
from mock import patch #py2
from unittest.mock import patch

import requests
from tornado.ioloop import IOLoop
Expand Down
5 changes: 1 addition & 4 deletions notebook/tests/test_nbextensions.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,7 @@
from traitlets.tests.utils import check_help_all_output
from unittest import TestCase

try:
from unittest.mock import patch
except ImportError:
from mock import patch # py2
from unittest.mock import patch

import ipython_genutils.testing.decorators as dec
from ipython_genutils import py3compat
Expand Down
5 changes: 1 addition & 4 deletions notebook/tests/test_notebookapp.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,7 @@
import sys
from tempfile import NamedTemporaryFile

try:
from unittest.mock import patch
except ImportError:
from mock import patch # py2
from unittest.mock import patch

import nose.tools as nt

Expand Down
10 changes: 1 addition & 9 deletions notebook/tests/test_paths.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,9 @@

import re
import nose.tools as nt
from nose.tools import assert_regex, assert_not_regex

from notebook.base.handlers import path_regex

try: # py3
assert_regex = nt.assert_regex
assert_not_regex = nt.assert_not_regex
except AttributeError: # py2
assert_regex = nt.assert_regexp_matches
assert_not_regex = nt.assert_not_regexp_matches


# build regexps that tornado uses:
path_pat = re.compile('^' + '/x%s' % path_regex + '$')

Expand Down
5 changes: 1 addition & 4 deletions notebook/tests/test_serverextensions.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,7 @@
import os
import sys
from unittest import TestCase
try:
from unittest.mock import patch
except ImportError:
from mock import patch # py2
from unittest.mock import patch

from ipython_genutils.tempdir import TemporaryDirectory
from ipython_genutils import py3compat
Expand Down
5 changes: 1 addition & 4 deletions notebook/tree/tests/test_tree_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,7 @@
from notebook.utils import url_path_join
from nbformat import write
from nbformat.v4 import new_notebook
try:
from urllib.parse import urlparse
except ImportError:
from urlparse import urlparse
from urllib.parse import urlparse

import requests

Expand Down