• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python validation.Validate类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中validation.Validate的典型用法代码示例。如果您正苦于以下问题:Python Validate类的具体用法?Python Validate怎么用?Python Validate使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了Validate类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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


示例16: test_time_wrong_divider

 def test_time_wrong_divider(self):
     self.assertFalse(Validate.validate_time('15.40'))
开发者ID:AndrasKesik,项目名称:Python_BloodDonorRegistration,代码行数:2,代码来源:validation_tests.py


示例17: test_a

 def test_a(self):
     self.assertFalse(Validate.validate_blood_type("A"))
开发者ID:AndrasKesik,项目名称:Python_BloodDonorRegistration,代码行数:2,代码来源:validation_tests.py


示例18: test_long

 def test_long(self):
     self.assertFalse(Validate.validate_blood_type("ggsiiuh sv448hg hsuh94"))
开发者ID:AndrasKesik,项目名称:Python_BloodDonorRegistration,代码行数:2,代码来源:validation_tests.py


示例19: test_azavaroslower

 def test_azavaroslower(self):
     self.assertTrue(Validate.validate_city_name("miskolc"))
开发者ID:AndrasKesik,项目名称:Python_BloodDonorRegistration,代码行数:2,代码来源:validation_tests.py


示例20: test_bpluslower

 def test_bpluslower(self):
     self.assertTrue(Validate.validate_blood_type("b+"))
开发者ID:AndrasKesik,项目名称:Python_BloodDonorRegistration,代码行数:2,代码来源:validation_tests.py



注:本文中的validation.Validate类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python validation_mocks.get_mock_key_file函数代码示例发布时间:2022-05-26
下一篇:
Python validation.cast_integer函数代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap