[foundation-web] Added memberlist.py, a tool to JSON dump the member list
- From: Tobias Mueller <tobiasmue src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [foundation-web] Added memberlist.py, a tool to JSON dump the member list
- Date: Wed, 6 Feb 2013 15:50:58 +0000 (UTC)
commit 4accb419928aee7469993a7ed14c0ea00c13e1f2
Author: Tobias Mueller (ideabox) <tobiasmue gnome org>
Date: Wed Feb 6 16:48:27 2013 +0100
Added memberlist.py, a tool to JSON dump the member list
It has simplejson as a requirement. Python >2.6 ships it by default
IIRC. There is a version of simplejson compatible with Python >2.4.
You also need to have MySQL set up via ~/.my.cnf as the file referenced
in the imports states.
bin/memberlist.py | 40 ++++++++++++++++++++++++++++++++++++++++
1 files changed, 40 insertions(+), 0 deletions(-)
---
diff --git a/bin/memberlist.py b/bin/memberlist.py
new file mode 100644
index 0000000..2ffebc7
--- /dev/null
+++ b/bin/memberlist.py
@@ -0,0 +1,40 @@
+#!/usr/bin/env python
+'''Prints the current member list as JSON'''
+
+try:
+ import json
+except ImportError:
+ import simplejson as json
+
+from get_renewees import execute_query, Member
+
+query = ("SET NAMES 'utf8'; "
+ "SELECT CONCAT(firstname, ';', lastname, ';', email, ';', "
+ " last_renewed_on) "
+ " FROM foundationmembers"
+ " WHERE DATE_SUB(CURDATE(), INTERVAL 2 YEAR) <= last_renewed_on"
+ " ORDER BY lastname, firstname")
+
+
+def get_current_electorate():
+ infile = execute_query(query)
+ memberlist = [Member.from_csv(line.strip()) for line in infile]
+
+ return memberlist
+
+
+def get_json_memberlist():
+ members = get_current_electorate()
+ objects = [
+ {'firstname': o.firstname,
+ 'lastname': o.lastname,
+ 'email': o.email,
+ 'last_renewed_on': o.token_or_last_renewed_on,
+ }
+ for o in members]
+
+ j = json.dumps(objects, indent=4)
+ return j
+
+if __name__ == '__main__':
+ print get_json_memberlist()
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]