當前位置: 首頁>>代碼示例>>Python>>正文


Python email_validator.EmailNotValidError方法代碼示例

本文整理匯總了Python中email_validator.EmailNotValidError方法的典型用法代碼示例。如果您正苦於以下問題:Python email_validator.EmailNotValidError方法的具體用法?Python email_validator.EmailNotValidError怎麽用?Python email_validator.EmailNotValidError使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在email_validator的用法示例。


在下文中一共展示了email_validator.EmailNotValidError方法的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: test_email_invalid

# 需要導入模塊: import email_validator [as 別名]
# 或者: from email_validator import EmailNotValidError [as 別名]
def test_email_invalid():
    with pytest.raises(EmailNotValidError):
        EmailNotification('foo') 
開發者ID:Nike-Inc,項目名稱:signal_analog,代碼行數:5,代碼來源:test_signal_analog_detectors.py

示例2: is_valid_email_address

# 需要導入模塊: import email_validator [as 別名]
# 或者: from email_validator import EmailNotValidError [as 別名]
def is_valid_email_address(email_address):
	"""
	Check that the string specified appears to be a valid email address.

	:param str email_address: The email address to validate.
	:return: Whether the email address appears to be valid or not.
	:rtype: bool
	"""
	if email_address is None:
		return False
	try:
		email_validator.validate_email(email_address, allow_empty_local=False, check_deliverability=False)
	except email_validator.EmailNotValidError:
		return False
	return True 
開發者ID:rsmusllp,項目名稱:king-phisher,代碼行數:17,代碼來源:utilities.py

示例3: validate_email

# 需要導入模塊: import email_validator [as 別名]
# 或者: from email_validator import EmailNotValidError [as 別名]
def validate_email(email):
    try:
        return email_validator.validate_email(email)["email"]
    except email_validator.EmailNotValidError as e:
        raise EmailNotValidException(str(e)) 
開發者ID:cgwire,項目名稱:zou,代碼行數:7,代碼來源:auth.py

示例4: check_value

# 需要導入模塊: import email_validator [as 別名]
# 或者: from email_validator import EmailNotValidError [as 別名]
def check_value(self, value):
        try:
            validate_email(value,
                           allow_smtputf8=self.allow_smtputf8,
                           check_deliverability=self.check_deliverability,
                           allow_empty_local=self.allow_empty_local)
            return True
        except EmailNotValidError:
            return False 
開發者ID:xeBuz,項目名稱:Flask-Validator,代碼行數:11,代碼來源:internet.py

示例5: get_mfa

# 需要導入模塊: import email_validator [as 別名]
# 或者: from email_validator import EmailNotValidError [as 別名]
def get_mfa(self, username):
        try:
          validate_email(username)
          accountType = 2 # email
        except EmailNotValidError as _e:
          accountType = 1 # phone

        response = requests.get(self._urls.get_mfa(username, str(accountType), str(self._did), str(5), str(1)), headers=self._headers) 
開發者ID:tedchou12,項目名稱:webull,代碼行數:10,代碼來源:webull.py

示例6: validate_email

# 需要導入模塊: import email_validator [as 別名]
# 或者: from email_validator import EmailNotValidError [as 別名]
def validate_email(value: Union[str]) -> Tuple[str, str]:
    """
    Brutally simple email address validation. Note unlike most email address validation
    * raw ip address (literal) domain parts are not allowed.
    * "John Doe <local_part@domain.com>" style "pretty" email addresses are processed
    * the local part check is extremely basic. This raises the possibility of unicode spoofing, but no better
        solution is really possible.
    * spaces are striped from the beginning and end of addresses but no error is raised

    See RFC 5322 but treat it with suspicion, there seems to exist no universally acknowledged test for a valid email!
    """
    if email_validator is None:
        import_email_validator()

    m = pretty_email_regex.fullmatch(value)
    name: Optional[str] = None
    if m:
        name, value = m.groups()

    email = value.strip()

    try:
        email_validator.validate_email(email, check_deliverability=False)
    except email_validator.EmailNotValidError as e:
        raise errors.EmailError() from e

    at_index = email.index('@')
    local_part = email[:at_index]  # RFC 5321, local part must be case-sensitive.
    global_part = email[at_index:].lower()

    return name or local_part, local_part + global_part 
開發者ID:samuelcolvin,項目名稱:pydantic,代碼行數:33,代碼來源:networks.py

示例7: login

# 需要導入模塊: import email_validator [as 別名]
# 或者: from email_validator import EmailNotValidError [as 別名]
def login(self, username='', password='', device_name='', mfa=''):
        '''
        Login with email or phone number

        phone numbers must be a str in the following form
        US '+1-XXXXXXX'
        CH '+86-XXXXXXXXXXX'
        '''

        if not username or not password:
            raise ValueError('username or password is empty')

        # with webull md5 hash salted
        password = ('wl_app-a&b@!423^' + password).encode('utf-8')
        md5_hash = hashlib.md5(password)

        try:
          validate_email(username)
          accountType = 2 # email
        except EmailNotValidError as _e:
          accountType = 1 # phone

        if device_name == '' :
            device_name = 'default_string'

        data = {
            'account': username,
            'accountType': accountType,
            'deviceId': self._did,
            'deviceName': device_name,
            'grade': 1,
            'pwd': md5_hash.hexdigest(),
            'regionId': 1
        }

        if mfa != '' :
            data['extInfo'] = {'verificationCode': mfa}
            headers = self.build_req_headers()
        else :
            headers = self._headers
        response = requests.post(self._urls.login(), json=data, headers=headers)
        result = response.json()
        if 'accessToken' in result :
            self._access_token = result['accessToken']
            self._refresh_token = result['refreshToken']
            self._token_expire = result['tokenExpireTime']
            self._uuid = result['uuid']
            self._account_id = self.get_account_id()
        return result 
開發者ID:tedchou12,項目名稱:webull,代碼行數:51,代碼來源:webull.py


注:本文中的email_validator.EmailNotValidError方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。