| 1 | from collections.abc import Callable, Iterator |
| 2 | |
| 3 | ok: int |
| 4 | icu_version: str |
| 5 | unicode_version: str |
| 6 | |
| 7 | USET_SPAN_NOT_CONTAINED: int |
| 8 | USET_SPAN_CONTAINED: int |
| 9 | USET_SPAN_SIMPLE: int |
| 10 | UCOL_DEFAULT: int |
| 11 | UCOL_PRIMARY: int |
| 12 | UCOL_SECONDARY: int |
| 13 | UCOL_TERTIARY: int |
| 14 | UCOL_DEFAULT_STRENGTH: int |
| 15 | UCOL_QUATERNARY: int |
| 16 | UCOL_IDENTICAL: int |
| 17 | UCOL_OFF: int |
| 18 | UCOL_ON: int |
| 19 | UCOL_SHIFTED: int |
| 20 | UCOL_NON_IGNORABLE: int |
| 21 | UCOL_LOWER_FIRST: int |
| 22 | UCOL_UPPER_FIRST: int |
| 23 | UCOL_FRENCH_COLLATION: int |
| 24 | UCOL_ALTERNATE_HANDLING: int |
| 25 | UCOL_CASE_FIRST: int |
| 26 | UCOL_CASE_LEVEL: int |
| 27 | UCOL_NORMALIZATION_MODE: int |
| 28 | UCOL_DECOMPOSITION_MODE: int |
| 29 | UCOL_STRENGTH: int |
| 30 | UCOL_NUMERIC_COLLATION: int |
| 31 | UCOL_REORDER_CODE_SPACE: int |
| 32 | UCOL_REORDER_CODE_PUNCTUATION: int |
| 33 | UCOL_REORDER_CODE_SYMBOL: int |
| 34 | UCOL_REORDER_CODE_CURRENCY: int |
| 35 | UCOL_REORDER_CODE_DEFAULT: int |
| 36 | |
| 37 | NFD: int |
| 38 | NFKD: int |
| 39 | NFC: int |
| 40 | NFKC: int |
| 41 | |
| 42 | UPPER_CASE: int |
| 43 | LOWER_CASE: int |
| 44 | TITLE_CASE: int |
| 45 | |
| 46 | UBRK_CHARACTER: int |
| 47 | UBRK_WORD: int |
| 48 | UBRK_LINE: int |
| 49 | UBRK_SENTENCE: int |
| 50 | |
| 51 | class Collator: |
| 52 | "Collator" |
| 53 | |
| 54 | def __init__(self, locale: str) -> None: |
| 55 | "Create a Collator for the specified locale." |
| 56 | pass |
| 57 | |
| 58 | def sort_key(self, unicode_object: str) -> bytes: |
| 59 | """sort_key(unicode object) -> Return a sort key for the given object as a bytestring. |
| 60 | |
| 61 | The idea is that these bytestring will sort using the builtin cmp function, just |
| 62 | like the original unicode strings would sort in the current locale with ICU. |
| 63 | """ |
| 64 | pass |
| 65 | |
| 66 | def get_attribute(self, key: int) -> int: |
| 67 | "get_attribute(key) -> get the specified attribute on this collator." |
| 68 | pass |
| 69 | |
| 70 | def set_attribute(self, key: int, val: int) -> None: |
| 71 | "set_attribute(key, val) -> set the specified attribute on this collator." |
| 72 | pass |
| 73 | |
| 74 | def strcmp(self, a: str, b: str) -> int: |
| 75 | "strcmp(unicode object, unicode object) -> strcmp(a, b) <=> cmp(sorty_key(a), sort_key(b)), but faster." |
| 76 | pass |
| 77 | |
| 78 | def find_all(self, pattern: str, source: str, callback: Callable[[int, int], object], whole_words: bool = False) -> None: |
| 79 | """find(pattern, source, callback) -> reports the position and length of all |
| 80 | occurrences of pattern in source to callback. Aborts if callback returns anything |
| 81 | other than None. |
| 82 | """ |
| 83 | pass |
| 84 | |
| 85 | def find(self, pattern: str, source: str, whole_words: bool = False) -> tuple[int, int]: |
| 86 | "find(pattern, source) -> returns the position and length of the first occurrence of pattern in source. Returns (-1, -1) if not found." |
| 87 | pass |
| 88 | |
| 89 | def contains(self, pattern: str, source: str) -> bool: |
| 90 | "contains(pattern, source) -> return True iff the pattern was found in the source." |
| 91 | pass |
| 92 | |
| 93 | def contractions(self) -> tuple[str | None, ...]: |
| 94 | "contractions() -> returns the contractions defined for this collator." |
| 95 | pass |
| 96 | |
| 97 | def clone(self) -> Collator: |
| 98 | "clone() -> returns a clone of this collator." |
| 99 | pass |
| 100 | |
| 101 | def startswith(self, a: str, b: str, offset: int = 0) -> bool: |
| 102 | "startswith(a, b, offset=0) -> returns True iff a startswith b at the given codepoint offset, following the current collation rules." |
| 103 | pass |
| 104 | |
| 105 | def collation_order(self, string: str) -> tuple[int, int]: |
| 106 | """collation_order(string) -> returns (order, length) where order is an integer |
| 107 | that gives the position of string in a list. length gives the number of characters |
| 108 | used for order. |
| 109 | """ |
| 110 | pass |
| 111 | |
| 112 | @property |
| 113 | def actual_locale(self) -> str: |
| 114 | "Actual locale used by this collator." |
| 115 | pass |
| 116 | |
| 117 | @property |
| 118 | def capsule(self) -> object: |
| 119 | "A capsule enclosing the pointer to the ICU collator struct" |
| 120 | pass |
| 121 | |
| 122 | @property |
| 123 | def display_name(self) -> str: |
| 124 | "Display name of this collator in English. The name reflects the actual data source used." |
| 125 | pass |
| 126 | |
| 127 | @property |
| 128 | def strength(self) -> int: |
| 129 | "The strength of this collator." |
| 130 | pass |
| 131 | |
| 132 | @strength.setter |
| 133 | def strength(self, val: int) -> None: |
| 134 | pass |
| 135 | |
| 136 | @property |
| 137 | def upper_first(self) -> bool | None: |
| 138 | """Whether this collator should always put upper case letters before lower case. |
| 139 | |
| 140 | Values are: None - means use the tertiary strength of the letters. |
| 141 | True - Always sort upper case before lower case. |
| 142 | False - Always sort lower case before upper case. |
| 143 | """ |
| 144 | pass |
| 145 | |
| 146 | @upper_first.setter |
| 147 | def upper_first(self, val: bool | None) -> None: |
| 148 | pass |
| 149 | |
| 150 | @property |
| 151 | def numeric(self) -> bool: |
| 152 | "If True the collator sorts contiguous digits as numbers rather than strings, so 2 will sort before 10." |
| 153 | pass |
| 154 | |
| 155 | @numeric.setter |
| 156 | def numeric(self, val: bool) -> None: |
| 157 | pass |
| 158 | |
| 159 | @property |
| 160 | def max_variable(self) -> int: |
| 161 | "The highest sorting character affected by alternate handling" |
| 162 | pass |
| 163 | |
| 164 | @max_variable.setter |
| 165 | def max_variable(self, val: int) -> None: |
| 166 | pass |
| 167 | |
| 168 | class Transliterator: |
| 169 | "Transliterator" |
| 170 | |
| 171 | def __init__(self, id: str, rules: str, forward: bool = True) -> None: |
| 172 | "Create a Transliterator with the specified id compiled from the specified rules." |
| 173 | pass |
| 174 | |
| 175 | def transliterate(self, text: str) -> str: |
| 176 | "transliterate(text) -> Run the transliterator on the specified text" |
| 177 | pass |
| 178 | |
| 179 | class BreakIterator: |
| 180 | """BreakIterator(type, locale[, extra_word_break_chars]) -> Create a break iterator. |
| 181 | |
| 182 | For UBRK_WORD iterators, extra_word_break_chars is an optional string of characters |
| 183 | that act as additional word-break points beyond the ICU defaults. |
| 184 | """ |
| 185 | |
| 186 | def __init__(self, type: int, locale: str, extra_word_break_chars: str | None = None) -> None: |
| 187 | "Create a break iterator of the specified type (one of UBRK_CHARACTER, UBRK_WORD, UBRK_LINE, UBRK_SENTENCE) for the specified locale." |
| 188 | pass |
| 189 | |
| 190 | def set_text(self, unicode_object: str) -> None: |
| 191 | "set_text(unicode object) -> Set the text this iterator will operate on" |
| 192 | pass |
| 193 | |
| 194 | def split2(self) -> list[tuple[int, int]]: |
| 195 | """split2() -> Split the current text into tokens, returning a list of 2-tuples |
| 196 | of the form (position of token, length of token). The numbers are suitable for |
| 197 | indexing python strings regardless of narrow/wide builds. |
| 198 | """ |
| 199 | pass |
| 200 | |
| 201 | def iter_breaks(self) -> Iterator[tuple[int, int]]: |
| 202 | """iter_breaks() -> Split the current text into tokens, returning an iterator |
| 203 | that yields 2-tuples of the form (position of token, length of token). The numbers |
| 204 | are suitable for indexing python strings regardless of narrow/wide builds. |
| 205 | """ |
| 206 | pass |
| 207 | |
| 208 | def iter_positions(self) -> Iterator[int]: |
| 209 | """iter_positions() -> Split the current text into tokens, returning an iterator |
| 210 | that yields the position of each token as an integer. The numbers are suitable for |
| 211 | indexing python strings regardless of narrow/wide builds. |
| 212 | """ |
| 213 | pass |
| 214 | |
| 215 | def count_words(self) -> int: |
| 216 | "count_words() -> Split the current text into tokens as in split2() and count the number of tokens." |
| 217 | pass |
| 218 | |
| 219 | def index(self, token: str) -> int: |
| 220 | """index(token) -> Find the index of the first match for token. |
| 221 | |
| 222 | Useful to find, for example, words that could also be a part of a larger word. |
| 223 | For example, index('i') in 'string i' will be 7 not 3. Returns -1 if not found. |
| 224 | """ |
| 225 | pass |
| 226 | |
| 227 | def change_case(unicode_object: str, which: int, locale: str | bytes | None) -> str: |
| 228 | "change_case(unicode object, which, locale) -> change case to one of UPPER_CASE, LOWER_CASE, TITLE_CASE" |
| 229 | pass |
| 230 | |
| 231 | def swap_case(unicode_object: str) -> str: |
| 232 | "swap_case(unicode object) -> swaps the case using the simple, locale independent unicode algorithm" |
| 233 | pass |
| 234 | |
| 235 | def set_default_encoding(encoding: object = None) -> None: |
| 236 | "set_default_encoding(encoding) -> Set the default encoding for the python unicode implementation. In Py3, this operation is a no-op" |
| 237 | pass |
| 238 | |
| 239 | def set_filesystem_encoding(encoding: str | bytes) -> None: |
| 240 | "set_filesystem_encoding(encoding) -> Set the filesystem encoding for python." |
| 241 | pass |
| 242 | |
| 243 | def get_available_transliterators() -> list[str]: |
| 244 | "get_available_transliterators() -> Return list of available transliterators. This list is rather limited on OS X." |
| 245 | pass |
| 246 | |
| 247 | def character_name(char: str, alias: bool = False) -> str: |
| 248 | "character_name(char, alias=False) -> Return name for the first character in char, which must be a unicode string." |
| 249 | pass |
| 250 | |
| 251 | def character_name_from_code(code: int, alias: bool = False) -> str: |
| 252 | "character_name_from_code(code, alias=False) -> Return the name for the specified unicode code point" |
| 253 | pass |
| 254 | |
| 255 | def chr(code: int) -> str: |
| 256 | """chr(code) -> Return a python unicode string corresponding to the specified character |
| 257 | code. The string can have length 1 or 2 (for non BMP codes on narrow python builds). |
| 258 | """ |
| 259 | pass |
| 260 | |
| 261 | def ord_string(code: str) -> tuple[int, ...]: |
| 262 | "ord_string(code) -> Convert a python unicode string to a tuple of unicode codepoints." |
| 263 | pass |
| 264 | |
| 265 | def normalize(mode: int, unicode_text: str) -> str: |
| 266 | "normalize(mode, unicode_text) -> Return a python unicode string which is normalized in the specified mode." |
| 267 | pass |
| 268 | |
| 269 | def roundtrip(string: str) -> str: |
| 270 | "roundtrip(string) -> Roundtrip a unicode object from python to ICU back to python (useful for testing)" |
| 271 | pass |
| 272 | |
| 273 | def available_locales_for_break_iterator() -> tuple[bytes, ...]: |
| 274 | "available_locales_for_break_iterator() -> Return tuple of all available locales for the BreakIterator" |
| 275 | pass |
| 276 | |
| 277 | def string_length(string: str) -> int: |
| 278 | """string_length(string) -> Return the length of a string (number of unicode code |
| 279 | points in the string). Useful on narrow python builds where len() returns an incorrect |
| 280 | answer if the string contains surrogate pairs. |
| 281 | """ |
| 282 | pass |
| 283 | |
| 284 | def utf16_length(string: str) -> int: |
| 285 | """utf16_length(string) -> Return the length of a string (number of UTF-16 code |
| 286 | points in the string). Useful on wide python builds where len() returns an incorrect |
| 287 | answer if the string contains surrogate pairs. |
| 288 | """ |
| 289 | pass |
| 290 | |
| 291 | def word_prefix_find(collator: Collator, break_iterator: BreakIterator, string: str, prefix: str) -> int: |
| 292 | """word_prefix_find(collator, break_iterator, string, prefix) -> Return the codepoint |
| 293 | offset of the first word in string that starts with prefix according to collator, |
| 294 | or -1 if none. |
| 295 | """ |
| 296 | pass |