本文整理汇总了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()
示例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()
示例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:
示例4: test_nothing
# 需要导入模块: from validation import Validate [as 别名]
# 或者: from validation.Validate import validate_id [as 别名]
def test_nothing(self):
self.assertFalse(Validate.validate_id(""))