summaryrefslogtreecommitdiff
path: root/display.py
diff options
context:
space:
mode:
authorhmjsp <hmjsp@liber8bits.com>2026-03-19 11:18:25 +0000
committerhmjsp <hmjsp@liber8bits.com>2026-03-19 11:18:25 +0000
commit4b6845618b972153cef5b8c776dd7b018775e444 (patch)
tree166576f397f8a363091f5f03869d9205721156a1 /display.py
parentaf448c11a6ad47bc35f93bb6be82186f00699705 (diff)
downloadchronologgy-4b6845618b972153cef5b8c776dd7b018775e444.zip
use config/cache dirs rather than storing in same dir
- also display.py shows time in hours rather than minutes
Diffstat (limited to 'display.py')
-rwxr-xr-xdisplay.py17
1 files changed, 13 insertions, 4 deletions
diff --git a/display.py b/display.py
index e160c6b..cfd7041 100755
--- a/display.py
+++ b/display.py
@@ -7,6 +7,7 @@ import csv
import argparse
from collections import OrderedDict
import formatting as f
+import os
parser = argparse.ArgumentParser()
parser.add_argument("logfile", help="log file to display chart of",
@@ -15,13 +16,21 @@ args = parser.parse_args()
day_times = f.per_tag_per_day(args.logfile)
+cache_dir = os.environ["HOME"] + "/.cache/chronologgy"
+try:
+ os.makedirs(cache_dir)
+except FileExistsError:
+ pass
+except PermissionError:
+ print("permission denied: unable to create " + config_dir)
+
for day in day_times:
chart = pygal.Bar()
pie = pygal.Pie()
for key, value in day.items():
if key == "date":
continue
- chart.add(key, round(value/60, 0))
- pie.add(key, round(value/60, 0))
- chart.render_to_file(str(day["date"]+"-bar.svg"))
- pie.render_to_file(str(day["date"]+"-pie.svg"))
+ chart.add(key, round(value/60/60, 1))
+ pie.add(key, round(value/60/60, 1))
+ chart.render_to_file(str(cache_dir + "/" + day["date"]+"-bar.svg"))
+ pie.render_to_file(str(cache_dir + "/" + day["date"]+"-pie.svg"))