Skip to content

Commit b6e372f

Browse files
author
Steven Cummings
committed
Added get_past_events
1 parent 89c4152 commit b6e372f

2 files changed

Lines changed: 45 additions & 4 deletions

File tree

README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,3 +22,8 @@ Example Usage
2222
9
2323
>>> next_meetup.event_url
2424
u'http://www.meetup.com/pythonkc/events/25940081/'
25+
>>> last_meetup = meetups.get_past_events()[0]
26+
>>> last_meetup.name
27+
u'Monthly Meetup: Google App Engine'
28+
>>> last_meetup.time
29+
datetime.datetime(2011, 7, 9, 14, 0, tzinfo=tzoffset(None, -18000))

pythonkc_meetups/client.py

Lines changed: 40 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -49,13 +49,21 @@ def __init__(self, api_key, http_timeout=1, http_retries=2):
4949

5050
def get_upcoming_events(self):
5151
"""
52-
Get the upcoming PythonKC meetup events.
52+
Get upcoming PythonKC meetup events.
5353
5454
Returns
5555
-------
5656
List of ``pythonkc_meetups.types.MeetupEvent``, ordered by event time,
5757
ascending.
5858
59+
Exceptions
60+
----------
61+
* PythonKCMeetupsBadJson
62+
* PythonKCMeetupsBadResponse
63+
* PythonKCMeetupsMeetupDown
64+
* PythonKCMeetupsNotJson
65+
* PythonKCMeetupsRateLimitExceeded
66+
5967
"""
6068

6169
query = urllib.urlencode({'key': self._api_key,
@@ -65,6 +73,34 @@ def get_upcoming_events(self):
6573
events = data['results']
6674
return [parse_event(event) for event in events]
6775

76+
def get_past_events(self):
77+
"""
78+
Get past PythonKC meetup events.
79+
80+
Returns
81+
-------
82+
List of ``pythonkc_meetups.types.MeetupEvent``, ordered by event time,
83+
descending.
84+
85+
Exceptions
86+
----------
87+
* PythonKCMeetupsBadJson
88+
* PythonKCMeetupsBadResponse
89+
* PythonKCMeetupsMeetupDown
90+
* PythonKCMeetupsNotJson
91+
* PythonKCMeetupsRateLimitExceeded
92+
93+
"""
94+
95+
query = urllib.urlencode({'key': self._api_key,
96+
'group_urlname': GROUP_URLNAME,
97+
'status': 'past',
98+
'desc': 'true'})
99+
url = '{0}?{1}'.format(EVENTS_URL, query)
100+
data = self._http_get_json(url)
101+
events = data['results']
102+
return [parse_event(event) for event in events]
103+
68104
def _http_get_json(self, url):
69105
"""
70106
Make an HTTP GET request to the specified URL, check that it returned a
@@ -82,10 +118,10 @@ def _http_get_json(self, url):
82118
Exceptions
83119
----------
84120
* PythonKCMeetupsBadJson
85-
* PythonKCMeetupsNotJson
121+
* PythonKCMeetupsBadResponse
86122
* PythonKCMeetupsMeetupDown
123+
* PythonKCMeetupsNotJson
87124
* PythonKCMeetupsRateLimitExceeded
88-
* PythonKCMeetupsBadResponse
89125
90126
"""
91127
response, content = self._http_get(url)
@@ -117,9 +153,9 @@ def _http_get(self, url):
117153
118154
Exceptions
119155
----------
156+
* PythonKCMeetupsBadResponse
120157
* PythonKCMeetupsMeetupDown
121158
* PythonKCMeetupsRateLimitExceeded
122-
* PythonKCMeetupsBadResponse
123159
124160
"""
125161
for try_number in range(self._http_retries + 1):

0 commit comments

Comments
 (0)