Skip to content

Commit 3a2936b

Browse files
authored
Merge pull request #25 from deep-compute/update_travis_via_gitkanban
updated the code and travis file with black formatter
2 parents 47ff0b5 + 937d896 commit 3a2936b

3 files changed

Lines changed: 44 additions & 44 deletions

File tree

.travis.yml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
before_install:
2-
- pip3 install black
31
deploy:
42
- provider: releases
53
skip_cleanup: true
@@ -33,5 +31,5 @@ language: python
3331
python:
3432
- '3.5'
3533
script:
36-
- black --check .
34+
- docker run -v $(pwd):/app deepcompute/black:python-black-latest --check .
3735
- echo "No tests as of now"

kwikapi/tornado/kwikapi_tornado.py

Lines changed: 26 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@
1616

1717
DUMMY_LOG = Dummy()
1818

19-
class TornadoRequest(BaseRequest):
2019

20+
class TornadoRequest(BaseRequest):
2121
def __init__(self, req_hdlr):
2222
super().__init__()
2323
self._request = req_hdlr.request
@@ -39,6 +39,7 @@ def body(self):
3939
def headers(self):
4040
return self._request.headers
4141

42+
4243
class TornadoResponse(BaseResponse):
4344
def __init__(self, req_hdlr):
4445
super().__init__()
@@ -51,20 +52,22 @@ def write(self, data, proto, stream=False):
5152
if not stream:
5253
nbytes = n.value
5354

54-
accept_enc = self._req_hdlr.request.headers.get('Accept-Encoding', '')
55-
accept_enc = set([e.strip().lower() for e in accept_enc.split(',') if e.strip()])
55+
accept_enc = self._req_hdlr.request.headers.get("Accept-Encoding", "")
56+
accept_enc = set(
57+
[e.strip().lower() for e in accept_enc.split(",") if e.strip()]
58+
)
5659

57-
if 'gzip' in accept_enc:
60+
if "gzip" in accept_enc:
5861
compressed = io.BytesIO()
59-
gfile = gzip.GzipFile(fileobj=compressed, mode='w')
62+
gfile = gzip.GzipFile(fileobj=compressed, mode="w")
6063
gfile.write(self._data)
6164
gfile.flush()
6265
gfile.close()
6366
self._data = compressed.getvalue()
6467
nbytes = len(self._data)
65-
self._headers['Content-Encoding'] = 'gzip'
68+
self._headers["Content-Encoding"] = "gzip"
6669

67-
self._headers['Content-Length'] = nbytes
70+
self._headers["Content-Length"] = nbytes
6871

6972
self._stream = stream
7073

@@ -80,25 +83,28 @@ def close(self):
8083
def headers(self):
8184
return self._headers
8285

86+
8387
class RequestHandler(TornadoRequestHandler):
8488
PROTOCOL = BaseRequestHandler.DEFAULT_PROTOCOL
8589

8690
def __init__(self, *args, **kwargs):
87-
self.api = kwargs.pop('api')
88-
self.log = kwargs.pop('log', DUMMY_LOG)
91+
self.api = kwargs.pop("api")
92+
self.log = kwargs.pop("log", DUMMY_LOG)
8993

90-
default_version = kwargs.pop('default_version', None)
91-
default_protocol = kwargs.pop('default_protocol', self.PROTOCOL)
94+
default_version = kwargs.pop("default_version", None)
95+
default_protocol = kwargs.pop("default_protocol", self.PROTOCOL)
9296

93-
pre_call_hook = kwargs.pop('pre_call_hook', None)
94-
post_call_hook = kwargs.pop('post_call_hook', None)
97+
pre_call_hook = kwargs.pop("pre_call_hook", None)
98+
post_call_hook = kwargs.pop("post_call_hook", None)
9599

96-
self.kwik_req_hdlr = BaseRequestHandler(self.api,
97-
default_version=default_version,
98-
default_protocol=default_protocol,
99-
pre_call_hook=pre_call_hook,
100-
post_call_hook=post_call_hook,
101-
log=self.log)
100+
self.kwik_req_hdlr = BaseRequestHandler(
101+
self.api,
102+
default_version=default_version,
103+
default_protocol=default_protocol,
104+
pre_call_hook=pre_call_hook,
105+
post_call_hook=post_call_hook,
106+
log=self.log,
107+
)
102108

103109
super().__init__(*args, **kwargs)
104110

@@ -132,7 +138,7 @@ def fn():
132138
except tornado.iostream.StreamClosedError:
133139
continue
134140
except Exception:
135-
self.log.exception('unhandle_request_handling_exception')
141+
self.log.exception("unhandle_request_handling_exception")
136142
raise
137143
finally:
138144
self.finish()

setup.py

Lines changed: 17 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,28 @@
11
from setuptools import setup, find_packages
22

33
# https://docs.djangoproject.com/en/1.11/intro/reusable-apps/
4-
version = '0.3.7'
4+
version = "0.3.7"
55
setup(
66
name="kwikapi-tornado",
77
version=version,
8-
packages=['kwikapi.tornado'],
8+
packages=["kwikapi.tornado"],
99
include_package_data=True,
10-
license='MIT License', # example license
11-
description='Quickest way to build powerful HTTP APIs in Python',
12-
url='https://github.com/deep-compute/kwikapi.tornado',
10+
license="MIT License", # example license
11+
description="Quickest way to build powerful HTTP APIs in Python",
12+
url="https://github.com/deep-compute/kwikapi.tornado",
1313
download_url="https://github.com/deep-compute/kwikapi.tornado/tarball/%s" % version,
14-
author='Deep Compute, LLC',
15-
author_email='contact@deepcompute.com',
16-
install_requires=[
17-
'tornado==5.0.2',
18-
'deeputil==0.2.7',
19-
'requests==2.20.0',
20-
],
14+
author="Deep Compute, LLC",
15+
author_email="contact@deepcompute.com",
16+
install_requires=["tornado==5.0.2", "deeputil==0.2.7", "requests==2.20.0"],
2117
classifiers=[
22-
'Environment :: Web Environment',
23-
'Intended Audience :: Developers',
24-
'License :: OSI Approved :: MIT License',
25-
'Operating System :: OS Independent',
26-
'Programming Language :: Python',
27-
'Programming Language :: Python :: 3',
28-
'Programming Language :: Python :: 3.5',
29-
'Topic :: Internet :: WWW/HTTP',
30-
'Topic :: Internet :: WWW/HTTP :: Dynamic Content',
18+
"Environment :: Web Environment",
19+
"Intended Audience :: Developers",
20+
"License :: OSI Approved :: MIT License",
21+
"Operating System :: OS Independent",
22+
"Programming Language :: Python",
23+
"Programming Language :: Python :: 3",
24+
"Programming Language :: Python :: 3.5",
25+
"Topic :: Internet :: WWW/HTTP",
26+
"Topic :: Internet :: WWW/HTTP :: Dynamic Content",
3127
],
3228
)

0 commit comments

Comments
 (0)