You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@community.apache.org by se...@apache.org on 2018/01/06 22:39:46 UTC
svn commit: r1820426 - /comdev/tools/meetups.py
Author: sebb
Date: Sat Jan 6 22:39:46 2018
New Revision: 1820426
URL: http://svn.apache.org/viewvc?rev=1820426&view=rev
Log:
Skip meetings in unrelated group categories
Modified:
comdev/tools/meetups.py
Modified: comdev/tools/meetups.py
URL: http://svn.apache.org/viewvc/comdev/tools/meetups.py?rev=1820426&r1=1820425&r2=1820426&view=diff
==============================================================================
--- comdev/tools/meetups.py (original)
+++ comdev/tools/meetups.py Sat Jan 6 22:39:46 2018
@@ -12,10 +12,14 @@ import io
# is formatted to paste onto a mailing list. One is suggested tweets.
# One is for pasting into apache.org/events/meetups.mdtext
#
-# Note that these are POSSIBLY Apache-related. Typically, there's around
-# a 50% false positive rate, what with hiking trails, native American
-# dance enthusiasts, and heilcopter fans. These lists MUST be manually
-# filtered before they are used anywhere publicly.
+# Note that these are POSSIBLY Apache-related.
+# It would be nice to only select group categories that are Apache-related,
+# but it does not appear to be possible to enumerate them. There may be new ones.
+# So the code skips groups in categories which have referenced Apache in the past
+# but which are clearly not relevant.
+#
+# These lists should be manually filtered before they are used anywhere publicly.
+# If additional references slip through, please update the skip_groups field.
#
# See also note below about the API key.
#
@@ -39,7 +43,8 @@ def importMeetups():
# Radius is defined around Lexington, KY, but it's infinite radius, so
# should work everywhere.
- url = "https://api.meetup.com/2/open_events?&sign=true&photo-host=public&state=ky&city=lexington&country=usa&text=apache&radius=10000&sign=true&key=" + key
+ # Only want data for next fortnight (default is 1 month)
+ url = "https://api.meetup.com/2/open_events?time=,2w&text=apache&sign=true&key=" + key
print "Fetching meetups ..."
@@ -91,7 +96,11 @@ def createFiles():
nowts = time.mktime(now.timetuple())
with open('meetups.json') as data_file:
- meetups = json.load(data_file)
+ tmp = json.load(data_file)
+
+ # sort here - the 'order=time' API qualifier does not seem to work properly
+ # using an exact sort (i.e. with id) helps reduce arbitrary ordering changes in the output file
+ meetups = sorted(tmp, key=lambda k: str(k['time'] +k['utc_offset']) + k['id'])
with open('groups.json') as data_file:
grps = json.load(data_file)
@@ -141,6 +150,8 @@ We also [list the major Apache-related c
Please feel free to notify us (dev@community.apache.org) if you're
aware of events that are missing, Thanks. Also, the instructions for updating this page are in the [README](/events/README.txt) file in this directory.
+N.B. Dates are in local-time
+
'''))
# Standard intro to mailing list post
@@ -149,6 +160,8 @@ Apache enthusiasts are likely to be pres
of others, please let me know, and/or add them to
http://apache.org/events
+N.B. Dates are in local-time
+
If there's a meetup in your area, please consider attending. If you
attend, please consider taking a few photos, and possibly even writing
up a brief summary of what was covered.
@@ -157,13 +170,15 @@ up a brief summary of what was covered.
'''))
+ # These group['shortname'] values are unlikely to be relevant:
+ skip_groups = dict.fromkeys(['arts-culture', 'health-wellbeing',
+ 'hobbies-crafts', 'language', 'music', 'new-age-spirituality',
+ 'outdoors-adventure', 'photography', 'singles'])
+ used_groups = {} # collect the unskipped groups
+
for meetup in meetups:
eventts = int( meetup['time'] + meetup['utc_offset'] )
- # Skip it if it's more than two weeks away
- if eventts > twoweeklater:
- continue
-
eventtime = date.fromtimestamp( eventts/1000 )
t = eventtime.strftime("%A %B %d")
@@ -176,11 +191,39 @@ up a brief summary of what was covered.
# Group information ...
grp = grp_deets[ meetup['group']['id'] ]
+ # is the group category unlikely to be related to the ASF?
+ shortname = grp['category']['shortname']
+ if shortname in skip_groups:
+ print "=== Skipping " + shortname.encode('utf_8') + ' -- ' + meetup['name'].encode('utf_8')
+ continue
+ used_groups[shortname] = grp
+
+ # Pick up the location details from the venue, as it may be different from group loc
+ state = None
+ country = ''
+ if 'venue' in meetup:
+ city = meetup['venue']['city']
+ country = meetup['venue']['country'].upper()
+ if 'state' in meetup['venue']:
+ state = meetup['venue']['state'].upper()
+ else: # state may be missing from venue, try to fix this
+ # state is not always correct outside US
+ # if the group is based at the same city, use its state:
+ if country == 'US' and grp['city'] == city and 'state' in grp.keys():
+ state = grp['state']
+ else:
+ city = 'No venue specified; group is based in ' + grp['city']
+ if 'state' in grp.keys():
+ state = grp['state']
+ country = grp['country']
+
# For the website ...
- eventout = "* " + t + ' [' + meetup['name'] + '](' + meetup['event_url'] + "), " + grp['city'] + ', '
- if 'state' in grp.keys():
- eventout = eventout + grp['state'] + ', '
- eventout = eventout + grp['country'] + "\n"
+ eventout = "* " + t + ' [' + meetup['name'] + '](' + meetup['event_url'] + "), " + city
+ if state:
+ eventout = eventout + ', ' + state
+ if country != '':
+ eventout = eventout + ', '
+ eventout = eventout + country + "\n"
website.write( unicode(eventout) )
# For everything else, a week is enough
@@ -188,17 +231,21 @@ up a brief summary of what was covered.
continue
# For Twitter
- eventout = t + ' in ' + grp['city'] + ', '
- if 'state' in grp.keys():
- eventout = eventout + grp['state'] + ', '
- eventout = eventout + grp['country'] + ': ' + meetup['name'] + ' - ' + meetup['event_url'] + " #Apache #Meetup\n"
+ eventout = t + ' in ' + city
+ if state:
+ eventout = eventout + ', ' + state
+ if country != '':
+ eventout = eventout + ', '
+ eventout = eventout + country + ': ' + meetup['name'] + ' - ' + meetup['event_url'] + " #Apache #Meetup\n"
tweets.write( unicode( eventout ))
# For mailing list
- eventout = '* ' + t + ' in ' + grp['city'] + ', '
- if 'state' in grp.keys():
- eventout = eventout + grp['state'] + ', '
- eventout = eventout + grp['country'] + ': ' + meetup['name'] + ' - ' + meetup['event_url'] + "\n\n"
+ eventout = '* ' + t + ' in ' + city
+ if state:
+ eventout = eventout + ', ' + state
+ if country != '':
+ eventout = eventout + ', '
+ eventout = eventout + country + ': ' + meetup['name'] + ' - ' + meetup['event_url'] + "\n\n"
mlist.write( unicode( eventout ))
# Barn door
@@ -206,5 +253,10 @@ up a brief summary of what was covered.
mlist.close()
website.close()
+ # show the groups in case some need to be added to skip_groups
+ print "Groups used:"
+ for g in used_groups:
+ print used_groups[g]['category']
+
print "Done! Check out meetups.mlist, meetups.tweet and meetups.mdtext\n"