Added life log, persona, and plugins manager. changed it so that any new .json files aren't uploaded
29 lines
721 B
Python
29 lines
721 B
Python
import json
|
||
import os
|
||
|
||
|
||
class LifeLog:
|
||
"""
|
||
Records Ruby’s 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:]
|