示例#1
0
 def clear_history(self, widget):
     widget.set_sensitive(False)
     result = Alert.show_alert("Are you sure?",
                               "You will remove all history", True)
     if result == Gtk.ResponseType.OK:
         todotxtio.to_file(self.todo_histoy, [])
     widget.set_sensitive(True)
示例#2
0
def includeTodo(todoToAdd):
    conf = Configurator()
    list_of_todos = todotxtio.from_file(conf.todo)
    for i in range(len(list_of_todos)):
        list_of_todos[i].tags = getTagsAfterStopIfNeeded(list_of_todos[i])
    list_of_todos.append(todoToAdd)
    todotxtio.to_file(conf.todo, list_of_todos)
示例#3
0
def Del(task):
    todos = todotxtio.from_file(todo_path)
    newtodos = list()
    for todo in todos:
        print(todo.__repr__(), task.__repr__())
        if todo.__repr__() != task.__repr__():
            newtodos.append(todo)
    todotxtio.to_file(todo_path, newtodos)
示例#4
0
def saveTodo(todoToChange):
    conf = Configurator()
    list_of_todos = todotxtio.from_file(conf.todo)
    for i in range(len(list_of_todos)):
        if list_of_todos[i].text == todoToChange.text:
            list_of_todos[i].tags = todoToChange.tags
        else:
            list_of_todos[i].tags = getTagsAfterStopIfNeeded(list_of_todos[i])
    todotxtio.to_file(conf.todo, list_of_todos)
示例#5
0
def toPrio(task, p):
    todos = todotxtio.from_file(todo_path)
    newtodos = list()
    print(task)
    for todo in todos:
        print(todo.__repr__(), task.__repr__())
        if todo.__repr__() == task.__repr__():
            todo.priority = p
        newtodos.append(todo)
    todotxtio.to_file(todo_path, newtodos)
示例#6
0
def toDone(task):
    todos = todotxtio.from_file(todo_path)
    newtodos = list()
    print(task)
    for todo in todos:
        print(todo.__repr__(), task.__repr__())
        if todo.__repr__() == task.__repr__():
            todo.completed = True
        newtodos.append(todo)
    todotxtio.to_file(todo_path, newtodos)
示例#7
0
def todo_list_menu_selection(list_of_todos, todays_list):
    '''
    Select various ways to update or edit the lists of To-Dos
    '''

    options = {
        "U": "Update Today's To-do list",
        "R": "Remove To-Dos from Today's list",
        "P": "Change To-do priority",
        "A": "Add new To-do",
        "E": "Edit existing To-do",
        "M": "Go back to main menu"
    }

    q1 = "What would you like to change? Please select an option:"
    q2 = "Make your selection:"
    while True:
        print(80 * '+' + '\n' + q1)
        for i, o in options.items():
            print("[{}] - {}".format(i, o))
        print(80 * '+')
        try:
            option_selected = input(q2).upper() or "M"
        except:
            print("returning to main menu")
            option_selected = "M"
        if option_selected in options.keys():
            print("You selected:{}".format(options[option_selected]))
            #break
        else:
            print("Incorrect selection, please try again")
            continue
        if option_selected == "U":
            todays_list = make_todays_list(todays_list, list_of_todos)
        elif option_selected == "R":
            todays_list = make_todays_list(todays_list)
        elif option_selected == "P":
            list_of_todos = edit_todo(list_of_todos)
        elif option_selected == "A":
            list_of_todos, todays_list = add_new_todo(list_of_todos,
                                                      todays_list)
        elif option_selected == "E":
            print('not implemented yet')
        elif option_selected == "M":
            break

    #sort modified lists
    sort_todo_list(list_of_todos)
    sort_todo_list(todays_list)
    #save modified list
    tdt.to_file(TODO_TXT_TMP, list_of_todos)
    print("Modified list saved!")
    return list_of_todos, todays_list
示例#8
0
    def after_track_time(self, todo, before_started_at, after_started_at,
                         total_time, just_now):
        """
        This event is fired after user click on one task or close the app with a task started
        Take on account that this event is fired per task and one click may fire this event two times:
        one to finalize previous, other for initialize this
        In the original code only track total time per task. To sum all time inverted in a task
        you need to know when started it and with the current time you can sum time to total time
        With this hook you can know when was started and the total time in one step
        Arguments:
        * todo (todo object. See todotxt.io) Object that hold information
        * before_started_at: Unix time. Last started time
        * after_started_at (float): Unix time. If greater than 0 todo has initialized
                                               else the todo has being finalized
        * total_time: Acumulated time in todo
        * just_now: Unix time. Only one time instance accross call's
        """
        if before_started_at:
            list_of_todos = todotxtio.from_file(self.todo_histoy)
            new_todo_history = todotxtio.Todo(text=todo.text)
            new_todo_history.projects = todo.projects
            new_todo_history.contexts = todo.contexts
            new_todo_history.completed = True
            new_todo_history.tags["started"] = str(before_started_at)
            new_todo_history.tags["ended"] = str(just_now)
            new_todo_history.tags["step_time"] = str(just_now -
                                                     before_started_at)
            new_todo_history.tags["total_time"] = str(todo.tags["total_time"])
            list_of_todos.append(new_todo_history)
            todotxtio.to_file(self.todo_histoy, list_of_todos)

        print(
            "todo: {}, before_started_at: {}, after_started_at: {}, total_time: {}, just_now: {}"
            .format(
                todo.text,
                before_started_at,
                after_started_at,
                total_time,
                just_now,
            ))
示例#9
0
def trackHistory(todo, just_now):
    beforeTags = {}
    if todo:
        beforeTags = todo.tags
    started_at = float(beforeTags.get("started_at", 0))
    conf = Configurator()
    list_of_history = todotxtio.from_file(conf.todo_histoy)
    new_todo_history = todotxtio.Todo(text=todo.text)
    new_todo_history.projects = todo.projects
    new_todo_history.contexts = todo.contexts
    new_todo_history.completed = True
    new_todo_history.tags["started"] = str(started_at)
    new_todo_history.tags["ended"] = str(just_now)
    new_todo_history.tags["step_time"] = str(just_now - started_at)
    new_todo_history.tags["total_time"] = str(
        float(todo.tags.get("total_time", 0)) + (just_now - started_at)
    )
    desc = formatTodo(todo.tags.get("description"))
    if desc:
        new_todo_history.tags["description"] = desc
    list_of_history.append(new_todo_history)
    todotxtio.to_file(conf.todo_histoy, list_of_history)
示例#10
0
def main():
    #check if tmp file remains, if so, load it
    if os.path.isfile(TODO_TXT_TMP):
        list_of_todos = tdt.from_file(TODO_TXT_TMP)
        print('Loaded To-Dos from {} !'.format(TODO_TXT_TMP))
    else:
        #generate the main list of To-dos by reading in todo.txt
        list_of_todos = tdt.from_file(TODO_TXT)
    #save timestamped backup of todo.txt content
    backup_name = 'todo_txt_' + re.sub(
        r'\D+', '',
        datetime.now().isoformat(timespec='seconds'))
    #tdt.to_file(backup_name, list_of_todos)
    if os.path.isfile(TODO_TXT):
        os.rename(TODO_TXT, backup_name)
    #give IDs to all To-dos, sort list, save to todo_txt_tmp
    list_of_todos = todo_id(list_of_todos)
    sort_todo_list(list_of_todos)
    tdt.to_file(TODO_TXT_TMP, list_of_todos)
    #    print_list(list_of_todos, completed='Y')
    #define today's list of To-Dos from those that aren't completed
    todays_list = make_todays_list(tdt.search(list_of_todos, completed=False))
    #initialise variables keeping track of Pomos done, their number, time spent
    done_list, pomo_done, time_today = [], 0, 0
    #loop for moving To-dos from today's list to done list by doing them
    while True:
        option_selected = selection(todays_list, "CRSF", default_option='0')
        if option_selected == 'C':
            list_of_todos, todays_list = todo_list_menu_selection(
                list_of_todos, todays_list)
            continue
        elif option_selected == 'F':
            print("That's it for today!")
            break
        elif option_selected == 'R':
            ###############NEED TO SAVE ANYTHING?????????????????????????????
            #re-initialise
            done_list, pomo_done, time_today = [], 0, 0
            #update todays_list by adding from todo.txt
            todays_list = make_todays_list(todays_list, list_of_todos)
            feedback(pomo_done, time_today, done_list, todays_list)
            continue
        elif option_selected == 'S':
            print("not yet implemented")
            continue


#        else: #has to be a To-do
        try:
            completed, pomo_count, pomo_cycle_duration = run_pomo(
                option_selected)
        except:
            print('\n', 80 * '$' + '\n ' + 40 * '#~')
            print(25 * ' ' + 'Pomo run was interrupted !\n' + 40 * '#~', '\n',
                  80 * '$')
            continue
        #run pomodoro and keep track of metrics
        pomo_done += pomo_count
        time_today += pomo_cycle_duration
        #update the to-do that's going through a pomodoro cycle
        update_todo(option_selected, completed, pomo_count,
                    pomo_cycle_duration)
        print('checking:', option_selected)
        #update the temprary todo.txt file
        tdt.to_file(TODO_TXT_TMP, list_of_todos)
        feedback(pomo_done, time_today, done_list, todays_list)
        if completed == "Y":
            print("You just finished:\n {} \n Well done!".format(
                option_selected))
            done_list.append(option_selected)
            todays_list.remove(option_selected)
        feedback(pomo_done, time_today, done_list, todays_list)
    #sort full list, overwrite the temporary todo.txt file
    sort_todo_list(list_of_todos)
    #save final list, overwriting the original
    tdt.to_file(TODO_TXT, list_of_todos)
    if os.path.isfile(TODO_TXT):
        print("saved current To-Dos to {}.".format(TODO_TXT))
    #remove tmp file - otherwise it will be loaded next time
    if os.path.isfile(TODO_TXT_TMP):
        os.remove(TODO_TXT_TMP)
        print("removed {}.".format(TODO_TXT_TMP))
示例#11
0
def Save(task):
    todos = todotxtio.from_file(todo_path)
    todos.append(task)
    todotxtio.to_file(todo_path, todos)
#!/usr/bin/env python
import gkeepapi
import todotxtio

todo_tile = "/home/k/Desktop/todo.txt"

keep = gkeepapi.Keep()
success = keep.login('*****@*****.**', 'mhkmsbxpvohndjqk')

gnotes = keep.find(labels=[keep.findLabel('Planning')])
todos = []
for note in gnotes:
    if (note.title == "My Tasks"):
        glistitems = note.items
        for item in glistitems:
            todos.append(todotxtio.Todo(text=item.text))
            print(item.text)



todotxtio.to_file(todo_tile, todos)
示例#13
0
 def store(self, todos, user):
     todotxtio.to_file(self.config['path'], todos)