本文整理汇总了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()
示例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
示例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
示例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()
示例5: test_ofalse
def test_ofalse(self):
self.assertFalse(Validate.validate_blood_type("O+"))
示例6: test_null
def test_null(self):
self.assertFalse(Validate.validate_blood_type("0"))
示例7: test_time_too_much_min
def test_time_too_much_min(self):
self.assertFalse(Validate.validate_time('15:60'))
示例8: test_number
def test_number(self):
self.assertFalse(Validate.validate_city_name("29"))
示例9: test_azavarosupper
def test_azavarosupper(self):
self.assertTrue(Validate.validate_city_name("SZERENCS"))
示例10: test_nothing
def test_nothing(self):
self.assertFalse(Validate.validate_blood_type(""))
示例11: test_nuber
def test_nuber(self):
self.assertFalse(Validate.validate_positive_int("-15"))
示例12: test_string
def test_string(self):
self.assertFalse(Validate.validate_positive_int("hsvee"))
示例13: test_positive
def test_positive(self):
self.assertTrue(Validate.validate_positive_int("42"))
示例14: test_time_valid
def test_time_valid(self):
self.assertTrue(Validate.validate_time('12:35'))
示例15: test_time_nothing
def test_time_nothing(self):
self.assertFalse(Validate.validate_time(''))