Skip to content

Commit 036f57f

Browse files
dolfandringaSylvainCorlay
authored andcommitted
Added recompiled requirements.txt and some linting fixes
1 parent 2ab493a commit 036f57f

File tree

3 files changed

+24
-11
lines changed

3 files changed

+24
-11
lines changed

nbviewer/providers/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ def _load_provider_feature(feature, providers, **handler_names):
8383
try:
8484
# Ex: handler_names['url_handler']
8585
handler_names[provider_handler_key]
86-
except KeyError:
86+
except KeyError as e:
8787
continue
8888
else:
8989
# Ex: provider_handlers['url_handler'] = handler_names['url_handler']

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: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,12 @@ beautifulsoup4==4.11.1
2020
# via nbconvert
2121
bleach==5.0.1
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==2022.12.7
2430
# via elastic-transport
2531
cffi==1.15.1
@@ -48,6 +54,10 @@ jinja2==3.1.2
4854
# via
4955
# jupyter-server
5056
# nbconvert
57+
jmespath==1.0.0
58+
# via
59+
# boto3
60+
# botocore
5161
jsonschema==4.17.0
5262
# via nbformat
5363
jupyter-client==7.4.4
@@ -130,11 +140,15 @@ pyparsing==3.0.9
130140
pyrsistent==0.19.2
131141
# via jsonschema
132142
python-dateutil==2.8.2
133-
# via jupyter-client
143+
# via
144+
# botocore
145+
# jupyter-client
134146
pyzmq==24.0.1
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
@@ -171,6 +185,8 @@ traitlets==5.5.0
171185
# nbconvert
172186
# nbformat
173187
urllib3==1.26.12
188+
# via
189+
# botocore
174190
# via elastic-transport
175191
wcwidth==0.2.5
176192
# via prompt-toolkit

0 commit comments

Comments
 (0)