From e66cf1bdbe9a1689d3f7b28c907bbd4945137335 Mon Sep 17 00:00:00 2001 From: Nelson Elhage Date: Sun, 23 May 2010 21:29:04 -0400 Subject: [PATCH 1/1] Prepare for floating-point values in ledger --- render.py | 4 ++-- templates/email.txt | 4 ++-- templates/week.tmpl | 6 +++--- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/render.py b/render.py index 0a7bf46..0fa0489 100755 --- a/render.py +++ b/render.py @@ -71,7 +71,7 @@ def render_template(path, week=None): '-n', 'balance', acct], stdout=subprocess.PIPE) (out, _) = p.communicate() - return int(out.split()[0][1:]) + return float(out.split()[0][1:]) p = subprocess.Popen(['ledger', '-f', os.path.join(HERE,'ledger'), '-n', 'balance', 'Pool:Owed:'], @@ -82,7 +82,7 @@ def render_template(path, week=None): if not line: continue (val, acct) = line.split() user = acct[len("Pool:Owed:"):] - val = int(val[len("$"):]) + val = float(val[len("$"):]) debts.append((user, val)) return Template(filename=path, output_encoding='utf-8').render( diff --git a/templates/email.txt b/templates/email.txt index e82b15f..d98a6b5 100644 --- a/templates/email.txt +++ b/templates/email.txt @@ -20,8 +20,8 @@ People who have not yet started: Beer pool: This week: $${5 * len(lame)}.00 -Total: $${pool}.00 -Paid: $${paid}.00 +Total: $${pool} +Paid: $${paid} Individual debts: % for (u, v) in sorted(debts, key=lambda p:p[1], reverse=True): diff --git a/templates/week.tmpl b/templates/week.tmpl index 57a88c0..d4ca365 100644 --- a/templates/week.tmpl +++ b/templates/week.tmpl @@ -31,9 +31,9 @@ Results for week beginning ${week_start.strftime("%F")}

Beer pool:

- - - + + +
This week: $${5 * len(lame)}.00
Total: $${pool}.00
Paid: $${paid}.00
This week: $${5 * len(lame)}
Total: $${pool}
Paid: $${paid}

Debts:

-- 2.39.5