當前位置: 首頁>>代碼示例>>Python>>正文


Python validation.Validate類代碼示例

本文整理匯總了Python中validation.Validate的典型用法代碼示例。如果您正苦於以下問題:Python Validate類的具體用法?Python Validate怎麽用?Python Validate使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了Validate類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: delete_donor

 def delete_donor(cursor):
     while True:
         try:
             cursor.execute("SELECT UniqueId FROM Donor;")
             data = cursor.fetchall()
             ids = [i[0] for i in data]
             print(ids, "(0) Cancel")
             user_input = input("Enter donor's ID or passport number: ").upper()
             if user_input == '0':
                 clear()
                 break
             elif not Validate.validate_id(user_input):
                 print("\n\tWrong ID or Passport number, enter a real value")
                 time.sleep(2)
                 clear()
                 continue
             elif user_input not in ids:
                 print("\n\tID is valid, but there is no entry with this ID yet.")
                 time.sleep(2)
                 clear()
                 continue
             else:
                 print("Deleting entry...")
                 cursor.execute("DELETE FROM Donor WHERE UniqueId = '{}';".format(user_input))
                 time.sleep(1)
             print("Done!")
             input()
             clear()
             break
         except Exception as e:
             print(e)
             print("\n\t! ! !  Belso Error ! ! ! ")
             input()
             clear()
開發者ID:AndrasKesik,項目名稱:Python_BloodDonorRegistration,代碼行數:34,代碼來源:donor_manager_db.py

示例2: update_progressbar

 def update_progressbar(self, dt):
     """Updating progress bar and activating validation."""
     if self.progress != 100 and self.progress != -1:
         self.progress += 1
         self.status = 'Validating: {}%'.format(int(self.progress))
     elif self.progress == 100:
         check = Validate.ksvalidate(self.kstext)
         self.progress = -1
         self.status = check
開發者ID:albertoburitica,項目名稱:kickoff,代碼行數:9,代碼來源:main.py

示例3: add_new_donation_event

    def add_new_donation_event(cursor_object):
        print("Adding new event...\n")
        time.sleep(1)
        clear()
        e1 = Event()
        while True:
            e1.date_of_event = input("Date of Event: ")
            if Validate.validate_date(e1.date_of_event) and e1.registration_in_tendays():
                pass
            else:
                print("\n\t ! The registration should be at least 10 days from now. ! ")
                print("\t   ! Use this format to enter date: 'YYYY.MM.DD' ! \n")
                time.sleep(2)
                clear()
                continue

            e1.start_time = EventManagerDB.data_into_event_object(e1, Validate.validate_time, "Start Time: ", TIME_ERR)
            e1.end_time = EventManagerDB.data_into_event_object(e1, Validate.validate_time, "End Time: ", TIME_ERR)
            while not e1.is_starttime_before_endtime():
                print("\n\t ! The starting time should be before the ending time. ! ")
                time.sleep(2)
                clear()
                e1.end_time = ""
                e1.end_time = EventManagerDB.data_into_event_object(e1, Validate.validate_time, "End Time: ", TIME_ERR)

            e1.zip_code = EventManagerDB.data_into_event_object(e1, Validate.validate_zipcode, "ZIP code: ", ZIP_ERR)
            e1.city = EventManagerDB.data_into_event_object(e1, Validate.validate_city_name, "City: ", CITY_ERR)
            e1.address = EventManagerDB.data_into_event_object(e1, Validate.validate_address, "Address of event: ", ADDRESS_ERR)
            e1.available_beds = EventManagerDB.data_into_event_object(e1, Validate.validate_positive_int, "Available beds: ", POSINT_ERR)
            e1.planned_donor_number = EventManagerDB.data_into_event_object(e1, Validate.validate_positive_int, "Planned donor number: ", POSINT_ERR)

            e1.successfull = EventManagerDB.data_into_event_object(e1, Validate.validate_positive_int, "\n How many successfull donation was on the event?\n > ", POSINT_ERR)

            print("\nThe required functions: \n")

            print("Weekday :", e1.is_weekday())
            e1.duration = e1.calculate_duration()
            print("Duration: {} min  --  {} hours ".format(e1.duration, round(e1.duration/60, 1)))
            print("Maximum donor number:", e1.max_donor_number())
            print("Success rate: {}".format(e1.success_rate()))
            input("\n\n (Press ENTER to go BACK)")
            EventManagerDB.store_donation_data(e1, cursor_object)
            clear()
            break
開發者ID:AndrasKesik,項目名稱:Python_BloodDonorRegistration,代碼行數:44,代碼來源:event_manager_db.py

示例4: delete_donor

 def delete_donor():
     while True:
         try:
             with open("Data/donors.csv", "r") as f:
                 content = []
                 for line in f:
                     content.append(line.strip())
             ids = [content[i].split(",")[6] for i in range(len(content)) if i != 0]
             print(ids, "(0) Cancel")
             user_input = input("Enter donor's ID or passport number: ").upper()
             if user_input == "0":
                 clear()
                 break
             elif not Validate.validate_id(user_input):
                 print("\n\tWrong ID or Passport number, enter a real value")
                 time.sleep(2)
                 clear()
                 continue
             elif user_input not in ids:
                 print("\n\tID is valid, but there is no entry with this ID yet.")
                 time.sleep(2)
                 clear()
                 continue
             else:
                 print("Deleting entry...")
                 with open("Data/donors.csv", "w") as f:
                     for line in content:
                         if user_input != line.split(",")[6]:
                             f.write(line + "\n")
                 time.sleep(1)
             print("Done!")
             input()
             clear()
             break
         except Exception as e:
             print(e)
             print("\n\t! ! !  Belso Error ! ! ! ")
             input()
             clear()
開發者ID:AndrasKesik,項目名稱:Python_BloodDonorRegistration,代碼行數:39,代碼來源:donor_manager_csv.py

示例5: test_ofalse

 def test_ofalse(self):
     self.assertFalse(Validate.validate_blood_type("O+"))
開發者ID:AndrasKesik,項目名稱:Python_BloodDonorRegistration,代碼行數:2,代碼來源:validation_tests.py

示例6: test_null

 def test_null(self):
     self.assertFalse(Validate.validate_blood_type("0"))
開發者ID:AndrasKesik,項目名稱:Python_BloodDonorRegistration,代碼行數:2,代碼來源:validation_tests.py

示例7: test_time_too_much_min

 def test_time_too_much_min(self):
     self.assertFalse(Validate.validate_time('15:60'))
開發者ID:AndrasKesik,項目名稱:Python_BloodDonorRegistration,代碼行數:2,代碼來源:validation_tests.py

示例8: test_number

 def test_number(self):
     self.assertFalse(Validate.validate_city_name("29"))
開發者ID:AndrasKesik,項目名稱:Python_BloodDonorRegistration,代碼行數:2,代碼來源:validation_tests.py

示例9: test_azavarosupper

 def test_azavarosupper(self):
     self.assertTrue(Validate.validate_city_name("SZERENCS"))
開發者ID:AndrasKesik,項目名稱:Python_BloodDonorRegistration,代碼行數:2,代碼來源:validation_tests.py

示例10: test_nothing

 def test_nothing(self):
     self.assertFalse(Validate.validate_blood_type(""))
開發者ID:AndrasKesik,項目名稱:Python_BloodDonorRegistration,代碼行數:2,代碼來源:validation_tests.py

示例11: test_nuber

 def test_nuber(self):
     self.assertFalse(Validate.validate_positive_int("-15"))
開發者ID:AndrasKesik,項目名稱:Python_BloodDonorRegistration,代碼行數:2,代碼來源:validation_tests.py

示例12: test_string

 def test_string(self):
     self.assertFalse(Validate.validate_positive_int("hsvee"))
開發者ID:AndrasKesik,項目名稱:Python_BloodDonorRegistration,代碼行數:2,代碼來源:validation_tests.py

示例13: test_positive

 def test_positive(self):
     self.assertTrue(Validate.validate_positive_int("42"))
開發者ID:AndrasKesik,項目名稱:Python_BloodDonorRegistration,代碼行數:2,代碼來源:validation_tests.py

示例14: test_time_valid

 def test_time_valid(self):
     self.assertTrue(Validate.validate_time('12:35'))
開發者ID:AndrasKesik,項目名稱:Python_BloodDonorRegistration,代碼行數:2,代碼來源:validation_tests.py

示例15: test_time_nothing

 def test_time_nothing(self):
     self.assertFalse(Validate.validate_time(''))
開發者ID:AndrasKesik,項目名稱:Python_BloodDonorRegistration,代碼行數:2,代碼來源:validation_tests.py


注:本文中的validation.Validate類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。