diff options
| author | huker667 <huker@tuta.io> | 2026-05-23 18:09:50 +0300 |
|---|---|---|
| committer | huker667 <huker@tuta.io> | 2026-05-23 18:09:50 +0300 |
| commit | 8861fbbb4b28b04fbf6428c689744060ce26edd7 (patch) | |
| tree | 9eeac6321e323897e328c0d8ebec4859730e32ae /statistics.py | |
| parent | f9207e1f9951f97e5c6a0c3dbb525e9c5bf517b6 (diff) | |
| download | uzbekgpt-8861fbbb4b28b04fbf6428c689744060ce26edd7.tar.gz uzbekgpt-8861fbbb4b28b04fbf6428c689744060ce26edd7.tar.bz2 uzbekgpt-8861fbbb4b28b04fbf6428c689744060ce26edd7.zip | |
added global statistics
Diffstat (limited to 'statistics.py')
| -rw-r--r-- | statistics.py | 30 |
1 files changed, 30 insertions, 0 deletions
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 |