Skip to content

Commit d923b31

Browse files
committed
cleanup
1 parent 9649584 commit d923b31

5 files changed

Lines changed: 21 additions & 12 deletions

File tree

‎.travis.yml‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
language: python
22
python:
3-
- 2.6
3+
- 2.6
44
- 2.7
55
- 3.3
66
- 3.4
77
notifications:
88
email:
99
- thierryschellenbach@gmail.com
1010
after_success:
11-
- coveralls
11+
- coveralls

‎stream/client.py‎

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,13 @@
1212
class StreamClient(object):
1313
base_url = 'https://getstream.io/api/'
1414

15-
def __init__(self, api_key, api_secret, site_id, version='v1.0', timeout=3.0, base_url=None):
15+
def __init__(self, api_key, api_secret, app_id, version='v1.0', timeout=3.0, base_url=None):
1616
'''
1717
Initialize the client with the given api key and secret
1818
1919
:param api_key: the api key
2020
:param api_secret: the api secret
21-
:param base_url: (optionally overwrite the api base url)
21+
:param app_id: the app id
2222
2323
**Example usage**::
2424
@@ -39,7 +39,7 @@ def __init__(self, api_key, api_secret, site_id, version='v1.0', timeout=3.0, ba
3939
'''
4040
self.api_key = api_key
4141
self.api_secret = api_secret
42-
self.site_id = site_id
42+
self.site_id = app_id
4343
self.version = version
4444
self.timeout = timeout
4545
if base_url is not None:
@@ -53,7 +53,8 @@ def feed(self, feed_slug, user_id):
5353
'''
5454
Returns a Feed object
5555
56-
:param feed_id: the feed object
56+
:param feed_slug: the slug of the feed
57+
:param user_id: the user id
5758
'''
5859
from stream.feed import Feed
5960

‎stream/serializer.py‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
import datetime
22
import json
3+
import six
34

45
'''
56
Adds the ability to send date and datetime objects to the API
67
The date and datetime formats from the API are automatically supported and parsed
78
'''
8-
import six
9+
910

1011

1112
def _datetime_encoder(obj):

‎stream/signing.py‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,15 @@ def sign(api_secret, feed_id):
1111
'''
1212
Base64 encoded sha1 signature
1313
14-
:param secret: the secret
15-
:param feed_id: the feed_id to sign (commonly a feed id such as user:1)
14+
:param api_secret: the api secret
15+
:param feed_id: the feed_id to sign (commonly a feed id such as user1)
1616
1717
**Example**::
18-
signature = sign('secret', 'user:1')
18+
signature = sign('secret', 'user1')
1919
2020
'''
21-
key = hashlib.sha1((api_secret).encode('utf-8')).digest()
22-
signed = hmac.new(key, msg=feed_id.encode('utf8'), digestmod=hashlib.sha1)
21+
hashed_secret = hashlib.sha1((api_secret).encode('utf-8')).digest()
22+
signed = hmac.new(hashed_secret, msg=feed_id.encode('utf8'), digestmod=hashlib.sha1)
2323
digest = signed.digest()
2424
urlsafe_digest = b64_encode(digest)
2525
token = urlsafe_digest.decode('ascii')

‎stream/utils.py‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,13 @@
11

22

33
def validate_feed(feed_id):
4+
'''
5+
Validates the input is in the format of user:1
6+
7+
:param feed_id: a feed such as user:1
8+
9+
Raises ValueError if the format doesnt match
10+
'''
411
if len(feed_id.split(':')) != 2:
512
msg = 'Invalid feed_id spec %s, please specify the feed_id as feed_slug:feed_id'
613
raise ValueError(msg % feed_id)

0 commit comments

Comments
 (0)