Skip to content

Commit

Permalink
add chardet.universaldetector (#3734)
Browse files Browse the repository at this point in the history
  • Loading branch information
ju-sh committed Mar 12, 2020
1 parent 62f1aa5 commit b44cd29
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 0 deletions.
4 changes: 4 additions & 0 deletions third_party/2and3/chardet/__init__.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
from typing import Any
from .universaldetector import UniversalDetector as UniversalDetector

def __getattr__(name: str) -> Any: ... # incomplete
31 changes: 31 additions & 0 deletions third_party/2and3/chardet/universaldetector.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import sys
from typing import Dict, Union, AnyStr, Pattern, Optional
from typing_extensions import TypedDict
from logging import Logger

class _FinalResultType(TypedDict):
encoding: str
confidence: float
language: str

class _IntermediateResultType(TypedDict):
encoding: Optional[str]
confidence: float
language: Optional[str]

class UniversalDetector(object):
MINIMUM_THRESHOLD: float
HIGH_BYTE_DETECTOR: Pattern[bytes]
ESC_DETECTOR: Pattern[bytes]
WIN_BYTE_DETECTOR: Pattern[bytes]
ISO_WIN_MAP: Dict[str, str]

result: _IntermediateResultType
done: bool
lang_filter: int
logger: Logger

def __init__(self, lang_filter: int) -> None: ...
def reset(self) -> None: ...
def feed(self, byte_str: bytes) -> None: ...
def close(self) -> _FinalResultType: ...

0 comments on commit b44cd29

Please sign in to comment.