예제 #1
0
def backup(target_list, include):
    if include == "all":
        include_hidden = True
    elif include == "visible":
        include_hidden = False
    else:
        include_hidden = True

    g = Gtasks()
    lists = g.get_lists()
    if target_list:
        original_count = len(lists)
        lists = [l for l in lists if l.title.lower() == target_list.lower()]
        new_count = len(lists)
        if not lists:
            print(
                f"Could not find any lists with the name '{target_list}' to backup!"
            )
            return
        else:
            print(f"Backing up {new_count} of {original_count} lists.")

    print(f"Including hidden tasks"
          if include_hidden else "Not including hidden tasks")
    content = []
    for l in lists:
        print(f"Adding list to backup: {l.title}")
        content.append(_serialize_list(l, include_hidden=include_hidden))
    _backup_to_file(content)
예제 #2
0
def list_available_lists():
    gt = Gtasks()
    available_list = gt.get_lists()

    list_names = []
    list_index = 0

    i = 1
    if len(available_list) > 1:
        print("These are your avaliable task list, please choose one: ")
        for task_list in available_list:
            print("{0}) {1}".format(i,task_list))
            list_names.append(task_list)
            i=i+1
        list_index = input("Choose a list by the number: ")

        while int(list_index) < 0 or int(list_index) > len(list_names):
            print(list_index)
            print("Choose a playlist available on the list.")
            list_index = input("Choose a playlist by the number: ")

        print ("Gonna syncronize notion tasks with this task list {0}".format(list_names[int(list_index)-1]))
        
        
    else:
        print("There is only one list available, so don't need to choose.")
        list_names.append(available_list[0])
        list_index = 0
       
    final_id = list_names[int(list_index)-1]
    return str(final_id)
예제 #3
0
def _find_list_with_name(name):
    """Returns single list that matched if we found a match, or None if it's not sure.
    Will print debug info if not found.
    """
    g = Gtasks()
    lists = g.get_lists()

    available_list_names = [l.title for l in lists]
    matching_lists = [l for l in lists if l.title.lower() == name.lower()]
    if len(matching_lists) > 1:
        print(
            f"Found {len(matching_lists)} lists that match name, not sure which to use: {name}"
        )
        return None

    if len(matching_lists) == 0:
        print(f"Could not find any lists that match that name: {name}")
        print("Available list names:")
        print(", ".join(available_list_names))
        return None

    return matching_lists[0]
예제 #4
0
파일: lists.py 프로젝트: OpenDevEd/gtasks
def lists():
    g = Gtasks()
    lists_ = g.get_lists()
    names = [l.title for l in lists_]
    print("Found Lists:")
    print("\n".join(names))