Skip to content

Commit

Permalink
format code using black
Browse files Browse the repository at this point in the history
  • Loading branch information
siddhantgoel committed Apr 14, 2019
1 parent 0bc8ebb commit 77f49fa
Show file tree
Hide file tree
Showing 13 changed files with 386 additions and 212 deletions.
15 changes: 8 additions & 7 deletions examples/bottle/stream_request_body.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,14 @@ def upload_page():
break
parser.data_received(chunk)

return {'name': value.value,
'filename': file.filename}
return {'name': value.value, 'filename': file.filename}


if __name__ == '__main__':
bottle.run(app=bottle.app(),
server='paste',
host='localhost',
port=9000,
debug=True)
bottle.run(
app=bottle.app(),
server='paste',
host='localhost',
port=9000,
debug=True,
)
16 changes: 11 additions & 5 deletions examples/flask/upload-test.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@
app = Flask(__name__)


page = dedent('''
page = dedent(
'''
<!doctype html>
<head>
<title>Upload new File</title>
Expand All @@ -26,7 +27,8 @@
<input type="submit" value="Upload">
</form>
</body>
''')
'''
)


@app.route('/', methods=['GET', 'POST'])
Expand All @@ -48,7 +50,8 @@ def upload_file():

time_finish = time.perf_counter()

response = dedent('''
response = dedent(
'''
<!doctype html>
<head>
<title>Done!</title>
Expand All @@ -61,8 +64,11 @@ def upload_file():
Time spent on file reception: {duration}s
</h2>
</body>
'''.format(file_name=file_.multipart_filename,
duration=(time_finish-time_start)))
'''.format(
file_name=file_.multipart_filename,
duration=(time_finish - time_start),
)
)

return response
return page
Expand Down
17 changes: 6 additions & 11 deletions examples/tornado/stream_request_body.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,9 @@ def data_received(self, chunk):
self._parser.data_received(chunk)

def post(self):
self.render('upload.html', name=self.value.value,
filename=self.file_.filename)
self.render(
'upload.html', name=self.value.value, filename=self.file_.filename
)


class IndexHandler(RequestHandler):
Expand All @@ -36,15 +37,9 @@ def get(self):


def main():
handlers = [
(r'/', IndexHandler),
(r'/upload', UploadHandler),
]

settings = dict(
debug=True,
template_path=os.path.dirname(__file__)
)
handlers = [(r'/', IndexHandler), (r'/upload', UploadHandler)]

settings = dict(debug=True, template_path=os.path.dirname(__file__))

app = Application(handlers, **settings)
app.listen(9999, address='localhost')
Expand Down
6 changes: 4 additions & 2 deletions streaming_form_data/__init__.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
from streaming_form_data.parser import (StreamingFormDataParser, # NOQA
ParseFailedException) # NOQA
from streaming_form_data.parser import ( # NOQA
StreamingFormDataParser,
ParseFailedException,
)
6 changes: 4 additions & 2 deletions streaming_form_data/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,8 @@ def __init__(self, headers):
def register(self, name, target):
if self._running:
raise ParseFailedException(
'Registering parts not allowed when parser is running')
'Registering parts not allowed when parser is running'
)

self._parser.register(name, target)

Expand All @@ -65,4 +66,5 @@ def data_received(self, data):
message = 'parsing particular part headers'

raise ParseFailedException(
'_parser.data_received failed with {}'.format(message))
'_parser.data_received failed with {}'.format(message)
)
3 changes: 2 additions & 1 deletion streaming_form_data/validators.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,5 @@ def __call__(self, chunk):

if self.so_far > self.max_size:
raise ValidationError(
'Size must not be greater than {}'.format(self.max_size))
'Size must not be greater than {}'.format(self.max_size)
)
3 changes: 2 additions & 1 deletion tests/test_exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ def test_basic_single(self):
encoder = MultipartEncoder(fields={'value': 'hello world'})

parser = StreamingFormDataParser(
headers={'Content-Type': encoder.content_type})
headers={'Content-Type': encoder.content_type}
)
parser.register('value', target)

data = encoder.to_string()
Expand Down

0 comments on commit 77f49fa

Please sign in to comment.