def get_data_from_input(self): try: self.date_of_event = DonationEventInput.get_event_data(DonationEventInput.DONATION_HEADER[0], "YYYY.MM.DD") if not self.check_min_period(): print("The registration should be at least 10 days before event.") sleep(3) raise ValueError if not self.is_weekday(): print("Event should be on weekdays only.") sleep(3) raise ValueError self.donation_start_time = DonationEventInput.get_event_data(DonationEventInput.DONATION_HEADER[2], "HH.MM") while self.donation_end_time == "": self.donation_end_time = DonationEventInput.get_event_data(DonationEventInput.DONATION_HEADER[3], "HH.MM") if not self.check_end_time(): self.donation_end_time = "" self.zip_code = DonationEventInput.get_event_data(DonationEventInput.DONATION_HEADER[4], "1234") self.city = DonationEventInput.get_event_data(DonationEventInput.DONATION_HEADER[5], ", ".join(Validator.CITIES)) self.address = DonationEventInput.get_event_data(DonationEventInput.DONATION_HEADER[6], "Aba u. 1.") self.bed_count = DonationEventInput.get_event_data(DonationEventInput.DONATION_HEADER[7], "9") print("The maximum number of donations: %s" % self.max_donation_number()) planned_donor_number = 0 while planned_donor_number == 0: planned_donor_number = DonationEventInput.get_event_data(DonationEventInput.DONATION_HEADER[8], "99") if self.check_planned_donor_number(planned_donor_number): self.planned_donor_number = planned_donor_number else: planned_donor_number = 0 actual_donor_number = 0 while actual_donor_number == 0: actual_donor_number = DonationEventInput.get_event_data(DonationEventInput.DONATION_HEADER[9], "99") if self.check_actual_donor_number(actual_donor_number): self.actual_donor_number = actual_donor_number else: actual_donor_number = 0 print(self.get_donation_success_rate()) sleep(3) except ValueError: return
def file_changer_donation(Index_to_change,Row_index_to_change,Donation_file_path): lines = file_handler.read_file_content(Donation_file_path) try: if int(Index_to_change) <= 10 and int(Index_to_change) >= 1: index = int(Index_to_change) - 1 line = int(Row_index_to_change) else: return False except: return False print("Old line: {}".format(lines[line])) change = DonationEventInput.get_event_data(DonationEventInput.DONATION_HEADER[index],'') split_line = lines[line].split(",") split_line[index] = change new_line = ",".join(split_line) lines[Row_index_to_change] = new_line file_handler.rewrite_file_with_data(Donation_file_path,lines) return True