Re-organize directory structure (#4971)

See discussion in #2491

Co-authored-by: Ivan Levkivskyi <ilevkivskyi@dropbox.com>
This commit is contained in:
Ivan Levkivskyi
2021-01-27 12:00:39 +00:00
committed by GitHub
parent 869238e587
commit 16ae4c6120
1399 changed files with 601 additions and 97 deletions

View File

@@ -0,0 +1,2 @@
version = "0.1"
python2 = true

View File

@@ -0,0 +1,27 @@
from typing import Any, Container, Iterable, Optional, Text
from bleach.linkifier import DEFAULT_CALLBACKS as DEFAULT_CALLBACKS, Linker as Linker, _Callback
from bleach.sanitizer import (
ALLOWED_ATTRIBUTES as ALLOWED_ATTRIBUTES,
ALLOWED_PROTOCOLS as ALLOWED_PROTOCOLS,
ALLOWED_STYLES as ALLOWED_STYLES,
ALLOWED_TAGS as ALLOWED_TAGS,
Cleaner as Cleaner,
)
__releasedate__: Text
__version__: Text
VERSION: Any # packaging.version.Version
def clean(
text: Text,
tags: Container[Text] = ...,
attributes: Any = ...,
styles: Container[Text] = ...,
protocols: Container[Text] = ...,
strip: bool = ...,
strip_comments: bool = ...,
) -> Text: ...
def linkify(
text: Text, callbacks: Iterable[_Callback] = ..., skip_tags: Optional[Container[Text]] = ..., parse_email: bool = ...
) -> Text: ...

View File

@@ -0,0 +1,6 @@
from typing import Any, MutableMapping, Text
_Attrs = MutableMapping[Any, Text]
def nofollow(attrs: _Attrs, new: bool = ...) -> _Attrs: ...
def target_blank(attrs: _Attrs, new: bool = ...) -> _Attrs: ...

View File

@@ -0,0 +1,31 @@
from typing import Any, Container, Iterable, List, MutableMapping, Optional, Pattern, Protocol, Text
_Attrs = MutableMapping[Any, Text]
class _Callback(Protocol):
def __call__(self, attrs: _Attrs, new: bool = ...) -> _Attrs: ...
DEFAULT_CALLBACKS: List[_Callback]
TLDS: List[Text]
def build_url_re(tlds: Iterable[Text] = ..., protocols: Iterable[Text] = ...) -> Pattern[Text]: ...
URL_RE: Pattern[Text]
PROTO_RE: Pattern[Text]
EMAIL_RE: Pattern[Text]
class Linker(object):
def __init__(
self,
callbacks: Iterable[_Callback] = ...,
skip_tags: Optional[Container[Text]] = ...,
parse_email: bool = ...,
url_re: Pattern[Text] = ...,
email_re: Pattern[Text] = ...,
recognized_tags: Optional[Container[Text]] = ...,
) -> None: ...
def linkify(self, text: Text) -> Text: ...
class LinkifyFilter(object): # TODO: derives from html5lib.Filter
def __getattr__(self, item: str) -> Any: ... # incomplete

View File

@@ -0,0 +1,34 @@
from typing import Any, Callable, Container, Dict, Iterable, List, Optional, Pattern, Text, Union
ALLOWED_TAGS: List[Text]
ALLOWED_ATTRIBUTES: Dict[Text, List[Text]]
ALLOWED_STYLES: List[Text]
ALLOWED_PROTOCOLS: List[Text]
INVISIBLE_CHARACTERS: Text
INVISIBLE_CHARACTERS_RE: Pattern[Text]
INVISIBLE_REPLACEMENT_CHAR: Text
# A html5lib Filter class
_Filter = Any
class Cleaner(object):
def __init__(
self,
tags: Container[Text] = ...,
attributes: Any = ...,
styles: Container[Text] = ...,
protocols: Container[Text] = ...,
strip: bool = ...,
strip_comments: bool = ...,
filters: Optional[Iterable[_Filter]] = ...,
) -> None: ...
def clean(self, text: Text) -> Text: ...
_AttributeFilter = Callable[[Text, Text, Text], bool]
_AttributeDict = Dict[Text, Union[Container[Text], _AttributeFilter]]
def attribute_filter_factory(attributes: Union[_AttributeFilter, _AttributeDict, Container[Text]]) -> _AttributeFilter: ...
class BleachSanitizerFilter(object): # TODO: derives from html5lib.sanitizer.Filter
def __getattr__(self, item: str) -> Any: ... # incomplete

View File

@@ -0,0 +1,8 @@
from collections import OrderedDict
from typing import Any, Mapping, Text, overload
def force_unicode(text: Text) -> Text: ...
@overload
def alphabetize_attributes(attrs: None) -> None: ...
@overload
def alphabetize_attributes(attrs: Mapping[Any, Text]) -> OrderedDict[Any, Text]: ...