python-adblock

Updated Brave adblock library for Python
Log | Files | Refs | README

adblock.pyi (3328B)


      1 from typing import Optional, Dict, List, Set
      2 
      3 __version__: str
      4 
      5 class AdblockException(Exception):
      6     pass
      7 
      8 class BlockerException(AdblockException):
      9     pass
     10 
     11 class SerializationError(BlockerException):
     12     pass
     13 
     14 class DeserializationError(BlockerException):
     15     pass
     16 
     17 class OptimizedFilterExistence(BlockerException):
     18     pass
     19 
     20 class BadFilterAddUnsupported(BlockerException):
     21     pass
     22 
     23 class FilterExists(BlockerException):
     24     pass
     25 
     26 class AddResourceException(AdblockException):
     27     pass
     28 
     29 class InvalidUtf8ContentError(AddResourceException):
     30     pass
     31 
     32 class InvalidBase64ContentError(AddResourceException):
     33     pass
     34 
     35 class BlockerResult:
     36     matched: bool
     37     explicit_cancel: bool
     38     important: bool
     39     redirect_type: Optional[str]
     40     redirect: Optional[str]
     41     exception: Optional[str]
     42     filter: Optional[str]
     43     error: Optional[str]
     44     def __repr__(self) -> str:
     45         pass
     46 
     47 class UrlSpecificResources:
     48     hide_selectors: Set[str]
     49     style_selectors: Dict[str, List[str]]
     50     exceptions: Set[str]
     51     injected_script: str
     52     def __repr__(self) -> str:
     53         pass
     54 
     55 class FilterSet:
     56     def __init__(self, debug: bool = False) -> None:
     57         pass
     58     def add_filter_list(
     59         self,
     60         filter_list: str,
     61         format: str = "standard",
     62         include_redirect_urls: bool = False,
     63         rule_types: str = "all",
     64     ) -> None:
     65         pass
     66     def add_filters(
     67         self,
     68         filters: List[str],
     69         format: str = "standard",
     70         include_redirect_urls: bool = False,
     71         rule_types: str = "all",
     72     ) -> None:
     73         pass
     74 
     75 class Engine:
     76     def __init__(self, filter_set: FilterSet, optimize: bool = True) -> None:
     77         pass
     78     def check_network_urls(
     79         self, url: str, source_url: str, request_type: str
     80     ) -> BlockerResult:
     81         pass
     82     def check_network_urls_with_hostnames(
     83         self,
     84         url: str,
     85         hostname: str,
     86         source_hostname: str,
     87         request_type: str,
     88         third_party_request: Optional[bool],
     89     ) -> BlockerResult:
     90         pass
     91     def check_network_urls_with_hostnames_subset(
     92         self,
     93         url: str,
     94         hostname: str,
     95         source_hostname: str,
     96         request_type: str,
     97         third_party_request: Optional[bool],
     98         previously_matched_rule: bool,
     99         force_check_exceptions: bool,
    100     ) -> BlockerResult:
    101         pass
    102     def serialize(self) -> bytes:
    103         pass
    104     def serialize_to_file(self, file: str) -> None:
    105         pass
    106     def deserialize(self, serialized: bytes) -> None:
    107         pass
    108     def deserialize_from_file(self, file: str) -> None:
    109         pass
    110     def filter_exists(self, filter: str) -> bool:
    111         pass
    112     def use_tags(self, tags: List[str]) -> None:
    113         pass
    114     def enable_tags(self, tags: List[str]) -> None:
    115         pass
    116     def disable_tags(self, tags: List[str]) -> None:
    117         pass
    118     def tag_exists(self, tag: str) -> bool:
    119         pass
    120     def add_resource(
    121         self,
    122         name: str,
    123         content_type: str,
    124         content: str,
    125         aliases: Optional[List[str]] = None,
    126     ) -> bool:
    127         pass
    128     def url_cosmetic_resources(self, url: str) -> UrlSpecificResources:
    129         pass
    130     def hidden_class_id_selectors(
    131         self, classes: List[str], ids: List[str], exceptions: Set[str]
    132     ) -> List[str]:
    133         pass