当前位置: 首页>>代码示例>>Python>>正文


Python Validate.validate_id方法代码示例

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


在下文中一共展示了Validate.validate_id方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: delete_donor

# 需要导入模块: from validation import Validate [as 别名]
# 或者: from validation.Validate import validate_id [as 别名]
 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,代码行数:36,代码来源:donor_manager_db.py

示例2: delete_donor

# 需要导入模块: from validation import Validate [as 别名]
# 或者: from validation.Validate import validate_id [as 别名]
 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,代码行数:41,代码来源:donor_manager_csv.py

示例3: input

# 需要导入模块: from validation import Validate [as 别名]
# 或者: from validation.Validate import validate_id [as 别名]
 elif user_input == MENU_ITEM_7:
     user_input = ""
     while user_input == "":
         user_input = input("(0) Cancel\nType ID number: ")
         user_input = user_input.upper()
         clear()
         if user_input == '0':
             break
         elif user_input.isdigit():
             if connect_decider:
                 EventManagerDB.change_event(user_input, cursor)
                 connection.commit()
             else:
                 EventManagerCSV.change_event(user_input)
             actv_selection = 0
         elif Validate.validate_id(user_input):
             if connect_decider:
                 DonorManagerDB.change_donor_data(user_input,cursor)
                 connection.commit()
             else:
                 DonorManager.change_donor_data(user_input)
             actv_selection = 0
         else:
             print(ID_ERR + "\n\t\t\t\tor\n" + POSINT_ERR)
             time.sleep(3)
             clear()
             user_input = ""
 #
 # EXIT
 #
 elif user_input == MENU_ITEM_8:
开发者ID:AndrasKesik,项目名称:Python_BloodDonorRegistration,代码行数:33,代码来源:main.py

示例4: test_nothing

# 需要导入模块: from validation import Validate [as 别名]
# 或者: from validation.Validate import validate_id [as 别名]
 def test_nothing(self):
     self.assertFalse(Validate.validate_id(""))
开发者ID:AndrasKesik,项目名称:Python_BloodDonorRegistration,代码行数:4,代码来源:validation_tests.py


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