]> projects.mako.cc - iron-blogger/commitdiff
Prepare for floating-point values in ledger
authorNelson Elhage <nelhage@ksplice.com>
Mon, 24 May 2010 01:29:04 +0000 (21:29 -0400)
committerNelson Elhage <nelhage@ksplice.com>
Mon, 24 May 2010 01:29:04 +0000 (21:29 -0400)
render.py
templates/email.txt
templates/week.tmpl

index 0a7bf46f488d68095a370ac722467aa8631d2c82..0fa0489434bcea6f0222c511f23adaea04f7c25a 100755 (executable)
--- 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()
                               '-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:'],
 
     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:"):]
         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(
         debts.append((user, val))
 
     return Template(filename=path, output_encoding='utf-8').render(
index e82b15fb59e1add6f3110110f7402be769266d85..d98a6b5b9e253c0061c7d389d22ef023b459fbef 100644 (file)
@@ -20,8 +20,8 @@ People who have not yet started:
 
 Beer pool:
 This week: $${5 * len(lame)}.00
 
 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):
 
 Individual debts:
 % for (u, v) in sorted(debts, key=lambda p:p[1], reverse=True):
index 57a88c01c066449302777f67fde74966f5710534..d4ca365e0d28544c708737ee8e14457cc866e579 100644 (file)
@@ -31,9 +31,9 @@ Results for week beginning ${week_start.strftime("%F")}
 
 <h2>Beer pool:</h2>
 <table>
 
 <h2>Beer pool:</h2>
 <table>
-  <tr> <td> This week: </td> <td> $${5 * len(lame)}.00 </td> </tr>
-  <tr> <td> Total: </td> <td> $${pool}.00 </td> </tr>
-  <tr> <td> Paid: </td> <td> $${paid}.00 </td> </tr>
+  <tr> <td> This week: </td> <td> $${5 * len(lame)} </td> </tr>
+  <tr> <td> Total: </td> <td> $${pool} </td> </tr>
+  <tr> <td> Paid: </td> <td> $${paid} </td> </tr>
 </table>
 
 <h2>Debts:</h2>
 </table>
 
 <h2>Debts:</h2>

Benjamin Mako Hill || Want to submit a patch?