librus_apix.helpers
This module defines a function for checking access to Librus resources by examining the content of a BeautifulSoup object.
Functions: - no_access_check: Checks for access to Librus resources by examining the content of a BeautifulSoup object.
1""" 2This module defines a function for checking access to Librus resources by examining the content of a BeautifulSoup object. 3 4Functions: 5 - no_access_check: Checks for access to Librus resources by examining the content of a BeautifulSoup object. 6 7""" 8 9from bs4 import BeautifulSoup 10from librus_apix.exceptions import TokenError 11 12 13def no_access_check(soup: BeautifulSoup) -> BeautifulSoup: 14 pattern = "Brak dostępu" 15 no_access = soup.select_one("h2.inside") 16 if not no_access: 17 return soup 18 if pattern in no_access.get_text(): 19 raise TokenError("Malformed or expired token.") 20 else: 21 return soup
def
no_access_check(soup: bs4.BeautifulSoup) -> bs4.BeautifulSoup: