Skip to content

Create try_get_text helper function in parse_xml #287

@AdrianDAlessandro

Description

@AdrianDAlessandro

This pattern seems

to be quite common. A little helper function might help with readability here and elsewhere:

def try_get_text(soup: BeautifulSoup, name: str, attrs: dict[str, str]) -> str:
    if result := soup.find(name, attrs):
        return result.text
    return ""

Originally posted by @alexdewar in #263 (comment)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions