本文整理匯總了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(""))