MCPcopy Index your code
hub / github.com/JoshData/python-email-validator / main

Function main

email_validator/__main__.py:27–57  ·  view source on GitHub ↗
(dns_resolver: Optional[_Resolver] = None)

Source from the content-addressed store, hash-verified

25
26
27def main(dns_resolver: Optional[_Resolver] = None) -> None:
28 # The dns_resolver argument is for tests.
29
30 # Set options from environment variables.
31 options: Dict[str, Any] = {}
32 for varname in ('ALLOW_SMTPUTF8', 'ALLOW_EMPTY_LOCAL', 'ALLOW_QUOTED_LOCAL', 'ALLOW_DOMAIN_LITERAL',
33 'ALLOW_DISPLAY_NAME',
34 'GLOBALLY_DELIVERABLE', 'CHECK_DELIVERABILITY', 'TEST_ENVIRONMENT'):
35 if varname in os.environ:
36 options[varname.lower()] = bool(os.environ[varname])
37 for varname in ('DEFAULT_TIMEOUT',):
38 if varname in os.environ:
39 options[varname.lower()] = float(os.environ[varname])
40
41 if len(sys.argv) == 1:
42 # Validate the email addresses passed line-by-line on STDIN.
43 dns_resolver = dns_resolver or caching_resolver()
44 for line in sys.stdin:
45 email = line.strip()
46 try:
47 validate_email(email, dns_resolver=dns_resolver, **options)
48 except EmailNotValidError as e:
49 print(f"{email} {e}")
50 else:
51 # Validate the email address passed on the command line.
52 email = sys.argv[1]
53 try:
54 result = validate_email(email, dns_resolver=dns_resolver, **options)
55 print(json.dumps(result.as_dict(), indent=2, sort_keys=True, ensure_ascii=False))
56 except EmailNotValidError as e:
57 print(e)
58
59
60if __name__ == "__main__":

Callers 1

__main__.pyFile · 0.85

Calls 3

validate_emailFunction · 0.90
as_dictMethod · 0.80
caching_resolverFunction · 0.70

Tested by

no test coverage detected