Skip to content

Commit 7fb61af

Browse files
committed
Added recompiled requirements.txt and some linting fixes
1 parent cbbd109 commit 7fb61af

File tree

3 files changed

+27
-17
lines changed

3 files changed

+27
-17
lines changed

nbviewer/providers/__init__.py

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,7 @@
1010
]
1111

1212
default_rewrites = [
13-
"nbviewer.providers.{}".format(prov)
14-
for prov in ["gist", "github", "dropbox", "url", "s3"]
13+
"nbviewer.providers.{}".format(prov) for prov in ["gist", "github", "dropbox", "url", "s3"]
1514
]
1615

1716

@@ -87,9 +86,7 @@ def _load_provider_feature(feature, providers, **handler_names):
8786
continue
8887
else:
8988
# Ex: provider_handlers['url_handler'] = handler_names['url_handler']
90-
provider_handlers[provider_handler_key] = handler_names[
91-
provider_handler_key
92-
]
89+
provider_handlers[provider_handler_key] = handler_names[provider_handler_key]
9390

9491
features = []
9592

nbviewer/providers/s3/handlers.py

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,10 @@
99
import os
1010
from datetime import datetime
1111
from urllib.parse import urlparse
12+
1213
import boto3
1314
import botocore
15+
from tornado import iostream
1416
from tornado import web
1517

1618
from .. import _load_handler_from_location
@@ -24,17 +26,17 @@ class S3Handler(RenderingHandler):
2426
2527
Serving notebooks from S3 buckets
2628
"""
29+
2730
def initialize(self, **kwargs):
2831
self.s3_client = boto3.client("s3")
2932
self._downloadable_data = None
3033
self._downloaded_path = None
3134
super().initialize(**kwargs)
3235

33-
3436
async def download(self, path):
3537
"""Download the notebook"""
3638
headers = await self.get_notebook_headers(path)
37-
filename=os.path.basename(path)
39+
filename = os.path.basename(path)
3840
self.set_header("Content-Length", headers["ContentLength"])
3941
# Escape commas to workaround Chrome issue with commas in download filenames
4042
self.set_header(
@@ -55,7 +57,6 @@ async def download(self, path):
5557
except iostream.StreamClosedError:
5658
return
5759

58-
5960
async def get_notebook_data(self, path):
6061
"""Get additional notebook data"""
6162
is_download = self.get_query_arguments("download")
@@ -65,7 +66,6 @@ async def get_notebook_data(self, path):
6566

6667
return path
6768

68-
6969
async def get_notebook_headers(self, path):
7070
"""Get the size of a notebook file."""
7171
o = urlparse(path)
@@ -81,7 +81,6 @@ async def get_notebook_headers(self, path):
8181
raise ex
8282
return head
8383

84-
8584
async def read_s3_file(self, path):
8685
"""Download the notebook file from s3."""
8786
o = urlparse(path)
@@ -98,11 +97,10 @@ async def read_s3_file(self, path):
9897
raise ex
9998
s3_file.seek(0)
10099
self.log.debug("Done downloading.")
101-
self._downloadable_data = s3_file.read().decode('utf-8')
100+
self._downloadable_data = s3_file.read().decode("utf-8")
102101
self._downloaded_path = path
103102
return self._downloadable_data
104103

105-
106104
async def deliver_notebook(self, path):
107105
nbdata = await self.read_s3_file(path)
108106

@@ -137,16 +135,15 @@ async def get(self, path):
137135
await self.deliver_notebook(fullpath)
138136

139137

140-
141138
def default_handlers(handlers=[], **handler_names):
142139
"""Tornado handlers"""
143140

144141
s3_handler = _load_handler_from_location(handler_names["s3_handler"])
145142

146143
return handlers + [(r"/(s3%3A//.*)", s3_handler, {})]
147144

145+
148146
def uri_rewrites(rewrites=[]):
149147
return [
150148
(r"^(s3://.*)$", "{0}"),
151149
]
152-

requirements.txt

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#
2-
# This file is autogenerated by pip-compile with python 3.10
2+
# This file is autogenerated by pip-compile with python 3.9
33
# To update, run:
44
#
55
# pip-compile
@@ -20,6 +20,12 @@ black==21.12b0
2020
# via ipython
2121
bleach==4.1.0
2222
# via nbconvert
23+
boto3==1.23.3
24+
# via -r requirements.in
25+
botocore==1.26.3
26+
# via
27+
# boto3
28+
# s3transfer
2329
certifi==2021.10.8
2430
# via elasticsearch
2531
cffi==1.15.0
@@ -52,6 +58,10 @@ jinja2==3.0.3
5258
# via
5359
# jupyter-server
5460
# nbconvert
61+
jmespath==1.0.0
62+
# via
63+
# boto3
64+
# botocore
5565
jsonschema==4.4.0
5666
# via nbformat
5767
jupyter-client==7.1.2
@@ -130,11 +140,15 @@ pyparsing==3.0.7
130140
pyrsistent==0.18.1
131141
# via jsonschema
132142
python-dateutil==2.8.2
133-
# via jupyter-client
143+
# via
144+
# botocore
145+
# jupyter-client
134146
pyzmq==22.3.0
135147
# via
136148
# jupyter-client
137149
# jupyter-server
150+
s3transfer==0.5.2
151+
# via boto3
138152
send2trash==1.8.0
139153
# via jupyter-server
140154
six==1.16.0
@@ -172,7 +186,9 @@ traitlets==5.1.1
172186
typing-extensions==4.0.1
173187
# via black
174188
urllib3==1.26.8
175-
# via elasticsearch
189+
# via
190+
# botocore
191+
# elasticsearch
176192
wcwidth==0.2.5
177193
# via prompt-toolkit
178194
webencodings==0.5.1

0 commit comments

Comments
 (0)