Skip to content
This repository was archived by the owner on Feb 21, 2019. It is now read-only.

Commit 899cdb4

Browse files
author
Nathan Hamblen
committed
Revert "uses strptime for date and time"
some time zones are not understood, causing converttime to fail This reverts commit 48810c8.
1 parent 48810c8 commit 899cdb4

File tree

1 file changed

+18
-35
lines changed

1 file changed

+18
-35
lines changed

meetup_api_client.py

Lines changed: 18 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
#!/usr/bin/env python
22
from __future__ import with_statement
33

4+
import datetime
45
import time
56
import types
67
from urllib import urlencode
78
from urllib2 import HTTPError, HTTPErrorProcessor, urlopen, Request, build_opener
8-
from datetime import datetime
99

1010
import oauth
1111
import MultipartPostHandler as mph
@@ -231,31 +231,21 @@ def __init__(self, json, uritype):
231231
def __str__(self):
232232
return 'meta: ' + str(self.meta) + '\n' + str(self.results)
233233

234-
def converttime(str):
235-
"""Given a time string in Meetup's format, return a datetime."""
236-
MEETUP_DATE_FORMAT = '%a %b %d %H:%M:%S %Z %Y'
237-
return datetime.strptime(str, MEETUP_DATE_FORMAT)
238-
239234
class API_Item(object):
240235
"""Base class for an item in a result set returned by the API."""
241236

242237
datafields = [] #override
243-
timefields = [] #override
244238
def __init__(self, properties):
245-
"""load properties that are relevant to all items (id, etc.)"""
246-
for field in self.datafields:
247-
self.__setattr__(field, properties[field])
248-
for field in self.timefields:
249-
self.__setattr__(field, converttime(properties[field]))
250-
self.json = properties
239+
"""load properties that are relevant to all items (id, etc.)"""
240+
for field in self.datafields:
241+
self.__setattr__(field, properties[field])
242+
self.json = properties
251243

252244
def __repr__(self):
253245
return self.__str__();
254246

255247
class Member(API_Item):
256-
datafields = ['bio', 'name', 'link','id','photo_url', 'zip','lat','lon',
257-
'city','state','country']
258-
timefields = ['joined', 'visited']
248+
datafields = ['bio', 'name', 'link','id','photo_url', 'zip','lat','lon','city','state','country','joined','visited']
259249

260250
def get_groups(self, apiclient, **extraparams):
261251
extraparams.update({'member_id':self.id})
@@ -265,19 +255,14 @@ def __str__(self):
265255
return "Member %s (url: %s)" % (self.name, self.link)
266256

267257
class Photo(API_Item):
268-
datafields = ['albumtitle', 'link', 'member_url', 'descr', 'photo_url',
269-
'photo_urls', 'thumb_urls']
270-
timefields = ['created']
258+
datafields = ['albumtitle', 'link', 'member_url', 'descr', 'created', 'photo_url', 'photo_urls', 'thumb_urls']
271259

272260
def __str__(self):
273261
return "Photo located at %s posted by member at %s: (%s)" % (self.link, self.member_url, self.descr)
274262

275263

276264
class Event(API_Item):
277-
datafields = ['id', 'name', 'photo_url', 'event_url', 'venue_lat',
278-
'venue_lon', 'description', 'status', 'rsvpcount',
279-
'no_rsvpcount', 'maybe_rsvpcount']
280-
timefields = ['time', 'updated']
265+
datafields = ['id', 'name', 'updated', 'time', 'photo_url', 'event_url', 'venue_lat', 'venue_lon', 'description', 'status', 'rsvpcount', 'no_rsvpcount', 'maybe_rsvpcount']
281266

282267
def __str__(self):
283268
return 'Event %s named %s at %s (url: %s)' % (self.id, self.name, self.time, self.event_url)
@@ -287,18 +272,17 @@ def get_rsvps(self, apiclient, **extraparams):
287272
return apiclient.get_rsvps(**extraparams)
288273

289274
class Rsvp(API_Item):
290-
datafields = ['name', 'link', 'comment','zip','coord','lon','city','state',
291-
'country','response','guests','answers']
292-
timefields = ['updated', 'created']
275+
datafields = ['name', 'link', 'comment','zip','coord','lon','city','state','country','response','guests','answers','updated','created']
293276

294277
def __str__(self):
295278
return 'Rsvp by %s (%s) with comment: %s' % (self.name, self.link, self.comment)
296279

297280
class Group(API_Item):
298-
datafields = [ 'id','name','group_urlname','link', 'members','photo_url',
299-
'description','zip','lat','lon', 'city','state','country',
300-
'organizerProfileURL', 'topics']
301-
timefields = ['created', 'updated']
281+
datafields = [ 'id','name','group_urlname','link','updated',\
282+
'members','created','photo_url',\
283+
'description','zip','lat','lon',\
284+
'city','state','country','organizerProfileURL', \
285+
'topics']
302286

303287
def __str__(self):
304288
return "%s (%s)" % (self.name, self.link)
@@ -332,8 +316,8 @@ def get_events(self,apiclient, **extraparams):
332316
return apiclient.get_events(**extraparams)
333317

334318
class Topic(API_Item):
335-
datafields = ['id','name','description','link', 'members','urlkey']
336-
timefields = ['updated']
319+
datafields = ['id','name','description','link','updated',\
320+
'members','urlkey']
337321

338322
def __str__(self):
339323
return "%s with %s members (%s)" % (self.name, self.members,
@@ -348,9 +332,8 @@ def get_photos(self, apiclient, **extraparams):
348332
return apiclient.get_photos(**extraparams)
349333

350334
class Comment(API_Item):
351-
datafields = ['name','link','comment','rating','photo_url',
352-
'lat','lon','country','city','state']
353-
timefields = ['created']
335+
datafields = ['name','link','comment','rating','photo_url',\
336+
'created','lat','lon','country','city','state']
354337

355338
def __str__(self):
356339
return "Comment from %s (%s)" % (self.name, self.link)

0 commit comments

Comments
 (0)