2 from typing import IO, Any, Callable, Generic, List, Text, Type, TypeVar, overload
3 from typing_extensions import SupportsIndex
5 _TB = TypeVar("_TB", bound="_BaseEntry")
6 _TP = TypeVar("_TP", bound="POFile")
7 _TM = TypeVar("_TM", bound="MOFile")
13 # check_for_duplicates: bool
15 def pofile(pofile: Text, *, klass: Type[_TP], **kwargs: Any) -> _TP: ...
17 def pofile(pofile: Text, **kwargs: Any) -> POFile: ...
19 def mofile(mofile: Text, *, klass: Type[_TM], **kwargs: Any) -> _TM: ...
21 def mofile(mofile: Text, **kwargs: Any) -> MOFile: ...
22 def detect_encoding(file: bytes | Text, binary_mode: bool = ...) -> str: ...
23 def escape(st: Text) -> Text: ...
24 def unescape(st: Text) -> Text: ...
26 class _BaseFile(List[_TB]):
30 check_for_duplicates: bool
32 metadata: dict[Text, Text]
33 metadata_is_fuzzy: bool
34 def __init__(self, *args: Any, **kwargs: Any) -> None: ...
35 def __unicode__(self) -> Text: ...
36 def __contains__(self, entry: _TB) -> bool: ... # type: ignore # AttributeError otherwise
37 def __eq__(self, other: object) -> bool: ...
38 def append(self, entry: _TB) -> None: ...
39 def insert(self, index: SupportsIndex, entry: _TB) -> None: ...
40 def metadata_as_entry(self) -> POEntry: ...
41 def save(self, fpath: Text | None = ..., repr_method: str = ...) -> None: ...
42 def find(self, st: Text, by: str = ..., include_obsolete_entries: bool = ..., msgctxt: bool = ...) -> _TB | None: ...
43 def ordered_metadata(self) -> list[tuple[Text, Text]]: ...
44 def to_binary(self) -> bytes: ...
46 class POFile(_BaseFile[POEntry]):
47 def __unicode__(self) -> Text: ...
48 def save_as_mofile(self, fpath: Text) -> None: ...
49 def percent_translated(self) -> int: ...
50 def translated_entries(self) -> list[POEntry]: ...
51 def untranslated_entries(self) -> list[POEntry]: ...
52 def fuzzy_entries(self) -> list[POEntry]: ...
53 def obsolete_entries(self) -> list[POEntry]: ...
54 def merge(self, refpot: POFile) -> None: ...
56 class MOFile(_BaseFile[MOEntry]):
59 magic_number: int | None
61 def __init__(self, *args: Any, **kwargs: Any) -> None: ...
62 def save_as_pofile(self, fpath: str) -> None: ...
63 def save(self, fpath: Text | None = ...) -> None: ... # type: ignore # binary file does not allow argument repr_method
64 def percent_translated(self) -> int: ...
65 def translated_entries(self) -> list[MOEntry]: ...
66 def untranslated_entries(self) -> list[MOEntry]: ...
67 def fuzzy_entries(self) -> list[MOEntry]: ...
68 def obsolete_entries(self) -> list[MOEntry]: ...
70 class _BaseEntry(object):
74 msgstr_plural: list[Text]
78 def __init__(self, *args: Any, **kwargs: Any) -> None: ...
79 def __unicode__(self, wrapwidth: int = ...) -> Text: ...
80 def __eq__(self, other: object) -> bool: ...
82 class POEntry(_BaseEntry):
85 occurrences: list[tuple[str, int]]
87 previous_msgctxt: Text | None
88 previous_msgid: Text | None
89 previous_msgid_plural: Text | None
91 def __init__(self, *args: Any, **kwargs: Any) -> None: ...
92 def __unicode__(self, wrapwidth: int = ...) -> Text: ...
93 def __cmp__(self, other: POEntry) -> int: ...
94 def __gt__(self, other: POEntry) -> bool: ...
95 def __lt__(self, other: POEntry) -> bool: ...
96 def __ge__(self, other: POEntry) -> bool: ...
97 def __le__(self, other: POEntry) -> bool: ...
98 def __eq__(self, other: Any) -> bool: ...
99 def __ne__(self, other: Any) -> bool: ...
100 def translated(self) -> bool: ...
101 def merge(self, other: POEntry) -> None: ...
103 def fuzzy(self) -> bool: ...
105 def msgid_with_context(self) -> Text: ...
106 def __hash__(self) -> int: ...
108 class MOEntry(_BaseEntry):
111 occurrences: list[tuple[str, int]]
113 previous_msgctxt: Text | None
114 previous_msgid: Text | None
115 previous_msgid_plural: Text | None
116 def __init__(self, *args: Any, **kwargs: Any) -> None: ...
117 def __hash__(self) -> int: ...
119 class _POFileParser(Generic[_TP]):
122 transitions: dict[tuple[str, str], tuple[Callable[[], bool], str]]
124 current_entry: POEntry
126 current_token: str | None
129 def __init__(self, pofile: Text, *args: Any, **kwargs: Any) -> None: ...
130 def parse(self) -> _TP: ...
131 def add(self, symbol: str, states: list[str], next_state: str) -> None: ...
132 def process(self, symbol: str) -> None: ...
133 def handle_he(self) -> bool: ...
134 def handle_tc(self) -> bool: ...
135 def handle_gc(self) -> bool: ...
136 def handle_oc(self) -> bool: ...
137 def handle_fl(self) -> bool: ...
138 def handle_pp(self) -> bool: ...
139 def handle_pm(self) -> bool: ...
140 def handle_pc(self) -> bool: ...
141 def handle_ct(self) -> bool: ...
142 def handle_mi(self) -> bool: ...
143 def handle_mp(self) -> bool: ...
144 def handle_ms(self) -> bool: ...
145 def handle_mx(self) -> bool: ...
146 def handle_mc(self) -> bool: ...
148 class _MOFileParser(Generic[_TM]):
151 def __init__(self, mofile: Text, *args: Any, **kwargs: Any) -> None: ...
152 def __del__(self) -> None: ...
153 def parse(self) -> _TM: ...
155 class TextWrapper(textwrap.TextWrapper):
156 drop_whitespace: bool
157 def __init__(self, *args: Any, **kwargs: Any) -> None: ...