X-Git-Url: https://projects.mako.cc/source/iron-blogger/blobdiff_plain/1c8a87b02aae31b111907415779d7df230357a24..e7232ce8abb4c8556d5df05778f725873ba2fa0f:/weekly-update.py diff --git a/weekly-update.py b/weekly-update.py index acfc17b..7a44dff 100755 --- a/weekly-update.py +++ b/weekly-update.py @@ -19,7 +19,6 @@ if args[0] == '-n': args = args[1:] date = args[0] -today = str(datetime.date.today()) with open('ledger', 'a') as f: f.write("\n") @@ -38,10 +37,10 @@ with open('ledger', 'a') as f: if debt < 30: continue punt.append(user) f.write("""\ -%(today)s Punt +%(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: @@ -77,9 +76,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'] = date 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"])