diff --git a/templates/quick_view.tmpl b/templates/quick_view.tmpl new file mode 100644 index 0000000..6a5cc55 --- /dev/null +++ b/templates/quick_view.tmpl @@ -0,0 +1,23 @@ +## -*- coding: utf-8 -*- +Subject: IRON BLOGGER results for the week beginning ${week_start.strftime("%F")} + +SLACKERS: ${", ".join(sorted([u.username for u in lame]))} +% if punt: +PUNTED for balance ≥$30: ${", ".join(sorted(punt))} +% endif + +People who posted: ${", ".join(sorted([u.username for u in good]))} + +% if skip: +People who have not yet started: ${", ".join(sorted([u.username for u in skip]))} +% endif + +Beer pool: +This week: € ${5 * len(lame)} +Total: € ${pool} +Paid: € ${paid} +Events: € ${event} +Individual debts: +% for (u, v) in sorted(debts, key=lambda p:p[1], reverse=True): +${u"%20s %d \u20AC" % (u, v)} +% endfor diff --git a/weekly-update.py b/weekly-update.py index 599fa4c..240e449 100755 --- a/weekly-update.py +++ b/weekly-update.py @@ -12,8 +12,14 @@ import settings config=settings.load_settings() dry_run = False +quick_view = False args = sys.argv[1:] +if args[0] == '-q': + dry_run = True + quick_view = True + args = args[1:] + if args[0] == '-n': dry_run = True args = args[1:] @@ -63,10 +69,12 @@ if not dry_run: x = xmlrpclib.ServerProxy(config['xmlrpc_endpoint']) x.metaWeblog.newPost(config['blog_id'], config['username'], passwd, page, True) email = render.render_template('templates/email.txt', date, punt=punt,mail=config['mail']) - -if dry_run: +quick = render.render_template('templates/quick_view.tmpl',date,punt=punt) +if quick_view: + print quick +if dry_run and not quick_view: print email -else: +if not dry_run: p = subprocess.Popen(['mutt', '-H', '/dev/stdin'], stdin=subprocess.PIPE) p.communicate(email)