Skip to content

Commit df0402c

Browse files
committed
moved client function docstrings from pusher.py to *_client.py
1 parent c424faf commit df0402c

File tree

5 files changed

+33
-48
lines changed

5 files changed

+33
-48
lines changed

pusher/http.py

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
absolute_import,
77
division)
88

9+
from pusher.util import doc_string
910
from pusher.errors import *
1011
from pusher.signature import sign
1112
from pusher.version import VERSION
@@ -34,14 +35,6 @@ def make_request(self, *args, **kwargs):
3435
return self.f(self.client, *args, **kwargs)
3536

3637

37-
def doc_string(doc):
38-
def decorator(f):
39-
f.__doc__ = doc
40-
return f
41-
42-
return decorator
43-
44-
4538
def request_method(f):
4639
@property
4740
@doc_string(f.__doc__)

pusher/notification_client.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,10 @@ def __init__(
3737

3838
@request_method
3939
def notify(self, interests, notification):
40+
"""Send push notifications, see:
41+
42+
https://github.com/pusher/pusher-http-python#push-notifications-beta
43+
"""
4044
if not isinstance(interests, list) and not isinstance(interests, set):
4145
raise TypeError("Interests must be a list or a set")
4246

pusher/pusher.py

Lines changed: 8 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@
1111
validate_channel,
1212
validate_socket_id,
1313
pusher_url_re,
14-
channel_name_re)
14+
channel_name_re,
15+
doc_string)
1516

1617
from pusher.signature import sign, verify
1718
from pusher.pusher_client import PusherClient
@@ -110,52 +111,32 @@ def from_env(cls, env='PUSHER_URL', **options):
110111
return cls.from_url(val, **options)
111112

112113

114+
@doc_string(PusherClient.trigger.__doc__)
113115
def trigger(self, channels, event_name, data, socket_id=None):
114-
'''
115-
Trigger an event on one or more channels, see:
116-
117-
http://pusher.com/docs/rest_api#method-post-event
118-
'''
119116
return self._pusher_client.trigger(
120117
channels, event_name, data, socket_id)
121118

122119

120+
@doc_string(PusherClient.trigger_batch.__doc__)
123121
def trigger_batch(self, batch=[], already_encoded=False):
124-
'''
125-
Trigger multiple events with a single HTTP call.
126-
127-
http://pusher.com/docs/rest_api#method-post-batch-events
128-
'''
129122
return self._pusher_client.trigger_batch(batch, already_encoded)
130123

131-
124+
@doc_string(PusherClient.channels_info.__doc__)
132125
def channels_info(self, prefix_filter=None, attributes=[]):
133-
'''
134-
Get information on multiple channels, see:
135-
136-
http://pusher.com/docs/rest_api#method-get-channels
137-
'''
138126
return self._pusher_client.channels_info(prefix_filter, attributes)
139127

140128

129+
@doc_string(PusherClient.channel_info.__doc__)
141130
def channel_info(self, channel, attributes=[]):
142-
'''
143-
Get information on a specific channel, see:
144-
145-
http://pusher.com/docs/rest_api#method-get-channel
146-
'''
147131
return self._pusher_client.channel_info(channel, attributes)
148132

149133

134+
@doc_string(PusherClient.users_info.__doc__)
150135
def users_info(self, channel):
151-
'''
152-
Fetch user ids currently subscribed to a presence channel
153-
154-
http://pusher.com/docs/rest_api#method-get-users
155-
'''
156136
return self._pusher_client.users_info(channel)
157137

158138

139+
@doc_string(NotificationClient.notify.__doc__)
159140
def notify(self, interest, notification):
160141
return self._notification_client.notify(interest, notification)
161142

pusher/pusher_client.py

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,10 @@ def __init__(
4848

4949
@request_method
5050
def trigger(self, channels, event_name, data, socket_id=None):
51+
"""Trigger an event on one or more channels, see:
52+
53+
http://pusher.com/docs/rest_api#method-post-event
54+
"""
5155
if isinstance(channels, six.string_types):
5256
channels = [channels]
5357

@@ -83,12 +87,10 @@ def trigger(self, channels, event_name, data, socket_id=None):
8387

8488
@request_method
8589
def trigger_batch(self, batch=[], already_encoded=False):
86-
'''
87-
Trigger multiple events with a single HTTP call.
90+
"""Trigger multiple events with a single HTTP call.
8891
8992
http://pusher.com/docs/rest_api#method-post-batch-events
90-
'''
91-
93+
"""
9294
if not already_encoded:
9395
for event in batch:
9496
event['data'] = data_to_string(event['data'],
@@ -103,11 +105,10 @@ def trigger_batch(self, batch=[], already_encoded=False):
103105

104106
@request_method
105107
def channels_info(self, prefix_filter=None, attributes=[]):
106-
'''
107-
Get information on multiple channels, see:
108+
"""Get information on multiple channels, see:
108109
109110
http://pusher.com/docs/rest_api#method-get-channels
110-
'''
111+
"""
111112
params = {}
112113
if attributes:
113114
params['info'] = join_attributes(attributes)
@@ -122,11 +123,10 @@ def channels_info(self, prefix_filter=None, attributes=[]):
122123

123124
@request_method
124125
def channel_info(self, channel, attributes=[]):
125-
'''
126-
Get information on a specific channel, see:
126+
"""Get information on a specific channel, see:
127127
128128
http://pusher.com/docs/rest_api#method-get-channel
129-
'''
129+
"""
130130
validate_channel(channel)
131131

132132
params = {}
@@ -139,11 +139,10 @@ def channel_info(self, channel, attributes=[]):
139139

140140
@request_method
141141
def users_info(self, channel):
142-
'''
143-
Fetch user ids currently subscribed to a presence channel
142+
"""Fetch user ids currently subscribed to a presence channel
144143
145144
http://pusher.com/docs/rest_api#method-get-users
146-
'''
145+
"""
147146
validate_channel(channel)
148147

149148
return Request(

pusher/util.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,3 +64,11 @@ def data_to_string(data, json_encoder):
6464

6565
else:
6666
return json.dumps(data, cls=json_encoder)
67+
68+
69+
def doc_string(doc):
70+
def decorator(f):
71+
f.__doc__ = doc
72+
return f
73+
74+
return decorator

0 commit comments

Comments
 (0)