# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
+import logging
+
import validators
+logging.basicConfig(level=logging.INFO)
+logger = logging.getLogger(__name__)
+
# Cookies stor
_cookies = {}
def store (domain: str, cookies: dict):
- # DEBUG: print(f"DEBUG: domain='{domain}',cookies()={len(cookies)} - CALLED!")
+ logger.debug(f"domain='{domain}',cookies()={len(cookies)} - CALLED!")
if not isinstance(domain, str):
raise ValueError(f"Parameter domain[]='{type(domain)}' is not 'str'")
elif domain == "":
_cookies[domain] = cookies
- # DEBUG: print(f"DEBUG: EXIT!")
+ logger.debug(f"EXIT!")
def get_all(domain: str) -> dict:
- # DEBUG: print(f"DEBUG: domain='{domain}' - CALLED!")
+ logger.debug(f"domain='{domain}' - CALLED!")
if not isinstance(domain, str):
raise ValueError(f"Parameter domain[]='{type(domain)}' is not 'str'")
elif domain == "":
elif not has(domain):
raise Exception(f"domain='{domain}' has no cookies stored, maybe invoke store() first?")
- # DEBUG: print(f"DEBUG: _cookies[{domain}]()={len(_cookies[domain])} - EXIT!")
+ logger.debug(f"_cookies[{domain}]()={len(_cookies[domain])} - EXIT!")
return _cookies[domain]
def has (domain: str) -> bool:
- # DEBUG: print(f"DEBUG: domain='{domain}' - CALLED!")
+ logger.debug(f"domain='{domain}' - CALLED!")
if not isinstance(domain, str):
raise ValueError(f"Parameter domain[]='{type(domain)}' is not 'str'")
elif domain == "":
has_cookies = domain in _cookies
- # DEBUG: print(f"DEBUG: has_cookies='{has_cookies}' - EXIT!")
+ logger.debug(f"has_cookies='{has_cookies}' - EXIT!")
return has_cookies
def clear (domain: str):
- # DEBUG: print(f"DEBUG: domain='{domain}' - CALLED!")
+ logger.debug(f"domain='{domain}' - CALLED!")
if not isinstance(domain, str):
raise ValueError(f"Parameter domain[]='{type(domain)}' is not 'str'")
elif domain == "":
raise ValueError(f"domain='{domain}' is a fake domain, please don't crawl them!")
if has(domain):
- # DEBUG: print(f"DEBUG: Removing cookies for domain='{domain}' ...")
+ logger.debug(f"Removing cookies for domain='{domain}' ...")
del _cookies[domain]
- # DEBUG: print(f"DEBUG: EXIT!")
+ logger.debug(f"EXIT!")