From fdcff72d83dc284dd04459a8692ed4774f4d0543 Mon Sep 17 00:00:00 2001 From: David Bartley Date: Tue, 1 Apr 2008 22:12:00 -0400 Subject: [PATCH] Add mathsoclist command --- ceo/console/main.py | 2 ++ ceo/console/mathsoclist.py | 29 +++++++++++++++++++++++++++++ 2 files changed, 31 insertions(+) create mode 100644 ceo/console/mathsoclist.py diff --git a/ceo/console/main.py b/ceo/console/main.py index f43150d..434f49b 100644 --- a/ceo/console/main.py +++ b/ceo/console/main.py @@ -5,12 +5,14 @@ from ceo.console.memberlist import MemberList from ceo.console.updateprograms import UpdatePrograms from ceo.console.expiredaccounts import ExpiredAccounts from ceo.console.inactive import Inactive +from ceo.console.mathsoclist import MathSocList commands = { 'memberlist' : MemberList(), 'updateprograms' : UpdatePrograms(), 'expiredaccounts' : ExpiredAccounts(), 'inactive': Inactive(), + 'mathsoclist' : MathSocList(), } help_opts = [ '--help', '-h' ] diff --git a/ceo/console/mathsoclist.py b/ceo/console/mathsoclist.py new file mode 100644 index 0000000..d977665 --- /dev/null +++ b/ceo/console/mathsoclist.py @@ -0,0 +1,29 @@ +from ceo import members, terms +import re + +class MathSocList: + help = ''' +mathsoclist + +Prints a current list of members that are likely to be paying MathSoc members. +''' + + regex = ".*(mat/|vpa/se|computer science|math).*" + noinc = [ "dtbartle", "dlgawley", "cpdohert", "mbiggs", "tmyklebu" ] + + def main(self, args): + regex = re.compile(self.regex) + mlist = members.list_term(terms.current()) + dns = mlist.keys() + dns.sort() + for dn in dns: + member = mlist[dn] + if member['uid'][0] in self.noinc: + continue + program = member.get('program', [''])[0] + if regex.match(program.lower()) != None: + print '%s %s %s' % ( + member['uid'][0].ljust(12), + member['cn'][0].ljust(30), + member.get('program', [''])[0] + )