From: Christian Heller
Date: Sun, 29 Oct 2023 03:05:36 +0000 (+0100)
Subject: Improve ledger.py.
X-Git-Url: https://plomlompom.com/repos/%7B%7Bdb.prefix%7D%7D/foo.html?a=commitdiff_plain;h=255b10fbe4b0c688828d510868017565af50b57f;p=misc
Improve ledger.py.
---
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("""
-