def parse(file: str, endswith: Optional[str]) -> None: """Parse given file for emails.""" with open(file, mode="r", encoding="utf-8") as f: for line in f: for email in parse_emails(line): if endswith and not email.endswith(endswith): continue click.echo(email)
def test_parse_email_sql() -> None: assert parse_emails( "1:[email protected]:john:pass:John Doe:::1900-00-00:00:M:66:729:67793" ) == ["*****@*****.**"]
def test_parse_emails_invalid() -> None: assert parse_emails("*****@*****.**") == []
def test_parse_emails_empty() -> None: assert parse_emails("Hello, world!") == []
def test_parse_email_sentence_multiple() -> None: assert parse_emails( "Hello [email protected]! How are you? It's [email protected]!" ) == ["*****@*****.**", "*****@*****.**"]
def test_parse_email_sentence_single() -> None: assert parse_emails("Hello [email protected]! How are you?") == ["*****@*****.**"]
def test_parse_emails_multiple() -> None: assert parse_emails("[email protected] [email protected]") == [ "*****@*****.**", "*****@*****.**", ]
def test_parse_emails_single() -> None: assert parse_emails("*****@*****.**") == ["*****@*****.**"]