Ruby/life_log.py
Dani 48585acb6f Dashboard updated
Added life log, persona, and plugins manager.
changed it so that any new .json files aren't uploaded
2025-05-05 13:23:38 -04:00

29 lines
721 B
Python
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import json
import os
class LifeLog:
"""
Records Rubys diary entries over time and lets you fetch her recent reflections.
"""
def __init__(self, path="life_log.json"):
self.path = path
self.entries = []
self.load()
def load(self):
if os.path.isfile(self.path):
with open(self.path, "r", encoding="utf-8") as f:
self.entries = json.load(f)
def save(self):
with open(self.path, "w", encoding="utf-8") as f:
json.dump(self.entries, f, ensure_ascii=False, indent=2)
def add(self, entry: str):
self.entries.append(entry)
self.save()
def recent(self, n=5):
return self.entries[-n:]