X-Git-Url: https://projects.mako.cc/source/iron-blogger/blobdiff_plain/30fd9f8032af69d94001dfbddcdb5b392e9e4bcd..305d70a11d7f892c965a2bf02740b6f8b16e2174:/weekly-update.py?ds=inline diff --git a/weekly-update.py b/weekly-update.py index ad6ef1a..9cd240c 100755 --- a/weekly-update.py +++ b/weekly-update.py @@ -7,9 +7,7 @@ import subprocess import datetime import yaml -XMLRPC_ENDPOINT = 'http://iron-blogger.mako.cc/xmlrpc.php' -USER = 'mako' -BLOG_ID = 1 +from config import * dry_run = False @@ -19,14 +17,14 @@ if args[0] == '-n': args = args[1:] date = args[0] -today = str(datetime.date.today()) with open('ledger', 'a') as f: f.write("\n") f.write(render.render_template('templates/ledger', date)) -subprocess.check_call(["git", "commit", "ledger", - "-m", "Update for %s" % (date,)]) +if not dry_run: + subprocess.check_call(["git", "commit", "ledger", + "-m", "Update for %s" % (date,)]) debts = render.get_debts() punt = [] @@ -34,13 +32,13 @@ punt = [] with open('ledger', 'a') as f: f.write("\n") for (user, debt) in debts: - if debt < 30: continue + if debt <= (FINE_SIZE * 6): continue punt.append(user) f.write("""\ -%(today)s Punt - Pool:Owed:%(user)s $-%(debt)s +%(date)s Punt + Pool:Owed:%(user)s -%(debt)s User:%(user)s -""" % {'user': user, 'debt': debt, 'today': today}) +""" % {'user': user, 'debt': debt, 'date': date}) if not dry_run: @@ -76,9 +74,17 @@ if punt: bloggers = yaml.safe_load(b) for p in punt: if 'end' not in bloggers[p]: - bloggers[p]['end'] = today + bloggers[p]['end'] = datetime.date(*map(int, date.split("-"))) with open('bloggers.yml','w') as b: yaml.safe_dump(bloggers, b) - subprocess.check_call(["git", "commit", "ledger", "bloggers.yml", - "-m", "Punts for %s" % (today,)]) + if not dry_run: + subprocess.check_call(["git", "commit", "ledger", "bloggers.yml", + "-m", "Punts for %s" % (date,)]) + +# if it's a dry run, lets set the ledger back to the beginning state +if dry_run: + subprocess.check_call(["git", "checkout", "ledger"]) + + if punt: + subprocess.check_call(["git", "checkout", "bloggers.yml"])