| | import json |
| | import os |
| |
|
| | |
| | ARCHIVO_REGISTRO = "registro_personal.json" |
| |
|
| | |
| | def guardar_registro(estado): |
| | """ |
| | Guarda todo el estado personal en un archivo JSON. |
| | - estado: diccionario con todas tus variables (calor铆as, comidas, actividad, hidrataci贸n, sue帽o, estr茅s, etc.) |
| | """ |
| | try: |
| | with open(ARCHIVO_REGISTRO, "w") as f: |
| | json.dump(estado, f, indent=4, default=str) |
| | return True |
| | except Exception as e: |
| | print(f"Error al guardar registro: {e}") |
| | return False |
| |
|
| | |
| | def cargar_registro(): |
| | """ |
| | Carga el estado desde el archivo JSON. |
| | Devuelve un diccionario vac铆o si no existe el archivo. |
| | """ |
| | if os.path.exists(ARCHIVO_REGISTRO): |
| | try: |
| | with open(ARCHIVO_REGISTRO, "r") as f: |
| | estado = json.load(f) |
| | return estado |
| | except Exception as e: |
| | print(f"Error al cargar registro: {e}") |
| | return {} |
| | else: |
| | |
| | return {} |
| |
|
| | |
| | def reiniciar_registro(): |
| | """ |
| | Borra todo el historial y el archivo de registro. |
| | """ |
| | if os.path.exists(ARCHIVO_REGISTRO): |
| | os.remove(ARCHIVO_REGISTRO) |
| | return {} |
| |
|