summaryrefslogtreecommitdiff
path: root/tools/confirm.py
diff options
context:
space:
mode:
authorJohn Wiegley <johnw@newartisans.com>2009-02-24 22:11:59 -0400
committerJohn Wiegley <johnw@newartisans.com>2009-02-24 22:11:59 -0400
commita364b1d4acd73f187302d9a1a37432a531ef62c5 (patch)
treecfee76a87f297db2cb43e69cbeaa236688e4b766 /tools/confirm.py
parent5a194cbdf4533b337776959fb2a2bb5ebccd35db (diff)
downloadfork-ledger-a364b1d4acd73f187302d9a1a37432a531ef62c5.tar.gz
fork-ledger-a364b1d4acd73f187302d9a1a37432a531ef62c5.tar.bz2
fork-ledger-a364b1d4acd73f187302d9a1a37432a531ef62c5.zip
Restored the functionality of tools/regtest
Diffstat (limited to 'tools/confirm.py')
-rwxr-xr-xtools/confirm.py23
1 files changed, 13 insertions, 10 deletions
diff --git a/tools/confirm.py b/tools/confirm.py
index fa650074..e0706cbf 100755
--- a/tools/confirm.py
+++ b/tools/confirm.py
@@ -7,16 +7,20 @@ import os
import re
def clean(num):
- return float(re.sub("(\s+|\$|,)","", num))
+ num = re.sub("(\s+|\$|,)","", num)
+ m = re.search("([-0-9.]+)", num)
+ if m:
+ return float(m.group(1))
+ else:
+ return float(num)
running_total = 0.0
index = 1
last_line = ""
errors = 0
-report = sys.argv[1]
-for line in os.popen("./ledger -f tools/standard.dat -e 2004/4 %s reg %s" %
- (report, sys.argv[2])):
+args = sys.argv[1]
+for line in os.popen(re.sub('\$cmd', 'reg', args)):
match = re.match("\\s*([-$,0-9.]+)\\s+([-$,0-9.]+)", line[55:])
if not match:
continue
@@ -25,10 +29,10 @@ for line in os.popen("./ledger -f tools/standard.dat -e 2004/4 %s reg %s" %
running_total += value
diff = abs(running_total - total)
- if report == "-V" or report == "-G" and diff < 0.015:
+ if (re.search(' -V ', args) or re.search(' -G ', args)) and diff < 0.015:
diff = 0.0
if diff > 0.001:
- print "! discrepancy of %.2f (%.2f - %.2f) at line %d:" % \
+ print "DISCREPANCY: %.3f (%.3f - %.3f) at line %d:" % \
(running_total - total, running_total, total, index)
print line,
running_total = total
@@ -39,17 +43,16 @@ for line in os.popen("./ledger -f tools/standard.dat -e 2004/4 %s reg %s" %
balance_total = 0.0
-for line in os.popen("./ledger -f tools/standard.dat -e 2004/4 %s bal %s" %
- (report, sys.argv[2])):
+for line in os.popen(re.sub('\$cmd', 'bal', args)):
if line[0] != '-':
balance_total = clean(line[:20])
diff = abs(balance_total - running_total)
-if report == "-V" or report == "-G" and diff < 0.015:
+if (re.search(' -V ', args) or re.search(' -G ', args)) and diff < 0.015:
diff = 0.0
if diff > 0.001:
print
- print "! discrepancy of %.2f (%.2f - %.2f) between register and balance" % \
+ print "DISCREPANCY: %.3f (%.3f - %.3f) between register and balance" % \
(balance_total - running_total, balance_total, running_total)
print last_line,
errors += 1