Beispiel #1
0
 def delete_current_record(self):
     print("delete record")
     match_index = self.current_record
     record = self.records[match_index]
     # load te csv
     csvm = CsvManager()
     csv_data = csvm.load_csv(self.DATASTORE_FILENAME)
     # find the row that matches record
     for row in csv_data:
         if row == record:
             # delete that row
             csv_data.remove(row)
             break
     # save the csv
     csvm.save_csv(csv_data, self.DATASTORE_FILENAME, truncate=True)
     return self.main_menu
Beispiel #2
0
 def edit_record(self):
     print("edit record")
     print('enter the record number to edit')
     user_input = input("> ")
     match_index = int(user_input) - 1
     record = self.records[match_index]
     # get the new values for the record
     date = None
     while date is None:
         print("New date of the Task")
         user_entry = self.date_entry()
         if user_entry[0] is not None:  # error
             print(user_entry[0])
             continue
         else:
             date = user_entry[1]
             date_string = self.date_to_string(date, target='file')
     print("New name of the Task")
     input_text = input("Enter the name of the task > ")
     task_name = input_text
     time_spent = None
     while time_spent is None:
         print("New time spent")
         input_text = input("Enter a whole number of minutes (rounded) ")
         try:
             time_spent = int(input_text)
         except ValueError:
             print("Invalid value")
             continue
     print("New notes")
     input_text = input("(Optional, leave blank for none) ")
     notes = input_text
     # load the csv
     csvm = CsvManager()
     csv_data = csvm.load_csv(self.DATASTORE_FILENAME)
     # find the row that matches record
     for row in csv_data:
         if row == record:
             row[self.HEADERS['date']] = date_string
             row[self.HEADERS['task_name']] = task_name
             row[self.HEADERS['duration']] = time_spent
             row[self.HEADERS['notes']] = notes
     # save the csv
     csvm.save_csv(csv_data, self.DATASTORE_FILENAME, truncate=True)
     return self.main_menu
Beispiel #3
0
 def delete_record(self):
     print("delete record")
     print('enter the record number to delete')
     user_input = input("> ")
     match_index = int(user_input) - 1
     record = self.records[match_index]
     # load te csv
     csvm = CsvManager()
     csv_data = csvm.load_csv(self.DATASTORE_FILENAME)
     # find the row that matches record
     for row in csv_data:
         if row == record:
             # delete that reow
             csv_data.remove(row)
             break
     # save the csv
     csvm.save_csv(csv_data, self.DATASTORE_FILENAME, truncate=True)
     return self.main_menu
Beispiel #4
0
 def add_entry(self):
     '''This is the menu where the user can add a task that was completed
     '''
     while True:
         print("\nADD ENTRY")
         date = None
         while date is None:
             print("Date of the Task")
             user_entry = self.date_entry()
             if user_entry[0] is not None:  # error
                 print(user_entry[0])
                 continue
             else:
                 date = user_entry[1]
                 date_string = self.date_to_string(date, target='file')
         print("Name of the Task")
         input_text = input("Enter the name of the task > ")
         task_name = input_text
         time_spent = None
         while time_spent is None:
             print("Time spent")
             print("Enter a whole number of minutes (rounded)")
             input_text = input("> ")
             try:
                 time_spent = int(input_text)
             except ValueError:
                 print("Invalid value, please try again")
                 continue
             if time_spent < 0:
                 print("Invalid value, please try again")
                 continue
         print("Notes")
         input_text = input("(Optional, leave blank for none) ")
         notes = input_text
         # call method to write data to file
         csvm = CsvManager()
         file_data = [{
             self.HEADERS['date']: date_string,
             self.HEADERS['task_name']: task_name,
             self.HEADERS['duration']: time_spent,
             self.HEADERS['notes']: notes
         }]
         csvm.save_csv(file_data, self.DATASTORE_FILENAME)
         return self.main_menu