def sanitize_page_number(page):
    """A helper function for cleanup a ``page`` argument. Cast a string to
    integer and check that the final value is positive.
    If the value is not valid returns 1.
    """
    if isinstance(page, str) and page.isdigit():
        page = int(page)
    if isinstance(page, int) and page > 0:
        return page
    return 1
