compass.utilities.url.URLPartFilter#

class URLPartFilter(blacklist=None, whitelist=None)[source]#

Bases: object

Match URL parts with whitelist precedence

Parameters:
  • blacklist (Iterable of str, optional) – URL parts that exclude matching URLs. By default, None.

  • whitelist (Iterable of str, optional) – URL parts that override blacklist matches. By default, None.

Methods

blacklist_match(url)

Return the first blacklist match unless URL is whitelisted

is_whitelisted(url)

Check whether any whitelist part occurs in a URL

blacklist_match(url)[source]#

Return the first blacklist match unless URL is whitelisted

Parameters:

url (str) – URL string to check against the blacklist.

Returns:

str or None – The first matching blacklist part if found and not whitelisted, otherwise None.

is_whitelisted(url)[source]#

Check whether any whitelist part occurs in a URL

Parameters:

url (str) – URL string to check against the whitelist.

Returns:

boolTrue if any whitelist part occurs in the URL, otherwise False.