Beispiel #1
0
    def addflow(self):
        print("\tThis is Dynamic Addflow, so to avoid write long lines in the \n"
               + "\tcommand line. Add a new todo: \n\n")

        try:
            task = input("Whats the thing! (req): ").strip()
            if task in ['', ' ']:
                raise ValueError
        except ValueError as e:
            raise ValueError(colored.red("Task cannot be left Empty"))

        try:
            bounty = int(input("How much is the reward (integer):(" + str(1) + ") ") or 1)
        except ValueError as e:
            raise ValueError(colored.red("Bounty should be an integer"))

        try:
            due = input("When its' due? (YYYY-MM-DD HH:mm)/ +(due_rules): ").strip()
            due_datetime = None
            if (due):
                due_datetime = parse_duestring(due)
        except ValueError as e:
            raise ValueError(colored.red("Bad Date Fomat: Expected Formats (YYYY-MM-DD or due_rules)"))

        tags = input("Tags (comma seprated): ").strip().split(',')
        tags = clean_tags(tags)
        foldername = input("Folder/Project :" ).strip()
        foldername = clean_foldername(foldername)

        self._todos.add(task, bounty, due_datetime, tags, foldername)
Beispiel #2
0
    def editflow(self, name):
        print("\tThis is Dynamic EditFlow, so to avoid writing long lines in the \n"
               + "\tcommand line. Editing (" + name + "): \n\n" )

        assert name in self._todosdata.keys(), "No todo with name " + name + " in database."
        todo = self._todosdata[name]
        task = input("Whats the thing! ("+todo['task'] +"): ").strip()
        try:
            bounty = int(input("How much is the reward ("+str(todo['bounty'])+") :") or todo['bounty'])
        except ValueError as e:
            raise ValueError(colored.red("Bounty should be an integer"))
        try:
            done = int(input("1 if done, 0 if not done yet: ") or todo['done'])
            if done not in [1, 0]:
                raise ValueError
            done = bool(done)
        except ValueError as e:
            raise ValueError(colored.red("Done should either be 1 or 0"))
        # due_datetime handling
        try:
            duestring = 'None'
            if 'due' in todo.keys():
                duestring = todo['due']
            due = input("When its' due? (Prev: "+ duestring +" ): ").strip()
            due_datetime = None
            if (due):
                due_datetime = parse_duestring(due)
        except ValueError as e:
            raise ValueError(colored.red("Bad Date Fomat: Expected Formats (YYYY-MM-DD or due_rules)"))

        # tags_handling
        tag_string = 'None'
        if 'tags' in todo.keys():
            tag_string = ", ".join(todo['tags'])
        tags = input("Tags (Prev: "+tag_string+" )\n New: ").strip().split(',')
        tags = clean_tags(tags)
        # folder_handling
        folder = self._todostructure[name]
        newfolder = input("Folder (Prev: "+ folder +" ): ").strip()
        newfolder = clean_foldername(newfolder)

        newtodo = {}

        if (task != '' and task != todo['task']):
            newtodo['task'] = task
        if (bounty != todo['bounty']):
            newtodo['bounty'] = bounty
        if (done != todo['done']):
            newtodo['done'] = done
        if (tags != []):
            newtodo['tags'] = tags
        if (due_datetime is not None):
            newtodo['due'] = due_datetime

        self._todos.edit(name, newtodo)
        if (newfolder != ''):
            self._todos.move_to_folder(newfolder, name)
Beispiel #3
0
def test_clean_foldername_whitespace_string():
    """
    output for clean_foldername with white-spaced string as input should be falsy, or
    more specifically, an empty string.
    """
    foldername = '  \t'
    cleaned = utils.clean_foldername(foldername)
    
    assert not (cleaned)
    assert cleaned == ''
Beispiel #4
0
def test_clean_foldername_whitespace_string():
    """
    output for clean_foldername with white-spaced string as input should be falsy, or
    more specifically, an empty string.
    """
    foldername = '  \t'
    cleaned = utils.clean_foldername(foldername)

    assert not (cleaned)
    assert cleaned == ''
Beispiel #5
0
def test_clean_foldername_normal_string():
    """
    output for clean_foldername with normal string as input should not be falsy, 
    and equilavent to lower case version of input string with trailing and 
    leading whitespaces truncated.
    """
    foldername = '   Mi-Tiempo '
    cleaned = utils.clean_foldername(foldername)
    
    assert cleaned != ''
    assert cleaned == 'mi-tiempo'
Beispiel #6
0
def test_clean_foldername_normal_string():
    """
    output for clean_foldername with normal string as input should not be falsy, 
    and equilavent to lower case version of input string with trailing and 
    leading whitespaces truncated.
    """
    foldername = '   Mi-Tiempo '
    cleaned = utils.clean_foldername(foldername)

    assert cleaned != ''
    assert cleaned == 'mi-tiempo'
Beispiel #7
0
def test_clean_foldername_special_chars_string():
    """
    output for clean_foldername with special character string as input should 
    not be falsy, and equilavent to lower case version of input string with 
    trailing and leading whitespaces truncated, also special characters remaining
    intact.
    """
    foldername = 'Mi-(Tiempo)& Tu tiem<.>po!'
    cleaned = utils.clean_foldername(foldername)
    
    assert cleaned != ''
    assert cleaned == 'mi-(tiempo)& tu tiem<.>po!'
Beispiel #8
0
def test_clean_foldername_special_chars_string():
    """
    output for clean_foldername with special character string as input should 
    not be falsy, and equilavent to lower case version of input string with 
    trailing and leading whitespaces truncated, also special characters remaining
    intact.
    """
    foldername = 'Mi-(Tiempo)& Tu tiem<.>po!'
    cleaned = utils.clean_foldername(foldername)

    assert cleaned != ''
    assert cleaned == 'mi-(tiempo)& tu tiem<.>po!'
Beispiel #9
0
    def addflow(self):
        print(
            "\tThis is Dynamic Addflow, so to avoid write long lines in the \n"
            + "\tcommand line. Add a new todo: \n\n")

        try:
            task = input("Whats the thing! (req): ").strip()
            if task in ['', ' ']:
                raise ValueError
        except ValueError as e:
            raise ValueError(colored.red("Task cannot be left Empty"))

        try:
            bounty = int(
                input("How much is the reward (integer):(" + str(1) + ") ")
                or 1)
        except ValueError as e:
            raise ValueError(colored.red("Bounty should be an integer"))

        try:
            due = input(
                "When its' due? (YYYY-MM-DD HH:mm)/ +(due_rules): ").strip()
            due_datetime = None
            if (due):
                due_datetime = parse_duestring(due)
        except ValueError as e:
            raise ValueError(
                colored.red(
                    "Bad Date Fomat: Expected Formats (YYYY-MM-DD or due_rules)"
                ))

        tags = input("Tags (comma seprated): ").strip().split(',')
        tags = clean_tags(tags)
        foldername = input("Folder/Project :").strip()
        foldername = clean_foldername(foldername)

        self._todos.add(task, bounty, due_datetime, tags, foldername)
Beispiel #10
0
    def editflow(self, name):
        print(
            "\tThis is Dynamic EditFlow, so to avoid writing long lines in the \n"
            + "\tcommand line. Editing (" + name + "): \n\n")

        assert name in self._todosdata.keys(
        ), "No todo with name " + name + " in database."
        todo = self._todosdata[name]
        task = input("Whats the thing! (" + todo['task'] + "): ").strip()
        try:
            bounty = int(
                input("How much is the reward (" + str(todo['bounty']) + ") :")
                or todo['bounty'])
        except ValueError as e:
            raise ValueError(colored.red("Bounty should be an integer"))
        try:
            done = int(input("1 if done, 0 if not done yet: ") or todo['done'])
            if done not in [1, 0]:
                raise ValueError
            done = bool(done)
        except ValueError as e:
            raise ValueError(colored.red("Done should either be 1 or 0"))
        # due_datetime handling
        try:
            duestring = 'None'
            if 'due' in todo.keys():
                duestring = todo['due']
            due = input("When its' due? (Prev: " + duestring + " ): ").strip()
            due_datetime = None
            if (due):
                due_datetime = parse_duestring(due)
        except ValueError as e:
            raise ValueError(
                colored.red(
                    "Bad Date Fomat: Expected Formats (YYYY-MM-DD or due_rules)"
                ))

        # tags_handling
        tag_string = 'None'
        if 'tags' in todo.keys():
            tag_string = ", ".join(todo['tags'])
        tags = input("Tags (Prev: " + tag_string +
                     " )\n New: ").strip().split(',')
        tags = clean_tags(tags)
        # folder_handling
        folder = self._todostructure[name]
        newfolder = input("Folder (Prev: " + folder + " ): ").strip()
        newfolder = clean_foldername(newfolder)

        newtodo = {}

        if (task != '' and task != todo['task']):
            newtodo['task'] = task
        if (bounty != todo['bounty']):
            newtodo['bounty'] = bounty
        if (done != todo['done']):
            newtodo['done'] = done
        if (tags != []):
            newtodo['tags'] = tags
        if (due_datetime is not None):
            newtodo['due'] = due_datetime

        self._todos.edit(name, newtodo)
        if (newfolder != ''):
            self._todos.move_to_folder(newfolder, name)