# THIS FILE IS AUTOMATICALLY GENERATED, DO NOT EDIT MANUALLY.

from typing import (
    Any,
    Callable,
    ClassVar,
    FrozenSet,
    Iterable,
    List,
    Mapping,
    Optional,
    Sequence,
    Tuple,
    Union,
)

from html.parser import HTMLParser
from xml.etree import ElementTree

XPathResult = Union[Sequence[str], Sequence[ElementTree.Element]]
XPather = Callable[[ElementTree.Element], XPathResult]
StrTransformer = Callable[[str], Any]
MapTransformer = Callable[[Mapping], Any]
Transformer = Callable[[Any], Any]
StrExtractor = Callable[[ElementTree.Element], str]
MapExtractor = Callable[[ElementTree.Element], Mapping]
Extractor = Callable[[ElementTree.Element], Any]
Preprocessor = Callable[[ElementTree.Element], None]

__version__ = ...  # type: str


class HTMLNormalizer(HTMLParser):
    VOID_ELEMENTS = ...  # type: ClassVar[FrozenSet[str]]
    omit_tags = ...  # type: FrozenSet[str]
    omit_attrs = ...  # type: FrozenSet[str]
    def __init__(
        self, *, omit_tags: Iterable[str] = ..., omit_attrs: Iterable[str] = ...
    ) -> None: ...

def html_to_xhtml(
    document: str,
    *,
    omit_tags: Iterable[str] = ...,
    omit_attrs: Iterable[str] = ...,
) -> str: ...
def build_tree(
    document: str, *, lxml_html: bool = ...
) -> ElementTree.Element: ...
def get_parent(element: ElementTree.Element) -> ElementTree.Element: ...
def make_xpather(path: str) -> XPather: ...
def make_path(
    path: str,
    sep: Optional[str] = ...,
    transform: Optional[StrTransformer] = ...,
    foreach: Optional[str] = ...,
) -> Extractor: ...
def make_items(
    rules: Sequence[MapExtractor],
    section: Optional[str] = ...,
    transform: Optional[MapTransformer] = ...,
    foreach: Optional[str] = ...,
) -> Extractor: ...
def make_rule(
    key: Union[str, StrExtractor],
    value: Extractor,
    *,
    foreach: Optional[str] = ...,
) -> MapExtractor: ...

class preprocessors:
    @staticmethod
    def remove(path: str) -> Preprocessor: ...
    @staticmethod
    def set_attr(
        path: str, name: Union[str, StrExtractor], value: Union[str, StrExtractor]
    ) -> Preprocessor: ...
    @staticmethod
    def set_text(path: str, text: Union[str, StrExtractor]) -> Preprocessor: ...

class transformers:
    int = ...  # type: Callable[[Any], int]
    float = ...  # type: Callable[[Any], float]
    bool = ...  # type: Callable[[Any], bool]
    len = ...  # type: Callable[[Sequence], int]
    lower = ...  # type: Callable[[str], str]
    upper = ...  # type: Callable[[str], str]
    capitalize = ...  # type: Callable[[str], str]
    lstrip = ...  # type: Callable[[str], str]
    rstrip = ...  # type: Callable[[str], str]
    strip = ...  # type: Callable[[str], str]
    @staticmethod
    def clean(s: str) -> str: ...
    @staticmethod
    def normalize(s: str) -> str: ...

def chain(*functions) -> Callable[[Any], Any]: ...
def load_spec(filepath: str) -> Mapping: ...
def parse_spec(spec: Mapping) -> Tuple[Sequence[Preprocessor], Extractor]: ...
def scrape(
    document: str, spec: Mapping, *, lxml_html: bool = ...
) -> Mapping: ...
def main(argv: Optional[List[str]] = ...) -> None: ...
