I am developing a Python program to sync tasks between lists in different to-do formats--initially Emacs org-mode and todo.txt. I am unsure what data structure I should use to track the tasks in a centralized form (or whether this is even the best approach).
My first attempt was to create dictionaries of each task property in which the key is the original line from the task list, and the value is a string of the relevant property. For example, I had dictionaries for the following:
#org-mode format
task_name["TODO [#C] Take out the trash"] = "Take out the trash"
priority["TODO [#C] Take out the trash"] = "C"
#todo.txt format
effort["(A) Refill Starbucks card @10min"] = 20 # meaning 20 minutes of estimated time
I then check which of the two text files was updated most recently, pull changed tasks from the most recent file, and overwrite these tasks on the old file. New tasks from either list are added to the other list. The tasks are also all stored in a centralized file: a CSV / tab-separated value file in which the headers are properties of the task (task_name, effort, priority, deadline, scheduled_date, todo_state, tags, etc.), and each row is a task.
It then occurred to me that maybe I should instead create an object class called "Task" in which each property is an attribute, and each task is an instance of the Task object instead of a series of dictionaries.
class Task(object):
def __init__(self, name, effort, priority):
name = self.name
effort = self.effort
priority = self.priority
Finally, it occurred to me that I might want to use nested dictionaries or JSON formats--something like this:
{line: "TODO [#C] Take out the trash" {
"task_name": "Take out the trash."
"priority": "C"
"todo_state": "TODO"
}}
Or I could put the tasks in an SQLite database.
Which approach is best, or is there another approach that is better than all of these? I am an intermediate Python developer with little experience with advanced data structures and classes, so I appreciate any help you can offer.