Add help for command-line ceo
[mspang/pyceo.git] / ceo / console / inactive.py
1 from ceo import members, terms
2
3 def max_term(term1, term2):
4     if terms.compare(term1, term2) > 0:
5         return term1
6     else:
7         return term2
8
9 class Inactive:
10   help = '''
11 inactive delta-terms
12
13 Prints a list of accounts that have been inactive (i.e. not unpaid) for
14 delta-terms.
15 '''
16   def main(self, args):
17     if len(args) != 1:
18         print self.help
19         return
20     delta = int(args[0])
21     mlist = members.list_all()
22     for member in mlist.values():
23         term = "f0000"
24         term = reduce(max_term, member.get("term", []), term)
25         term = reduce(max_term, member.get("nonMemberTerm", []), term)
26         if terms.delta(term, terms.current()) >= delta:
27             print "%s %s" % (member['uid'][0].ljust(12), term)