|
| 1 | +import re |
| 2 | +from _typeshed import Incomplete, SupportsRead |
| 3 | +from collections.abc import Callable, Mapping |
| 4 | +from datetime import _TzInfo, datetime |
| 5 | +from io import StringIO |
| 6 | +from typing import IO, Any |
| 7 | +from typing_extensions import Self, TypeAlias |
| 8 | + |
| 9 | +_FileOrStr: TypeAlias = bytes | str | IO[str] | IO[Any] |
| 10 | +_TzData: TypeAlias = _TzInfo | int | str | None |
| 11 | +_TzInfos: TypeAlias = Mapping[str, _TzData] | Callable[[str, int], _TzData] |
| 12 | + |
| 13 | +__all__ = ["parse", "parserinfo", "ParserError"] |
| 14 | + |
| 15 | +class _timelex: |
| 16 | + _split_decimal: re.Pattern[str] |
| 17 | + instream: StringIO | SupportsRead[str] |
| 18 | + charstack: list[str] |
| 19 | + tokenstack: list[str] |
| 20 | + eof: bool |
| 21 | + def __init__(self, instream: str | bytes | bytearray | SupportsRead[str]) -> None: ... |
| 22 | + def get_token(self) -> str | None: ... |
| 23 | + def __iter__(self) -> Self: ... |
| 24 | + def __next__(self) -> str: ... |
| 25 | + def next(self) -> str: ... |
| 26 | + @classmethod |
| 27 | + def split(cls, s: str) -> list[str]: ... |
| 28 | + @classmethod |
| 29 | + def isword(cls, nextchar: str) -> bool: ... |
| 30 | + @classmethod |
| 31 | + def isnum(cls, nextchar: str) -> bool: ... |
| 32 | + @classmethod |
| 33 | + def isspace(cls, nextchar: str) -> bool: ... |
| 34 | + |
| 35 | +class _resultbase: |
| 36 | + def __init__(self) -> None: ... |
| 37 | + def _repr(self, classname: str) -> str: ... |
| 38 | + def __len__(self) -> int: ... |
| 39 | + |
| 40 | +class parserinfo: |
| 41 | + JUMP: list[str] |
| 42 | + WEEKDAYS: list[tuple[str, str]] |
| 43 | + MONTHS: list[tuple[str, str] | tuple[str, str, str]] |
| 44 | + HMS: list[tuple[str, str, str]] |
| 45 | + AMPM: list[tuple[str, str]] |
| 46 | + UTCZONE: list[str] |
| 47 | + PERTAIN: list[str] |
| 48 | + TZOFFSET: dict[str, int] |
| 49 | + def __init__(self, dayfirst: bool = False, yearfirst: bool = False) -> None: ... |
| 50 | + def jump(self, name: str) -> bool: ... |
| 51 | + def weekday(self, name: str) -> int | None: ... |
| 52 | + def month(self, name: str) -> int | None: ... |
| 53 | + def hms(self, name: str) -> int | None: ... |
| 54 | + def ampm(self, name: str) -> int | None: ... |
| 55 | + def pertain(self, name: str) -> bool: ... |
| 56 | + def utczone(self, name: str) -> bool: ... |
| 57 | + def tzoffset(self, name: str) -> int | None: ... |
| 58 | + def convertyear(self, year: int, century_specified: bool = False) -> int: ... |
| 59 | + def validate(self, res: datetime) -> bool: ... |
| 60 | + |
| 61 | +class _ymd(list[Incomplete]): |
| 62 | + century_specified: bool |
| 63 | + dstridx: int | None |
| 64 | + mstridx: int | None |
| 65 | + ystridx: int | None |
| 66 | + def __init__(self, *args, **kwargs) -> None: ... |
| 67 | + @property |
| 68 | + def has_year(self) -> bool: ... |
| 69 | + @property |
| 70 | + def has_month(self) -> bool: ... |
| 71 | + @property |
| 72 | + def has_day(self) -> bool: ... |
| 73 | + def could_be_day(self, value): ... |
| 74 | + def append(self, val, label=None): ... |
| 75 | + def _resolve_from_stridxs(self, strids): ... |
| 76 | + def resolve_ymd(self, yearfirst: bool | None, dayfirst: bool | None): ... |
| 77 | + |
| 78 | +class parser: |
| 79 | + info: parserinfo |
| 80 | + def __init__(self, info: parserinfo | None = None) -> None: ... |
| 81 | + def parse( |
| 82 | + self, |
| 83 | + timestr: _FileOrStr, |
| 84 | + default: datetime | None = None, |
| 85 | + ignoretz: bool = False, |
| 86 | + tzinfos: _TzInfos | None = None, |
| 87 | + *, |
| 88 | + dayfirst: bool | None = ..., |
| 89 | + yearfirst: bool | None = ..., |
| 90 | + fuzzy: bool = ..., |
| 91 | + fuzzy_with_tokens: bool = ..., |
| 92 | + ) -> datetime: ... |
| 93 | + |
| 94 | +DEFAULTPARSER: parser |
| 95 | + |
| 96 | +def parse( |
| 97 | + timestr: _FileOrStr, |
| 98 | + parserinfo: parserinfo | None = None, |
| 99 | + *, |
| 100 | + dayfirst: bool | None = ..., |
| 101 | + yearfirst: bool | None = ..., |
| 102 | + ignoretz: bool = ..., |
| 103 | + fuzzy: bool = ..., |
| 104 | + fuzzy_with_tokens: bool = ..., |
| 105 | + default: datetime | None = ..., |
| 106 | + tzinfos: _TzInfos | None = ..., |
| 107 | +) -> datetime: ... |
| 108 | + |
| 109 | +class _tzparser: |
| 110 | + class _result(_resultbase): |
| 111 | + stdabbr: str | None |
| 112 | + stdoffset: int | None |
| 113 | + dstabbr: str | None |
| 114 | + dstoffset: int | None |
| 115 | + start: _attr |
| 116 | + end: _attr |
| 117 | + |
| 118 | + class _attr(_resultbase): |
| 119 | + month: int | None |
| 120 | + week: int | None |
| 121 | + weekday: int | None |
| 122 | + yday: int | None |
| 123 | + jyday: int | None |
| 124 | + day: int | None |
| 125 | + time: int | None |
| 126 | + |
| 127 | + def __init__(self): ... |
| 128 | + |
| 129 | + def parse(self, tzstr: str | re.Pattern[str]) -> _result | None: ... |
| 130 | + |
| 131 | +DEFAULTTZPARSER: _tzparser |
| 132 | + |
| 133 | +class ParserError(ValueError): ... |
| 134 | +class UnknownTimezoneWarning(RuntimeWarning): ... |
0 commit comments