From 8861fbbb4b28b04fbf6428c689744060ce26edd7 Mon Sep 17 00:00:00 2001 From: huker667 Date: Sat, 23 May 2026 18:09:50 +0300 Subject: added global statistics --- statistics.py | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 statistics.py (limited to 'statistics.py') diff --git a/statistics.py b/statistics.py new file mode 100644 index 0000000..6a98ff4 --- /dev/null +++ b/statistics.py @@ -0,0 +1,30 @@ +import os + + +def ensure_path(path, default="0"): + os.makedirs(os.path.dirname(path) or ".", exist_ok=True) + + if not os.path.exists(path): + with open(path, "w") as f: + f.write(default) + + +def add_one_to(path): + try: + with open(path, "r") as f: + total = int(f.read().strip()) + except: + total = 0 + + total += 1 + + with open(path, "w") as f: + f.write(str(total)) + + +def get_stats(path): + try: + with open(path) as f: + return int(f.read().strip()) + except: + return 0 -- cgit v1.3.1