def event_answers(event_id): """Return a dict mapping {"yes","no","maybe"} onto (username, num_guests) pairs.""" answers = defaultdict(list) rsvps = meetup("2/rsvps", event_id=event_id) for rsvp in rsvps: answers[rsvp['response']].append((rsvp['member']['name'], rsvp['guests'])) return answers
def list_events(**kwargs): """Return a list of events, from the 2/events Meetup API call.""" kwargs.setdefault('group_id', GROUP_ID) events = meetup("2/events", **kwargs) for event in events: event['when'] = time.strftime("%d %b %Y", time.localtime(event['time']//1000)) return events
def event_attendees(event_id): """Return the set of attendees in the yes or waiting list.""" rsvps = meetup("2/rsvps", event_id=event_id) attendees = set() for rsvp in rsvps: if rsvp['response'] in ['yes', 'waitlist']: member = rsvp['member'] attendees.add((member['member_id'], member['name'])) return attendees
def group_members(**kwargs): """Return a list of the members of a group.""" members = meetup.meetup("members", **kwargs) for m in members: last_visit = time.strptime(m['visited'][:-4], "%Y-%m-%d %H:%M:%S") m['visitage'] = time.time() - time.mktime(last_visit) joined = time.strptime(m['joined'].replace("EDT ", "").replace("EST ", ""), "%a %b %d %H:%M:%S %Y") m['joinage'] = time.time() - time.mktime(joined) return members
def group_members(**kwargs): """Return a list of the members of a group.""" members = meetup.meetup("members", **kwargs) for m in members: last_visit = time.strptime(m['visited'][:-4], "%Y-%m-%d %H:%M:%S") m['visitage'] = time.time() - time.mktime(last_visit) joined = time.strptime(m['joined'].replace("EDT ", "").replace("EST ", ""), "%a %b %d %H:%M:%S %Y") m['joinage'] = time.time() - time.mktime(joined) all_names.add(m['name'].lower()) gend = guess_gender(m['name']) if gend not in ['male', 'female']: unknown_names.add(m['name'].lower()) gend = "unknown" m['gender'] = gend return members
def test_second_tuesday_of_may_2013(self): self.assertEqual(meetup(2013, 5, "2nd", "Tuesday"), date(2013, 5, 14))
def test_second_wednesday_of_july_2013(self): self.assertEqual(meetup(2013, 7, "2nd", "Wednesday"), date(2013, 7, 10))
def test_tuesteenth_of_march_2013(self): self.assertEqual(meetup(2013, 3, "teenth", "Tuesday"), date(2013, 3, 19))
def test_last_wednesday_of_december_2014(self): self.assertEqual( meetup(2014, 12, 'last', 'Wednesday'), date(2014, 12, 31))
def test_second_sunday_of_april_2013(self): self.assertEqual(meetup(2013, 4, "2nd", "Sunday"), date(2013, 4, 14))
def test_first_friday_of_december_2012(self): self.assertEqual( meetup(2012, 12, '1st', 'Friday'), date(2012, 12, 7))
def test_thursteenth_of_september_2013(self): self.assertEqual( meetup(2013, 9, 'teenth', 'Thursday'), date(2013, 9, 19))
def test_second_saturday_of_january_2013(self): self.assertEqual(meetup(2013, 1, "2nd", "Saturday"), date(2013, 1, 12))
def test_thursteenth_of_may_2013(self): self.assertEqual( meetup(2013, 5, 'teenth', 'Thursday'), date(2013, 5, 16))
def test_thursteenth_of_june_2013(self): self.assertEqual( meetup(2013, 6, 'teenth', 'Thursday'), date(2013, 6, 13))
def test_wednesteenth_of_june_2013(self): self.assertEqual( meetup(2013, 6, 'teenth', 'Wednesday'), date(2013, 6, 19))
def test_nonexistent_fifth_monday_of_february_2015(self): with self.assertRaisesWithMessage(MeetupDayException): meetup(2015, 2, '5th', 'Monday')
def test_fifth_monday_of_march_2015(self): self.assertEqual( meetup(2015, 3, '5th', 'Monday'), date(2015, 3, 30))
def test_second_thursday_of_september_2013(self): self.assertEqual(meetup(2013, 9, "2nd", "Thursday"), date(2013, 9, 12))
def test_friteenth_of_april_2013(self): self.assertEqual( meetup(2013, 4, 'teenth', 'Friday'), date(2013, 4, 19))
def test_second_friday_of_november_2013(self): self.assertEqual(meetup(2013, 11, "2nd", "Friday"), date(2013, 11, 8))
def test_friteenth_of_august_2013(self): self.assertEqual( meetup(2013, 8, 'teenth', 'Friday'), date(2013, 8, 16))
def test_second_saturday_of_february_2013(self): self.assertEqual(meetup(2013, 2, "2nd", "Saturday"), date(2013, 2, 9))
def test_friteenth_of_september_2013(self): self.assertEqual( meetup(2013, 9, 'teenth', 'Friday'), date(2013, 9, 13))
def test_third_monday_of_april_2013(self): self.assertEqual(meetup(2013, 4, "3rd", "Monday"), date(2013, 4, 15))
def test_saturteenth_of_february_2013(self): self.assertEqual( meetup(2013, 2, 'teenth', 'Saturday'), date(2013, 2, 16))
def test_third_thursday_of_october_2013(self): self.assertEqual(meetup(2013, 10, "3rd", "Thursday"), date(2013, 10, 17))
def test_saturteenth_of_april_2013(self): self.assertEqual( meetup(2013, 4, 'teenth', 'Saturday'), date(2013, 4, 13))
def test_third_saturday_of_january_2013(self): self.assertEqual(meetup(2013, 1, "3rd", "Saturday"), date(2013, 1, 19))
def test_saturteenth_of_october_2013(self): self.assertEqual( meetup(2013, 10, 'teenth', 'Saturday'), date(2013, 10, 19))
def test_second_monday_of_april_2013(self): self.assertEqual(meetup(2013, 4, "2nd", "Monday"), date(2013, 4, 8))
def test_sunteenth_of_may_2013(self): self.assertEqual( meetup(2013, 5, 'teenth', 'Sunday'), date(2013, 5, 19))
def test_second_tuesday_of_june_2013(self): self.assertEqual(meetup(2013, 6, "2nd", "Tuesday"), date(2013, 6, 11))
def test_sunteenth_of_june_2013(self): self.assertEqual( meetup(2013, 6, 'teenth', 'Sunday'), date(2013, 6, 16))
def test_second_wednesday_of_august_2013(self): self.assertEqual(meetup(2013, 8, "2nd", "Wednesday"), date(2013, 8, 14))
def test_sunteenth_of_october_2013(self): self.assertEqual( meetup(2013, 10, 'teenth', 'Sunday'), date(2013, 10, 13))
def test_second_thursday_of_october_2013(self): self.assertEqual(meetup(2013, 10, "2nd", "Thursday"), date(2013, 10, 10))
def test_monteenth_of_may_2013(self): self.assertEqual( meetup(2013, 5, 'teenth', 'Monday'), date(2013, 5, 13))
def test_second_friday_of_december_2013(self): self.assertEqual(meetup(2013, 12, "2nd", "Friday"), date(2013, 12, 13))
def test_first_monday_of_march_2013(self): self.assertEqual( meetup(2013, 3, '1st', 'Monday'), date(2013, 3, 4))
def test_monteenth_of_september_2013(self): self.assertEqual(meetup(2013, 9, "teenth", "Monday"), date(2013, 9, 16))
def test_first_monday_of_april_2013(self): self.assertEqual( meetup(2013, 4, '1st', 'Monday'), date(2013, 4, 1))
def test_second_sunday_of_march_2013(self): self.assertEqual(meetup(2013, 3, "2nd", "Sunday"), date(2013, 3, 10))
def test_third_tuesday_of_june_2013(self): self.assertEqual(meetup(2013, 6, "3rd", "Tuesday"), date(2013, 6, 18))
def test_third_monday_of_march_2013(self): self.assertEqual(meetup(2013, 3, "3rd", "Monday"), date(2013, 3, 18))
def test_third_wednesday_of_august_2013(self): self.assertEqual(meetup(2013, 8, "3rd", "Wednesday"), date(2013, 8, 21))
def test_third_tuesday_of_may_2013(self): self.assertEqual(meetup(2013, 5, "3rd", "Tuesday"), date(2013, 5, 21))
def test_last_sunday_of_february_2015(self): self.assertEqual( meetup(2015, 2, 'last', 'Sunday'), date(2015, 2, 22))
def test_third_wednesday_of_july_2013(self): self.assertEqual(meetup(2013, 7, "3rd", "Wednesday"), date(2013, 7, 17))
def test_first_saturday_of_february_2013(self): self.assertEqual(meetup(2013, 2, "1st", "Saturday"), date(2013, 2, 2))
def test_third_thursday_of_september_2013(self): self.assertEqual(meetup(2013, 9, "3rd", "Thursday"), date(2013, 9, 19))
def test_monteenth_of_august_2013(self): self.assertEqual(meetup(2013, 8, "teenth", "Monday"), date(2013, 8, 19))
def test_third_friday_of_november_2013(self): self.assertEqual(meetup(2013, 11, "3rd", "Friday"), date(2013, 11, 15))
def test_wednesteenth_of_february_2013(self): self.assertEqual( meetup(2013, 2, 'teenth', 'Wednesday'), date(2013, 2, 13))
def test_third_friday_of_december_2013(self): self.assertEqual(meetup(2013, 12, "3rd", "Friday"), date(2013, 12, 20))
def test_last_sunday_of_april_2013(self): self.assertEqual( meetup(2013, 4, 'last', 'Sunday'), date(2013, 4, 28))
def test_first_sunday_of_march_2013(self): self.assertEqual(meetup(2013, 3, "1st", "Sunday"), date(2013, 3, 3))
def test_last_wednesday_of_february_2012(self): self.assertEqual( meetup(2012, 2, 'last', 'Wednesday'), date(2012, 2, 29))
def test_first_sunday_of_april_2013(self): self.assertEqual(meetup(2013, 4, "1st", "Sunday"), date(2013, 4, 7))
def test_last_sunday_of_march_2013(self): self.assertEqual( meetup(2013, 3, 'last', 'Sunday'), date(2013, 3, 31))