From 255b10fbe4b0c688828d510868017565af50b57f Mon Sep 17 00:00:00 2001
From: Christian Heller
Date: Sun, 29 Oct 2023 04:05:36 +0100
Subject: [PATCH] Improve ledger.py.
---
ledger.py | 26 ++++++++++++--------------
1 file changed, 12 insertions(+), 14 deletions(-)
diff --git a/ledger.py b/ledger.py
index 2a9a89c..27675da 100755
--- a/ledger.py
+++ b/ledger.py
@@ -336,7 +336,6 @@ class Database:
f.close()
total_lines = self.real_lines[:start] + lines + self.real_lines[end:]
text = '\n'.join(total_lines)
- # text = '\n'.join(self.real_lines[:start]) + '\n'.join(lines) + '\n'.join(self.real_lines[end:])
with open(self.db_file, 'w') as f:
f.write(text);
os.remove(self.lock_file)
@@ -413,7 +412,6 @@ input[type=number] { text-align: right; font-family: monospace; }
lines += add_taxes(lines)
elif '/add_free' == parsed_url.path:
lines = postvars['booking'][0].splitlines()
- lines += [''] # to ensure Booking-ending last line
start = int(postvars['start'][0])
end = int(postvars['end'][0])
try:
@@ -490,9 +488,9 @@ input[type=number] { text-align: right; font-family: monospace; }
return f"{content}
"
def ledger_as_html(self, db):
- single_c_tmpl = jinja2.Template('
')
+ single_c_tmpl = jinja2.Template('
')
booking_tmpl = jinja2.Template("""
-{{date}} {{desc}}
+
{{date}} {{desc}}
[edit: structured
/ free
| copy:structured
@@ -500,9 +498,9 @@ input[type=number] { text-align: right; font-family: monospace; }
{% for l in booking_lines %}
{% if l.acc %}
-{{l.acc}} | {{l.money}} |
+{{l.acc|e}} | {{l.money|e}} |
{% else %}
- |
+ |
{% endif %}
{% endfor %}
@@ -553,21 +551,21 @@ input[type=number] { text-align: right; font-family: monospace; }
def add_structured(self, db, start=0, end=0, copy=False, temp_lines=[], add_empty_line=None):
tmpl = jinja2.Template("""
-