Exemplo n.º 1
0
 def find_by_date_range(self):
     while True:
         inputStr.clear_screen()
         try:
             start_date = datetime.datetime.strptime(
                 input(inputStr.search_by_date_range_start),
                 "%d/%m/%Y").date()
             end_date = datetime.datetime.strptime(
                 input(inputStr.search_by_date_range_end),
                 "%d/%m/%Y").date()
         except ValueError as val:
             value = str(val).split(" ")
             print("Error: {} is not a valid date".format(value[2]))
             if "" == input("Press Enter to Try Again ").strip():
                 pass
         else:
             rows = database.Employee.select().where(
                 database.Employee.date >= start_date
                 | database.Employee.date <= end_date)
             option = self.__main_Search(rows)
             if option == 'exit':
                 return
             elif option == 'edit':
                 return
             elif option == 'delete':
                 return
Exemplo n.º 2
0
def collect_new_entry(entry):
    # Collect the 'Name' of the Employee
    inputStr.clear_screen()
    name = input(inputStr.employeeName).strip().lower()

    # Collect the 'Title' of the task
    inputStr.clear_screen()
    title = input(inputStr.taskTitle)

    # Collect the 'Time' of the task
    while True:
        inputStr.clear_screen()
        try:
            time_spent = round(int(input(inputStr.taskTime)))
        except ValueError as val2:
            value2 = str(val2).split(" ")
            print("Error: {} is not the time value ".format(value2[-1]))
            if "" == input("Press Enter to Try Again ").strip():
                pass
        else:
            break

    # Collect the 'Notes' of the task
    inputStr.clear_screen()
    notes = input(inputStr.taskNotes)

    inputStr.clear_screen()
    entry.name = name
    entry.title = title
    entry.time_spent = time_spent
    entry.notes = notes
Exemplo n.º 3
0
 def display_log(self, item):
     inputStr.clear_screen()
     print("Log Date: " + str(item.date) + ",\n")
     print("Employee Name: " + item.name + ",")
     print("Task Title: " + item.title + ",")
     print("Time Spent: " + str(item.time_spent) + " minutes,")
     print("Notes: " + item.notes + ".")
Exemplo n.º 4
0
def search_by_Regex():
    inputStr.clear_screen()
    prompt = input(inputStr.search_by_exactSearch).strip().lower()
    rows = read.csvRead()
    list_value = []
    for row in rows:
        data_title = str(row["Title"])
        data_notes = str(row["Notes"])
        match_title = re.search(prompt, data_title)
        match_notes = re.search(prompt, data_notes)

        if match_title:
            list_value.append(row)
        elif match_notes:
            list_value.append(row)
        else:
            pass

    option = main_Search(list_value)
    if option == 'exit':
        return
    elif option == 'edit':
        return
    elif option == 'delete':
        return
Exemplo n.º 5
0
def search_by_date_range():
    while True:
        inputStr.clear_screen()
        try:
            start_date = datetime.datetime.strptime(
                input(inputStr.search_by_date_range_start), "%d/%m/%Y").date()
            end_date = datetime.datetime.strptime(
                input(inputStr.search_by_date_range_end), "%d/%m/%Y").date()
        except ValueError as val:
            value = str(val).split(" ")
            print("Error: {} is not a valid date".format(value[2]))
            if "" == input("Press Enter to Try Again ").strip():
                pass
        else:
            rows = read.csvRead()
            list_value = []
            for row in rows:
                row_date = datetime.datetime.strptime(row['Date'],
                                                      "%Y-%m-%d").date()
                if (row_date >= start_date and row_date <= end_date):
                    list_value.append(row)

            option = main_Search(list_value)
            if option == 'exit':
                return
            elif option == 'edit':
                return
            elif option == 'delete':
                return
Exemplo n.º 6
0
def search_by_date():
    while True:
        inputStr.clear_screen()
        try:
            prompt = str(
                datetime.datetime.strptime(input(inputStr.search_by_date),
                                           "%d/%m/%Y").date())
        except ValueError as val:
            value = str(val).split(" ")
            print("Error: {} is not a valid date".format(value[2]))
            if "" == input("Press Enter to Try Again ").strip():
                pass
        else:
            rows = read.csvRead()
            list_value = []
            for row in rows:
                if row['Date'] == prompt:
                    list_value.append(row)

            option = main_Search(list_value)
            if option == 'exit':
                return
            elif option == 'edit':
                return
            elif option == 'delete':
                return
Exemplo n.º 7
0
def display_log(data):
    inputStr.clear_screen()
    for key, val in data.items():
        if key != 'Notes':
            if key == 'Time Spent':
                print(key + ": " + str(val) + " minutes,")
            else:
                print(key + ": " + str(val) + ",")
        else:
            print(key + ": " + str(val) + ".")
Exemplo n.º 8
0
    def find_by_exactSearch(self):
        inputStr.clear_screen()
        prompt = input(inputStr.find_by_exactSearch).strip().lower()
        list_value = database.Employee.select().where(
            database.Employee.name.contains(prompt)
            | database.Employee.notes.contains(prompt))

        option = self.__main_Search(list_value)
        if option == 'exit':
            return
        elif option == 'edit':
            return
        elif option == 'delete':
            return
Exemplo n.º 9
0
 def find_by_employee_name(self):
     while True:
         inputStr.clear_screen()
         employeeName = input(
             inputStr.find_by_employee_name).strip().lower()
         list_value = database.Employee.select().where(
             database.Employee.name == employeeName)
         option = self.__main_Search(list_value)
         if option == 'exit':
             return
         elif option == 'edit':
             return
         elif option == 'delete':
             return
Exemplo n.º 10
0
def start():
    while True:
        inputStr.clear_screen()
        print("WORK LOG")
        prompt = input(inputStr.prompt).strip().lower()
        if prompt == 'a':
            addEntries.add_new_entries()
        elif prompt == 'b':
            searchEntries.search_old_entries()
        elif prompt == 'c':
            inputStr.clear_screen()
            print("Thank You for using the work log program!")
            print("Come again soon.")
            break
Exemplo n.º 11
0
def start(entry):
    while True:
        inputStr.clear_screen()
        print("WORK LOG")
        prompt = input(inputStr.prompt).strip().lower()
        if prompt == 'a':
            collect_new_entry(entry)
            entry.databaseWrite(entry)
        elif prompt == 'b':
            entry.search_old_entries()
        elif prompt == 'c':
            inputStr.clear_screen()
            print("Thank You for using the work log program!")
            print("Come again soon.")
            break
Exemplo n.º 12
0
 def find_by_timeSpent(self):
     while True:
         inputStr.clear_screen()
         try:
             prompt = int(input(inputStr.find_by_timeSpent).strip().lower())
         except ValueError:
             input(
                 "Please provide a number as an input.\nPress Enter to try again "
             )
         else:
             list_value = database.Employee.select().where(
                 database.Employee.time_spent == prompt)
             option = self.__main_Search(list_value)
             if option == 'exit':
                 return
             elif option == 'edit':
                 return
             elif option == 'delete':
                 return
Exemplo n.º 13
0
def add_new_entries():
    # Collect the 'Date' of the task
    while True:
        inputStr.clear_screen()
        try:
            taskDate = str(
                datetime.datetime.strptime(input(inputStr.taskDate),
                                           "%d/%m/%Y").date())
        except ValueError as val1:
            value = str(val1).split(" ")
            print("Error: {} is not a valid date".format(value[2]))
            if "" == input("Press Enter to Try Again ").strip():
                pass
        else:
            break

    # Collect the 'Title' of the task
    inputStr.clear_screen()
    taskTitle = input(inputStr.taskTitle)

    # Collect the 'Time' of the task
    while True:
        inputStr.clear_screen()
        try:
            taskTime = round(int(input(inputStr.taskTime)))
        except ValueError as val2:
            value2 = str(val2).split(" ")
            print("Error: {} is not the time value ".format(value2[-1]))
            if "" == input("Press Enter to Try Again ").strip():
                pass
        else:
            break

    # Collect the 'Notes' of the task
    inputStr.clear_screen()
    taskNotes = input(inputStr.taskNotes)

    inputStr.clear_screen()
    new_entry = entry.Entry(taskDate, taskTitle, taskTime, taskNotes)
    log_new_entries(new_entry)
    print("The entry has been added. Press enter to return to the menu.\n")
    return
Exemplo n.º 14
0
def search_old_entries():
    while True:
        inputStr.clear_screen()
        prompt = input(inputStr.searchEntry).strip()
        if prompt == 'a':
            inputStr.clear_screen()
            search_by_date()

        elif prompt == 'b':
            inputStr.clear_screen()
            search_by_date_range()

        elif prompt == 'c':
            inputStr.clear_screen()
            search_by_exactSearch()

        elif prompt == 'd':
            inputStr.clear_screen()
            search_by_Regex()

        elif prompt == 'e':
            return
Exemplo n.º 15
0
    def search_old_entries(self):
        while True:
            inputStr.clear_screen()
            prompt = input(inputStr.searchEntry).strip().lower()
            if prompt == 'a':
                inputStr.clear_screen()
                self.find_by_date()

            if prompt == 'b':
                inputStr.clear_screen()
                self.find_by_date_range()

            elif prompt == 'c':
                inputStr.clear_screen()
                self.find_by_employee_name()

            elif prompt == 'd':
                inputStr.clear_screen()
                self.find_by_timeSpent()

            elif prompt == 'e':
                inputStr.clear_screen()
                self.find_by_exactSearch()

            elif prompt == 'f':
                return