Skip to content

Commit 6f52c5d

Browse files
committed
Minor addition to README to try to explain PR, minor change to setup.py to reflect deprecation of Python 2.7 support, and attempt to remove as many of the Python 2.7 import statements as possible.
1 parent 3915c8e commit 6f52c5d

File tree

8 files changed

+23
-59
lines changed

8 files changed

+23
-59
lines changed

README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,12 @@ If you'd like to write a new format, open a ticket, or speak up on [gitter][]!
185185
We have some work yet to do to support your next big thing in notebook
186186
publishing, and we'd love to here from you.
187187

188+
#### Config file
189+
190+
Newer versions of NBViewer will be configurable using a config file, `nbviewer_config.py`. In the directory where you run the command `python -m nbviewer` to start NBViewer, also add a file `nbviewer_config.py` which uses [the standard configuration syntax for Jupyter projects](https://traitlets.readthedocs.io/en/stable/config.html).
191+
192+
For example, to configure the value of a configurable `foo`, add the line `c.NBViewer.foo = 'bar'` to the `nbviewer_config.py` file located where you run `python -m nbviewer`. Again, currently very few features of NBViewer are configurable this way, but we hope to steadily increase the number of configurable characteristics of NBViewer in future releases.
193+
188194
## Securing the Notebook Viewer
189195

190196
You can run the viewer as a [JupyterHub 0.7+ service](https://jupyterhub.readthedocs.io/en/latest/reference/services.html). Running the viewer as a service prevents users who have not authenticated with the Hub from acccessing the nbviewer instance. This setup can be useful for protecting access to local notebooks rendered with the `--localfiles` option.

nbviewer/app.py

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -12,17 +12,8 @@
1212
import logging
1313
import markdown
1414

15-
16-
try:
17-
# py3
18-
from urllib.parse import urlparse
19-
# https://docs.python.org/3/library/cgi.html#cgi.escape
20-
# Deprecated since version 3.2: This function is unsafe because quote is
21-
# false by default, and therefore deprecated. Use html.escape() instead.
22-
from html import escape
23-
except ImportError:
24-
from cgi import escape
25-
from urlparse import urlparse
15+
from urllib.parse import urlparse
16+
from html import escape
2617

2718
from concurrent.futures import ThreadPoolExecutor, ProcessPoolExecutor
2819

nbviewer/cache.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,7 @@
66
#-----------------------------------------------------------------------------
77

88
import zlib
9-
try:
10-
from time import monotonic
11-
except ImportError:
12-
from time import time as monotonic
9+
from time import monotonic
1310

1411
from concurrent.futures import ThreadPoolExecutor
1512
from tornado.concurrent import Future

nbviewer/providers/base.py

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,8 @@
1515
from contextlib import contextmanager
1616
from datetime import datetime
1717

18-
try:
19-
# py3
20-
from http.client import responses
21-
from urllib.parse import urlparse, urlunparse, quote, urlencode
22-
except ImportError:
23-
from httplib import responses
24-
from urlparse import urlparse, urlunparse
25-
from urllib import quote, urlencode
18+
from http.client import responses
19+
from urllib.parse import urlparse, urlunparse, quote, urlencode
2620

2721
from tornado import (
2822
gen,

nbviewer/providers/github/client.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,7 @@
88
import json
99
import os
1010

11-
try: # py3
12-
from urllib.parse import urlparse
13-
except ImportError:
14-
from urlparse import urlparse
11+
from urllib.parse import urlparse
1512

1613
from tornado.concurrent import Future
1714
from tornado.httpclient import AsyncHTTPClient, HTTPError

nbviewer/providers/url/handlers.py

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,8 @@
55
# the file COPYING, distributed as part of this software.
66
#-----------------------------------------------------------------------------
77

8-
try:
9-
# py3
10-
from urllib.parse import urlparse
11-
from urllib import robotparser
12-
except ImportError:
13-
from urlparse import urlparse
14-
import robotparser
8+
from urllib.parse import urlparse
9+
from urllib import robotparser
1510

1611
from tornado import (
1712
gen,

nbviewer/utils.py

Lines changed: 9 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -5,36 +5,22 @@
55
# the file COPYING, distributed as part of this software.
66
#-----------------------------------------------------------------------------
77

8-
# https://docs.python.org/3.1/library/base64.html#base64.decodestring
9-
try:
10-
from base64 import encodebytes
11-
from base64 import decodebytes
12-
except ImportError:
13-
from base64 import encodestring as encodebytes
14-
from base64 import decodestring as decodebytes
8+
from base64 import encodebytes
9+
from base64 import decodebytes
1510

1611
import cgi
1712
from contextlib import contextmanager
1813
import re
1914
from subprocess import check_output
2015
import time
2116

22-
try:
23-
from urllib.parse import (
24-
parse_qs,
25-
quote as stdlib_quote,
26-
urlencode,
27-
urlparse,
28-
urlunparse,
29-
)
30-
except ImportError:
31-
from urllib import urlencode
32-
from urllib2 import quote as stdlib_quote
33-
from urlparse import (
34-
parse_qs,
35-
urlparse,
36-
urlunparse,
37-
)
17+
from urllib.parse import (
18+
parse_qs,
19+
quote as stdlib_quote,
20+
urlencode,
21+
urlparse,
22+
urlunparse,
23+
)
3824

3925
from tornado.log import app_log
4026

setup.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,8 +78,6 @@ def walk_subpkg(name):
7878
license = "BSD",
7979
classifiers = [
8080
'License :: OSI Approved :: BSD License',
81-
'Programming Language :: Python :: 2',
82-
'Programming Language :: Python :: 2.7',
8381
'Programming Language :: Python :: 3',
8482
'Programming Language :: Python :: 3.3',
8583
],

0 commit comments

Comments
 (0)