Skip to content

Commit a3d11a2

Browse files
authored
Merge pull request #1 from okdtsk/review_okdtsk
Review by Tasuku OKUDA
2 parents f1917e3 + 91ffe5b commit a3d11a2

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+624
-179
lines changed

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@
186186
same "printed page" as the copyright notice for easier
187187
identification within third-party archives.
188188

189-
Copyright {yyyy} {name of copyright owner}
189+
Copyright 2016 LINE Corporation.
190190

191191
Licensed under the Apache License, Version 2.0 (the "License");
192192
you may not use this file except in compliance with the License.

examples/flask-echo/app.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,16 @@
11
# -*- coding: utf-8 -*-
2+
# Licensed under the Apache License, Version 2.0 (the "License"); you may
3+
# not use this file except in compliance with the License. You may obtain
4+
# a copy of the License at
5+
#
6+
# http://www.apache.org/licenses/LICENSE-2.0
7+
#
8+
# Unless required by applicable law or agreed to in writing, software
9+
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
10+
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
11+
# License for the specific language governing permissions and limitations
12+
# under the License.
13+
214
from __future__ import unicode_literals
315

416
import os

examples/flask-echo/app_with_handler.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,16 @@
1+
# -*- coding: utf-8 -*-
2+
# Licensed under the Apache License, Version 2.0 (the "License"); you may
3+
# not use this file except in compliance with the License. You may obtain
4+
# a copy of the License at
5+
#
6+
# http://www.apache.org/licenses/LICENSE-2.0
7+
#
8+
# Unless required by applicable law or agreed to in writing, software
9+
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
10+
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
11+
# License for the specific language governing permissions and limitations
12+
# under the License.
13+
114
import os
215
import sys
316
from argparse import ArgumentParser

examples/flask-kitchensink/app.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,16 @@
11
# -*- coding: utf-8 -*-
2+
# Licensed under the Apache License, Version 2.0 (the "License"); you may
3+
# not use this file except in compliance with the License. You may obtain
4+
# a copy of the License at
5+
#
6+
# http://www.apache.org/licenses/LICENSE-2.0
7+
#
8+
# Unless required by applicable law or agreed to in writing, software
9+
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
10+
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
11+
# License for the specific language governing permissions and limitations
12+
# under the License.
13+
214
from __future__ import unicode_literals
315

416
import errno

examples/simple-server-echo/app.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,16 @@
11
# -*- coding: utf-8 -*-
2+
# Licensed under the Apache License, Version 2.0 (the "License"); you may
3+
# not use this file except in compliance with the License. You may obtain
4+
# a copy of the License at
5+
#
6+
# http://www.apache.org/licenses/LICENSE-2.0
7+
#
8+
# Unless required by applicable law or agreed to in writing, software
9+
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
10+
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
11+
# License for the specific language governing permissions and limitations
12+
# under the License.
13+
214
import os
315
import sys
416
import wsgiref.simple_server

linebot/__about__.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,22 @@
11
# -*- coding: utf-8 -*-
2+
# Licensed under the Apache License, Version 2.0 (the 'License'); you may
3+
# not use this file except in compliance with the License. You may obtain
4+
# a copy of the License at
5+
#
6+
# http://www.apache.org/licenses/LICENSE-2.0
7+
#
8+
# Unless required by applicable law or agreed to in writing, software
9+
# distributed under the License is distributed on an 'AS IS' BASIS, WITHOUT
10+
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
11+
# License for the specific language governing permissions and limitations
12+
# under the License.
13+
214
from __future__ import unicode_literals
315

416
__version__ = '0.1.0'
17+
__author__ = 'LINE Corporation'
18+
__copyright__ = 'Copyright 2016, LINE Corporation'
19+
__license__ = 'Apache 2.0'
520

621
__all__ = (
722
'__version__'

linebot/__init__.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,16 @@
11
# -*- coding: utf-8 -*-
2+
# Licensed under the Apache License, Version 2.0 (the "License"); you may
3+
# not use this file except in compliance with the License. You may obtain
4+
# a copy of the License at
5+
#
6+
# http://www.apache.org/licenses/LICENSE-2.0
7+
#
8+
# Unless required by applicable law or agreed to in writing, software
9+
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
10+
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
11+
# License for the specific language governing permissions and limitations
12+
# under the License.
13+
214
from __future__ import unicode_literals
315

416
from .__about__ import (

linebot/api.py

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,32 @@
11
# -*- coding: utf-8 -*-
2+
# Licensed under the Apache License, Version 2.0 (the "License"); you may
3+
# not use this file except in compliance with the License. You may obtain
4+
# a copy of the License at
5+
#
6+
# http://www.apache.org/licenses/LICENSE-2.0
7+
#
8+
# Unless required by applicable law or agreed to in writing, software
9+
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
10+
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
11+
# License for the specific language governing permissions and limitations
12+
# under the License.
13+
214
from __future__ import unicode_literals
315

416
import json
517

618
from .__about__ import __version__
719
from .exceptions import LineBotApiError
8-
from .http_client import (
9-
RequestsHttpClient, HttpClient
10-
)
20+
from .http_client import RequestsHttpClient
1121
from .models.error import Error
1222
from .models.profile import Profile
1323

1424

1525
class LineBotApi(object):
1626
DEFAULT_API_ENDPOINT = 'https://api.line.me'
1727

18-
def __init__(
19-
self, channel_access_token, endpoint=DEFAULT_API_ENDPOINT,
20-
timeout=HttpClient.DEFAULT_TIMEOUT, http_client=RequestsHttpClient
21-
):
28+
def __init__(self, channel_access_token, endpoint=DEFAULT_API_ENDPOINT,
29+
timeout=RequestsHttpClient.DEFAULT_TIMEOUT, http_client=RequestsHttpClient):
2230
"""Constructor of LineBotApi Client
2331
2432
Args:
@@ -114,9 +122,7 @@ def get_profile(self, user_id, timeout=None):
114122
)
115123
return Profile.new_from_json_dict(json.loads(body))
116124

117-
def get_content_stream(
118-
self, message_id, chunk_size=1024, timeout=None
119-
):
125+
def get_content_stream(self, message_id, chunk_size=1024, timeout=None):
120126
"""Call get content API
121127
122128
Retrieve image, video, and audio data sent by users.
@@ -181,9 +187,7 @@ def _get(self, path, timeout=None):
181187
self.__check_error(response)
182188
return response.body
183189

184-
def _get_stream(
185-
self, path, chunk_size=1024, decode_unicode=False, timeout=None
186-
):
190+
def _get_stream(self, path, chunk_size=1024, decode_unicode=False, timeout=None):
187191
url = self.endpoint + path
188192

189193
response = self.http_client.get_stream(

linebot/exceptions.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,16 @@
11
# -*- coding: utf-8 -*-
2+
# Licensed under the Apache License, Version 2.0 (the "License"); you may
3+
# not use this file except in compliance with the License. You may obtain
4+
# a copy of the License at
5+
#
6+
# http://www.apache.org/licenses/LICENSE-2.0
7+
#
8+
# Unless required by applicable law or agreed to in writing, software
9+
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
10+
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
11+
# License for the specific language governing permissions and limitations
12+
# under the License.
13+
214
from __future__ import unicode_literals
315

416

linebot/http_client.py

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,27 @@
11
# -*- coding: utf-8 -*-
2+
# Licensed under the Apache License, Version 2.0 (the "License"); you may
3+
# not use this file except in compliance with the License. You may obtain
4+
# a copy of the License at
5+
#
6+
# http://www.apache.org/licenses/LICENSE-2.0
7+
#
8+
# Unless required by applicable law or agreed to in writing, software
9+
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
10+
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
11+
# License for the specific language governing permissions and limitations
12+
# under the License.
13+
214
from __future__ import unicode_literals
315

16+
from abc import ABCMeta, abstractmethod
17+
from future.utils import with_metaclass
418
import requests
519

620

7-
class HttpClient(object):
21+
class HttpClient(with_metaclass(ABCMeta)):
822
DEFAULT_TIMEOUT = 5
923

10-
def __init__(
11-
self, timeout=DEFAULT_TIMEOUT
12-
):
24+
def __init__(self, timeout=DEFAULT_TIMEOUT):
1325
"""Constructor of HttpClient
1426
1527
Args:
@@ -19,6 +31,7 @@ def __init__(
1931

2032
self.timeout = timeout
2133

34+
@abstractmethod
2235
def get(self, url, headers=None, params=None, timeout=None):
2336
"""GET request
2437
@@ -32,6 +45,7 @@ def get(self, url, headers=None, params=None, timeout=None):
3245
"""
3346
raise NotImplementedError
3447

48+
@abstractmethod
3549
def get_stream(self, url, headers=None, params=None, timeout=None,
3650
chunk_size=1024, decode_unicode=False):
3751
"""GET request. response is chunk content.
@@ -47,6 +61,7 @@ def get_stream(self, url, headers=None, params=None, timeout=None,
4761
"""
4862
raise NotImplementedError
4963

64+
@abstractmethod
5065
def post(self, url, headers=None, data=None, timeout=None):
5166
"""POST request.
5267
@@ -61,9 +76,7 @@ def post(self, url, headers=None, data=None, timeout=None):
6176

6277

6378
class RequestsHttpClient(HttpClient):
64-
def __init__(
65-
self, timeout=HttpClient.DEFAULT_TIMEOUT
66-
):
79+
def __init__(self, timeout=HttpClient.DEFAULT_TIMEOUT):
6780
"""Constructor of RequestsHttpClient
6881
6982
'requests' implementation.

0 commit comments

Comments
 (0)