Пример #1
0
def start_module():
    """
    Starts this module and displays its menu.
    User can access default special features from here.
    User can go back to main menu from here.

    Returns:
        None
    """
    menu = [
        'Show items by status', 'Add item', 'Enter task toggle mode',
        'Remove task', 'Archive Tasks', 'show eisenhower table'
    ]
    user_input = None
    matrix = TodoMatrix()
    try:
        matrix.add_items_from_file('my_file.csv')
    except FileNotFoundError:
        print("Error: file with data no provided.")
        open('my_file.csv', 'w').close()

    while user_input != '0':
        handle_menu(menu)
        user_input = choose_option(matrix)

    matrix.archive_items()
    matrix.save_items_to_file('my_file.csv')
Пример #2
0
    def test_save_items_to_file(self):
        matrix_expected = TodoMatrix()
        matrix_expected.add_items_from_file('todo_items_read_test.csv')
        matrix_expected.save_items_to_file('todo_items_save_test.csv')

        matrix_tested = TodoMatrix()
        matrix_tested.add_items_from_file('todo_items_save_test.csv')

        self.assertEqual(matrix_tested.todo_quarters['IU'].__str__(),
                         matrix_expected.todo_quarters['IU'].__str__())

        self.assertEqual(matrix_tested.todo_quarters['IN'].__str__(),
                         matrix_expected.todo_quarters['IN'].__str__())

        self.assertEqual(matrix_tested.todo_quarters['NU'].__str__(),
                         matrix_expected.todo_quarters['NU'].__str__())

        self.assertEqual(matrix_tested.todo_quarters['NN'].__str__(),
                         matrix_expected.todo_quarters['NN'].__str__())
Пример #3
0
    def run(self):
        os.system('clear')
        matrix = TodoMatrix()
        matrix.add_items_from_file('todo.csv')

        while self.is_running:
            os.system('clear')
            print(matrix)
            self.display_menu()
            option = self.get_input('Enter choice of menu: ')

            if option == '1':
                title = self.get_input('Enter title of TODO item: ')
                deadline_year = self.get_input('Enter year of deadline: ')
                deadline_month = self.get_input('Enter month of deadline: ')
                deadline_day = self.get_input('Enter day of deadline: ')
                deadline = datetime(int(deadline_year), int(deadline_month),
                                    int(deadline_day))
                is_important = self.get_input(
                    'Is the task important? True/False: ')
                if is_important == 'True':
                    is_important = True
                elif is_important == 'False':
                    is_important = False
                matrix.add_item(title, deadline, is_important)

            elif option == '2':
                quarter_choice = self.get_input(
                    'Choose quarter (IU/IN/NU/NN): ')
                item_choice = int(
                    self.get_input(
                        'Choose number of item to mark as done: ')) - 1
                quarter = matrix.todo_quarters[quarter_choice]
                item = quarter.todo_items[item_choice]
                item.mark()

            elif option == '3':
                quarter_choice = self.get_input(
                    'Choose quarter (IU/IN/NU/NN): ')
                item_choice = int(
                    self.get_input(
                        'Choose number of item to unmark from done: ')) - 1
                quarter = matrix.todo_quarters[quarter_choice]
                item = quarter.todo_items[item_choice]
                item.unmark()

            elif option == '4':
                quarter_choice = self.get_input(
                    'Choose quarter (IU/IN/NU/NN): ')
                item_choice = int(
                    self.get_input('Choose number of item to remove: ')) - 1
                quarter = matrix.todo_quarters[quarter_choice]
                quarter.remove_item(item_choice)
                # item = quarter.todo_items[item_choice]
                # item.unmark()

            elif option == '5':
                matrix.archive_items()

            elif option == '0':
                self.is_running = False

        matrix.archive_items()
        matrix.save_items_to_file('todo.csv')