mirror of
https://github.com/davidhalter/typeshed.git
synced 2025-12-07 12:44:28 +08:00
Added stub for sre_parse and sre_constants(py2) (#1500)
* Added stub for sre_parse (py2) * Added missing import * Added missing hints; Fixed _AvType and _TemplateType * Added stub for sre_constants
This commit is contained in:
committed by
Matthias Kramm
parent
c5479b11bb
commit
01a0c51acf
94
stdlib/2/sre_constants.pyi
Normal file
94
stdlib/2/sre_constants.pyi
Normal file
@@ -0,0 +1,94 @@
|
||||
# Source: https://hg.python.org/cpython/file/2.7/Lib/sre_constants.py
|
||||
|
||||
from typing import Dict, List, TypeVar
|
||||
|
||||
MAGIC = ... # type: int
|
||||
MAXREPEAT = ... # type: int
|
||||
|
||||
class error(Exception): ...
|
||||
|
||||
FAILURE = ... # type: str
|
||||
SUCCESS = ... # type: str
|
||||
ANY = ... # type: str
|
||||
ANY_ALL = ... # type: str
|
||||
ASSERT = ... # type: str
|
||||
ASSERT_NOT = ... # type: str
|
||||
AT = ... # type: str
|
||||
BIGCHARSET = ... # type: str
|
||||
BRANCH = ... # type: str
|
||||
CALL = ... # type: str
|
||||
CATEGORY = ... # type: str
|
||||
CHARSET = ... # type: str
|
||||
GROUPREF = ... # type: str
|
||||
GROUPREF_IGNORE = ... # type: str
|
||||
GROUPREF_EXISTS = ... # type: str
|
||||
IN = ... # type: str
|
||||
IN_IGNORE = ... # type: str
|
||||
INFO = ... # type: str
|
||||
JUMP = ... # type: str
|
||||
LITERAL = ... # type: str
|
||||
LITERAL_IGNORE = ... # type: str
|
||||
MARK = ... # type: str
|
||||
MAX_REPEAT = ... # type: str
|
||||
MAX_UNTIL = ... # type: str
|
||||
MIN_REPEAT = ... # type: str
|
||||
MIN_UNTIL = ... # type: str
|
||||
NEGATE = ... # type: str
|
||||
NOT_LITERAL = ... # type: str
|
||||
NOT_LITERAL_IGNORE = ... # type: str
|
||||
RANGE = ... # type: str
|
||||
REPEAT = ... # type: str
|
||||
REPEAT_ONE = ... # type: str
|
||||
SUBPATTERN = ... # type: str
|
||||
MIN_REPEAT_ONE = ... # type: str
|
||||
AT_BEGINNING = ... # type: str
|
||||
AT_BEGINNING_LINE = ... # type: str
|
||||
AT_BEGINNING_STRING = ... # type: str
|
||||
AT_BOUNDARY = ... # type: str
|
||||
AT_NON_BOUNDARY = ... # type: str
|
||||
AT_END = ... # type: str
|
||||
AT_END_LINE = ... # type: str
|
||||
AT_END_STRING = ... # type: str
|
||||
AT_LOC_BOUNDARY = ... # type: str
|
||||
AT_LOC_NON_BOUNDARY = ... # type: str
|
||||
AT_UNI_BOUNDARY = ... # type: str
|
||||
AT_UNI_NON_BOUNDARY = ... # type: str
|
||||
CATEGORY_DIGIT = ... # type: str
|
||||
CATEGORY_NOT_DIGIT = ... # type: str
|
||||
CATEGORY_SPACE = ... # type: str
|
||||
CATEGORY_NOT_SPACE = ... # type: str
|
||||
CATEGORY_WORD = ... # type: str
|
||||
CATEGORY_NOT_WORD = ... # type: str
|
||||
CATEGORY_LINEBREAK = ... # type: str
|
||||
CATEGORY_NOT_LINEBREAK = ... # type: str
|
||||
CATEGORY_LOC_WORD = ... # type: str
|
||||
CATEGORY_LOC_NOT_WORD = ... # type: str
|
||||
CATEGORY_UNI_DIGIT = ... # type: str
|
||||
CATEGORY_UNI_NOT_DIGIT = ... # type: str
|
||||
CATEGORY_UNI_SPACE = ... # type: str
|
||||
CATEGORY_UNI_NOT_SPACE = ... # type: str
|
||||
CATEGORY_UNI_WORD = ... # type: str
|
||||
CATEGORY_UNI_NOT_WORD = ... # type: str
|
||||
CATEGORY_UNI_LINEBREAK = ... # type: str
|
||||
CATEGORY_UNI_NOT_LINEBREAK = ... # type: str
|
||||
|
||||
_T = TypeVar('_T')
|
||||
def makedict(list: List[_T]) -> Dict[_T, int]: ...
|
||||
|
||||
OP_IGNORE = ... # type: Dict[str, str]
|
||||
AT_MULTILINE = ... # type: Dict[str, str]
|
||||
AT_LOCALE = ... # type: Dict[str, str]
|
||||
AT_UNICODE = ... # type: Dict[str, str]
|
||||
CH_LOCALE = ... # type: Dict[str, str]
|
||||
CH_UNICODE = ... # type: Dict[str, str]
|
||||
SRE_FLAG_TEMPLATE = ... # type: int
|
||||
SRE_FLAG_IGNORECASE = ... # type: int
|
||||
SRE_FLAG_LOCALE = ... # type: int
|
||||
SRE_FLAG_MULTILINE = ... # type: int
|
||||
SRE_FLAG_DOTALL = ... # type: int
|
||||
SRE_FLAG_UNICODE = ... # type: int
|
||||
SRE_FLAG_VERBOSE = ... # type: int
|
||||
SRE_FLAG_DEBUG = ... # type: int
|
||||
SRE_INFO_PREFIX = ... # type: int
|
||||
SRE_INFO_LITERAL = ... # type: int
|
||||
SRE_INFO_CHARSET = ... # type: int
|
||||
63
stdlib/2/sre_parse.pyi
Normal file
63
stdlib/2/sre_parse.pyi
Normal file
@@ -0,0 +1,63 @@
|
||||
# Source: https://hg.python.org/cpython/file/2.7/Lib/sre_parse.py
|
||||
|
||||
from typing import Any, Dict, Iterable, List, Match, Optional, Pattern as _Pattern, Set, Tuple, Union
|
||||
|
||||
SPECIAL_CHARS = ... # type: str
|
||||
REPEAT_CHARS = ... # type: str
|
||||
DIGITS = ... # type: Set
|
||||
OCTDIGITS = ... # type: Set
|
||||
HEXDIGITS = ... # type: Set
|
||||
WHITESPACE = ... # type: Set
|
||||
ESCAPES = ... # type: Dict[str, Tuple[str, int]]
|
||||
CATEGORIES = ... # type: Dict[str, Union[Tuple[str, str], Tuple[str, List[Tuple[str, str]]]]]
|
||||
FLAGS = ... # type: Dict[str, int]
|
||||
|
||||
class Pattern:
|
||||
flags = ... # type: int
|
||||
open = ... # type: List[int]
|
||||
groups = ... # type: int
|
||||
groupdict = ... # type: Dict[str, int]
|
||||
lookbehind = ... # type: int
|
||||
def __init__(self) -> None: ...
|
||||
def opengroup(self, name: str = ...) -> int: ...
|
||||
def closegroup(self, gid: int) -> None: ...
|
||||
def checkgroup(self, gid: int) -> bool: ...
|
||||
|
||||
|
||||
_OpSubpatternType = Tuple[Optional[int], int, int, SubPattern]
|
||||
_OpGroupRefExistsType = Tuple[int, SubPattern, SubPattern]
|
||||
_OpInType = List[Tuple[str, int]]
|
||||
_OpBranchType = Tuple[None, List[SubPattern]]
|
||||
_AvType = Union[_OpInType, _OpBranchType, Iterable[SubPattern], _OpGroupRefExistsType, _OpSubpatternType]
|
||||
_CodeType = Union[str, _AvType]
|
||||
|
||||
class SubPattern:
|
||||
pattern = ... # type: str
|
||||
data = ... # type: List[_CodeType]
|
||||
width = ... # type: Optional[int]
|
||||
def __init__(self, pattern, data: List[_CodeType] = ...) -> None: ...
|
||||
def dump(self, level: int = ...) -> None: ...
|
||||
def __len__(self) -> int: ...
|
||||
def __delitem__(self, index: Union[int, slice]) -> None: ...
|
||||
def __getitem__(self, index: Union[int, slice]) -> Union[SubPattern, _CodeType]: ...
|
||||
def __setitem__(self, index: Union[int, slice], code: _CodeType): ...
|
||||
def insert(self, index, code: _CodeType) -> None: ...
|
||||
def append(self, code: _CodeType) -> None: ...
|
||||
def getwidth(self) -> int: ...
|
||||
|
||||
class Tokenizer:
|
||||
string = ... # type: str
|
||||
index = ... # type: int
|
||||
def __init__(self, string: str) -> None: ...
|
||||
def match(self, char: str, skip: int = ...) -> int: ...
|
||||
def get(self) -> Optional[str]: ...
|
||||
def tell(self) -> Tuple[int, Optional[str]]: ...
|
||||
def seek(self, index: int) -> None: ...
|
||||
|
||||
def isident(char: str) -> bool: ...
|
||||
def isdigit(char: str) -> bool: ...
|
||||
def isname(name: str) -> bool: ...
|
||||
def parse(str: str, flags: int = ..., pattern: Pattern = ...) -> SubPattern: ...
|
||||
_Template = Tuple[List[Tuple[int, int]], List[Optional[int]]]
|
||||
def parse_template(source: str, pattern: _Pattern) -> _Template: ...
|
||||
def expand_template(template: _Template, match: Match) -> str: ...
|
||||
Reference in New Issue
Block a user