示例#1
0
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)
示例#2
0
def test_parse_email_sql() -> None:
    assert parse_emails(
        "1:[email protected]:john:pass:John Doe:::1900-00-00:00:M:66:729:67793"
    ) == ["*****@*****.**"]
示例#3
0
def test_parse_emails_invalid() -> None:
    assert parse_emails("*****@*****.**") == []
示例#4
0
def test_parse_emails_empty() -> None:
    assert parse_emails("Hello, world!") == []
示例#5
0
def test_parse_email_sentence_multiple() -> None:
    assert parse_emails(
        "Hello [email protected]! How are you? It's [email protected]!"
    ) == ["*****@*****.**", "*****@*****.**"]
示例#6
0
def test_parse_email_sentence_single() -> None:
    assert parse_emails("Hello [email protected]! How are you?") == ["*****@*****.**"]
示例#7
0
def test_parse_emails_multiple() -> None:
    assert parse_emails("[email protected] [email protected]") == [
        "*****@*****.**",
        "*****@*****.**",
    ]
示例#8
0
def test_parse_emails_single() -> None:
    assert parse_emails("*****@*****.**") == ["*****@*****.**"]