This page documents every function defined inDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/FranksGP/Gestor_de_tareas/llms.txt
Use this file to discover all available pages before exploring further.
index.py. Each entry covers the exact signature as it appears in the source, all parameters, what the function returns, any file I/O or console output it produces, and how it responds to errors. The functions fall into three categories: persistence helpers (cargarTask, guardarTask), task-manipulation functions (agregarTask, listarTask, tareaCompletada, delete_task), and the top-level entry point (main).
cargarTask()
Tareas.json from the current working directory and deserialises it into a Python list. If the file does not exist, or if its contents cannot be parsed as valid JSON, the function returns an empty list rather than raising an exception, keeping all callers safe from I/O and parse errors.
Return value: list — a list of task dictionaries, or [] when the file is absent or malformed.
Side effects: Opens Tareas.json in read mode ("r") if the file exists.
Error handling: A json.JSONDecodeError is caught internally; the function returns [] instead of propagating the exception. A missing file is detected with os.path.exists() before any open attempt, so no FileNotFoundError is raised.
guardarTask(tasks)
Tareas.json, completely overwriting any previous content. The file is written with a four-space indent so it remains human-readable.
A list of task dictionaries. Each dictionary must contain the keys
titulo (str), descripcion (str), and completed (bool). Passing an empty list is valid and will write [] to the file.None
Side effects: Opens Tareas.json in write mode ("w"), creating the file if it does not exist or truncating it if it does. Uses json.dump(tasks, file, indent=4).
Error handling: No explicit error handling — any OSError raised by the underlying open() call (e.g., a permission error) will propagate to the caller.
agregarTask(titulo, descripcion)
completed set to False. After saving, a confirmation message is printed to standard output.
The title of the new task. This is a short, human-readable label displayed when tasks are listed.
A longer description of the task. Displayed alongside the title in the task list.
None
Side effects:
- Calls
cargarTask()to read the current list from disk. - Appends
{"titulo": titulo, "descripcion": descripcion, "completed": False}to the list. - Calls
guardarTask()to write the updated list toTareas.json. - Prints
"Tarea agregada exitosamente."to standard output.
cargarTask() and guardarTask().
listarTask()
main() before prompting for an index in options 3 and 4.
Return value: None
Side effects:
- Calls
cargarTask()to retrieve the current list. - If the list is empty, prints
"No hay tareas disponibles."and returns immediately. - Otherwise, iterates with
enumerate(tasks, start=1)and prints each task in the format:
{status} is "✔ Completada" when task["completed"] is True, or "✘ Pendiente" when it is False.
Error handling: Relies on cargarTask() for safe file reading; no additional error handling needed.
tareaCompletada(index)
completed field to True. The index argument uses 1-based numbering to match what listarTask() displays to the user.
The 1-based position of the task to mark as completed. Must satisfy
0 < index <= len(tasks). If the value is out of range, an error message is printed and no changes are saved.None
Side effects:
- Calls
cargarTask()to load the current list. - If
indexis valid, setstasks[index - 1]["completed"] = True, callsguardarTask(), and prints"Tarea marcada como completada.". - If
indexis out of range, prints"Índice inválido."without modifying the file.
0 < index <= len(tasks). A ValueError for non-integer input is not handled here — it is caught in main() before this function is called.
delete_task(index)
The 1-based position of the task to delete. Must satisfy
0 < index <= len(tasks). If the value is out of range, an error message is printed and the list is not modified.None
Side effects:
- Calls
cargarTask()to load the current list. - If
indexis valid, callstasks.pop(index - 1)to remove the task, callsguardarTask(), and prints"Tarea '{titulo}' eliminada."where{titulo}is the title of the removed task. - If
indexis out of range, prints"Índice inválido."without modifying the file.
tareaCompletada. ValueError for non-integer input is handled upstream in main().
main()
while True loop that displays a five-option menu, reads a string from standard input, and dispatches to the appropriate function. The loop exits cleanly when the user chooses option 5.
Return value: None
Side effects:
- Prints the menu to standard output on every iteration:
- Option 1: Prompts for a title and description, calls
agregarTask(). - Option 2: Calls
listarTask(). - Option 3: Calls
listarTask(), prompts for an integer index, callstareaCompletada(). CatchesValueErrorif the input is not a valid integer and prints"Entrada inválida. Debe ingresar un número.". - Option 4: Calls
listarTask(), prompts for an integer index, callsdelete_task(). CatchesValueErrorwith the same message as option 3. - Option 5: Prints
"Saliendo..."and breaks out of the loop. - Any other input: Prints
"Opción inválida, intente de nuevo."and continues the loop.
ValueError exceptions from int() conversions in options 3 and 4 are caught with a try/except block inside the loop. All other error handling is delegated to the functions called.