本文整理汇总了Python中validators.email方法的典型用法代码示例。如果您正苦于以下问题:Python validators.email方法的具体用法?Python validators.email怎么用?Python validators.email使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类validators
的用法示例。
在下文中一共展示了validators.email方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: printUsers
# 需要导入模块: import validators [as 别名]
# 或者: from validators import email [as 别名]
def printUsers():
table = texttable.Texttable()
table.set_deco(texttable.Texttable.HEADER)
table.set_cols_dtype(['i', # int
't',
't',
't',
't']) # text
table.header(["ID", "USERNAME", "EMAIL", "KINDLE EMAIL", "SEND EBOOK"])
db.connection()
for user in User.select():
if user.sendtokindle == 1:
sendstatus = "YES"
else:
sendstatus = "NO"
table.add_row([user.userid, user.name, user.email, user.kindle_mail, sendstatus])
db.close()
logging.info(table.draw())
示例2: __init__
# 需要导入模块: import validators [as 别名]
# 或者: from validators import email [as 别名]
def __init__(self, uid, username, email):
self.uid = uid
self.username = username
self.email = email
示例3: test_account_factory_different_data
# 需要导入模块: import validators [as 别名]
# 或者: from validators import email [as 别名]
def test_account_factory_different_data(account_factory):
account1 = account_factory()
account2 = account_factory()
assert isinstance(account1, Account)
assert isinstance(account2, Account)
assert account1 != account2
assert account1.uid != account2.uid
assert account1.username != account2.username
assert account1.email != account2.email
示例4: test_account_factory_overrides
# 需要导入模块: import validators [as 别名]
# 或者: from validators import email [as 别名]
def test_account_factory_overrides(account_factory):
username = 'sobolevn'
desired_id = 190
account = account_factory(username=username, uid=desired_id)
assert account.uid == desired_id
assert account.username == username
assert account.email.startswith(username)
示例5: test_account_factory_create_batch
# 需要导入模块: import validators [as 别名]
# 或者: from validators import email [as 别名]
def test_account_factory_create_batch(account_factory):
accounts = account_factory.create_batch(10)
uids = {account.uid for account in accounts}
usernames = {account.username for account in accounts}
assert len(accounts) == len(uids)
assert len(accounts) == len(usernames)
for account in accounts:
assert isinstance(account, Account)
assert account.uid > 0
assert account.username != ''
assert account.email.startswith(account.username)
示例6: test_account_factory_build_batch
# 需要导入模块: import validators [as 别名]
# 或者: from validators import email [as 别名]
def test_account_factory_build_batch(account_factory):
accounts = account_factory.build_batch(10)
uids = {account.uid for account in accounts}
usernames = {account.username for account in accounts}
assert len(accounts) == len(uids)
assert len(accounts) == len(usernames)
for account in accounts:
assert isinstance(account, Account)
assert account.uid > 0
assert account.username != ''
assert account.email.startswith(account.username)
示例7: test_account_data_overrides
# 需要导入模块: import validators [as 别名]
# 或者: from validators import email [as 别名]
def test_account_data_overrides(account):
assert account.username in TEST_USERNAMES
username, _ = account.email.split('@')
assert account.username == username
assert username in TEST_USERNAMES
示例8: test_account_multiple_data_overrides
# 需要导入模块: import validators [as 别名]
# 或者: from validators import email [as 别名]
def test_account_multiple_data_overrides(account):
assert account.username in TEST_USERNAMES
assert 10000 <= account.uid < 10003
username, _ = account.email.split('@')
assert account.username == username
assert username in TEST_USERNAMES
示例9: is_valid_email
# 需要导入模块: import validators [as 别名]
# 或者: from validators import email [as 别名]
def is_valid_email(email):
return bool(validators.email(email))
示例10: validate_result
# 需要导入模块: import validators [as 别名]
# 或者: from validators import email [as 别名]
def validate_result(current, default, type):
"""
Validates the data, whether it needs to be url, twitter, linkedin link etc.
"""
if current is None:
current = ""
if default is None:
default = ""
if type == "URL" and validators.url(current, require_tld=True) and not validators.url(default, require_tld=True):
return current
if type == "EMAIL" and validators.email(current) and not validators.email(default):
return current
return default
示例11: test_valid_author
# 需要导入模块: import validators [as 别名]
# 或者: from validators import email [as 别名]
def test_valid_author():
assert quantopian_tools.__author__
assert validators.email(quantopian_tools.__author_email__)
示例12: test_valid_maintainer
# 需要导入模块: import validators [as 别名]
# 或者: from validators import email [as 别名]
def test_valid_maintainer():
assert quantopian_tools.__maintainer__
assert validators.email(quantopian_tools.__maintainer_email__)
示例13: process_iocs
# 需要导入模块: import validators [as 别名]
# 或者: from validators import email [as 别名]
def process_iocs(results):
"""Return data formatted for Splunk from ThreatCrowd."""
if results != None:
provided_iocs = [y for x in results for y in x.values()]
else:
provided_iocs = sys.argv[1:]
session = commons.create_session()
splunk_table = []
for provided_ioc in set(provided_iocs):
provided_ioc = commons.deobfuscate_string(provided_ioc)
provided_ioc = provided_ioc.lower()
if validators.ipv4(provided_ioc):
ioc_type = "ip"
elif validators.domain(provided_ioc):
ioc_type = "domain"
elif validators.email(provided_ioc):
ioc_type = "email"
elif re.match("^[a-f\d]{32}$", provided_ioc) or re.match("^[a-f\d]{64}$", provided_ioc):
ioc_type = "resource"
else:
splunk_table.append({"invalid": provided_ioc})
continue
ioc_dicts = query_threatcrowd(provided_ioc, ioc_type, session)
for ioc_dict in ioc_dicts:
splunk_table.append(ioc_dict)
if len(provided_iocs) > 1:
sleep(10)
session.close()
return splunk_table
示例14: createUser
# 需要导入模块: import validators [as 别名]
# 或者: from validators import email [as 别名]
def createUser():
# Start interactive Shell!
while True:
username = input("Enter User Name: ")
if validators.truthy(username):
break
else:
print("Please enter a valid username!")
continue
while True:
email = input("Enter your Email: ")
if validators.email(email):
break
else:
print("Please enter a valid email!")
continue
while True:
kindlemail = input("Enter your Kindle Email: ")
if validators.email(kindlemail):
break
else:
print("Please enter a valid Email!")
continue
while True:
sendToKindle = input("Do you want to send Ebooks to this Account? [yes/no] ")
if sendToKindle == "yes":
break
elif sendToKindle == "no":
break
else:
print("Answer with yes or no.")
continue
logging.debug([username, email, kindlemail, sendToKindle])
# switch sendToKindle to 0 or 1
if sendToKindle == "yes":
sendToKindle = "1"
else:
sendToKindle = "0"
# Save data now!
db.connection()
newuser = User.create(email=email, name=username, sendtokindle=sendToKindle, kindle_mail=kindlemail)
try:
newuser.save()
except IntegrityError as fail:
db.rollback()
logging.error(fail)
finally:
logging.info("Succesfully added user %s!", username)
db.close()