basedpyright 1.12.6 → 1.13.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/pyright-langserver.js +1 -1
- package/dist/pyright-langserver.js.map +1 -1
- package/dist/pyright.js +1 -1
- package/dist/pyright.js.map +1 -1
- package/dist/typeshed-fallback/stdlib/_ast.pyi +279 -42
- package/dist/typeshed-fallback/stdlib/_bisect.pyi +149 -12
- package/dist/typeshed-fallback/stdlib/_codecs.pyi +125 -14
- package/dist/typeshed-fallback/stdlib/_csv.pyi +130 -7
- package/dist/typeshed-fallback/stdlib/_ctypes.pyi +72 -17
- package/dist/typeshed-fallback/stdlib/_curses.pyi +626 -78
- package/dist/typeshed-fallback/stdlib/_decimal.pyi +775 -153
- package/dist/typeshed-fallback/stdlib/_heapq.pyi +61 -5
- package/dist/typeshed-fallback/stdlib/_imp.pyi +70 -15
- package/dist/typeshed-fallback/stdlib/_json.pyi +55 -12
- package/dist/typeshed-fallback/stdlib/_locale.pyi +63 -12
- package/dist/typeshed-fallback/stdlib/_lsprof.pyi +61 -4
- package/dist/typeshed-fallback/stdlib/_operator.pyi +238 -62
- package/dist/typeshed-fallback/stdlib/_posixsubprocess.pyi +25 -1
- package/dist/typeshed-fallback/stdlib/_random.pyi +23 -5
- package/dist/typeshed-fallback/stdlib/_socket.pyi +618 -63
- package/dist/typeshed-fallback/stdlib/_stat.pyi +140 -13
- package/dist/typeshed-fallback/stdlib/_thread.pyi +215 -22
- package/dist/typeshed-fallback/stdlib/_tkinter.pyi +44 -11
- package/dist/typeshed-fallback/stdlib/_tracemalloc.pyi +71 -10
- package/dist/typeshed-fallback/stdlib/_warnings.pyi +53 -6
- package/dist/typeshed-fallback/stdlib/_weakref.pyi +43 -10
- package/dist/typeshed-fallback/stdlib/_winapi.pyi +255 -255
- package/dist/typeshed-fallback/stdlib/array.pyi +233 -44
- package/dist/typeshed-fallback/stdlib/atexit.pyi +50 -5
- package/dist/typeshed-fallback/stdlib/audioop.pyi +78 -26
- package/dist/typeshed-fallback/stdlib/binascii.pyi +105 -18
- package/dist/typeshed-fallback/stdlib/builtins.pyi +5254 -829
- package/dist/typeshed-fallback/stdlib/cmath.pyi +99 -23
- package/dist/typeshed-fallback/stdlib/errno.pyi +15 -0
- package/dist/typeshed-fallback/stdlib/faulthandler.pyi +33 -8
- package/dist/typeshed-fallback/stdlib/fcntl.pyi +199 -8
- package/dist/typeshed-fallback/stdlib/gc.pyi +130 -18
- package/dist/typeshed-fallback/stdlib/grp.pyi +58 -7
- package/dist/typeshed-fallback/stdlib/itertools.pyi +281 -42
- package/dist/typeshed-fallback/stdlib/marshal.pyi +82 -4
- package/dist/typeshed-fallback/stdlib/math.pyi +357 -61
- package/dist/typeshed-fallback/stdlib/mmap.pyi +47 -8
- package/dist/typeshed-fallback/stdlib/msvcrt.pyi +32 -32
- package/dist/typeshed-fallback/stdlib/nt.pyi +118 -111
- package/dist/typeshed-fallback/stdlib/parser.pyi +55 -24
- package/dist/typeshed-fallback/stdlib/posix.pyi +7 -0
- package/dist/typeshed-fallback/stdlib/pwd.pyi +60 -10
- package/dist/typeshed-fallback/stdlib/pyexpat/__init__.pyi +61 -12
- package/dist/typeshed-fallback/stdlib/readline.pyi +184 -27
- package/dist/typeshed-fallback/stdlib/resource.pyi +56 -16
- package/dist/typeshed-fallback/stdlib/select.pyi +97 -5
- package/dist/typeshed-fallback/stdlib/spwd.pyi +60 -11
- package/dist/typeshed-fallback/stdlib/sys/__init__.pyi +386 -48
- package/dist/typeshed-fallback/stdlib/syslog.pyi +27 -7
- package/dist/typeshed-fallback/stdlib/termios.pyi +88 -8
- package/dist/typeshed-fallback/stdlib/time.pyi +314 -37
- package/dist/typeshed-fallback/stdlib/unicodedata.pyi +264 -34
- package/dist/typeshed-fallback/stdlib/winreg.pyi +172 -132
- package/dist/typeshed-fallback/stdlib/zlib.pyi +108 -7
- package/package.json +1 -1
|
@@ -1,3 +1,10 @@
|
|
|
1
|
+
"""
|
|
2
|
+
This module defines an object type which can efficiently represent
|
|
3
|
+
an array of basic values: characters, integers, floating point
|
|
4
|
+
numbers. Arrays are sequence types and behave very much like lists,
|
|
5
|
+
except that the type of objects stored in them is constrained.
|
|
6
|
+
"""
|
|
7
|
+
|
|
1
8
|
import sys
|
|
2
9
|
from _typeshed import ReadableBuffer, SupportsRead, SupportsWrite
|
|
3
10
|
from collections.abc import Iterable
|
|
@@ -19,10 +26,72 @@ _T = TypeVar("_T", int, float, str)
|
|
|
19
26
|
typecodes: str
|
|
20
27
|
|
|
21
28
|
class array(MutableSequence[_T]):
|
|
29
|
+
"""
|
|
30
|
+
array(typecode [, initializer]) -> array
|
|
31
|
+
|
|
32
|
+
Return a new array whose items are restricted by typecode, and
|
|
33
|
+
initialized from the optional initializer value, which must be a list,
|
|
34
|
+
string or iterable over elements of the appropriate type.
|
|
35
|
+
|
|
36
|
+
Arrays represent basic values and behave very much like lists, except
|
|
37
|
+
the type of objects stored in them is constrained. The type is specified
|
|
38
|
+
at object creation time by using a type code, which is a single character.
|
|
39
|
+
The following type codes are defined:
|
|
40
|
+
|
|
41
|
+
Type code C Type Minimum size in bytes
|
|
42
|
+
'b' signed integer 1
|
|
43
|
+
'B' unsigned integer 1
|
|
44
|
+
'u' Unicode character 2 (see note)
|
|
45
|
+
'h' signed integer 2
|
|
46
|
+
'H' unsigned integer 2
|
|
47
|
+
'i' signed integer 2
|
|
48
|
+
'I' unsigned integer 2
|
|
49
|
+
'l' signed integer 4
|
|
50
|
+
'L' unsigned integer 4
|
|
51
|
+
'q' signed integer 8 (see note)
|
|
52
|
+
'Q' unsigned integer 8 (see note)
|
|
53
|
+
'f' floating point 4
|
|
54
|
+
'd' floating point 8
|
|
55
|
+
|
|
56
|
+
NOTE: The 'u' typecode corresponds to Python's unicode character. On
|
|
57
|
+
narrow builds this is 2-bytes on wide builds this is 4-bytes.
|
|
58
|
+
|
|
59
|
+
NOTE: The 'q' and 'Q' type codes are only available if the platform
|
|
60
|
+
C compiler used to build Python supports 'long long', or, on Windows,
|
|
61
|
+
'__int64'.
|
|
62
|
+
|
|
63
|
+
Methods:
|
|
64
|
+
|
|
65
|
+
append() -- append a new item to the end of the array
|
|
66
|
+
buffer_info() -- return information giving the current memory info
|
|
67
|
+
byteswap() -- byteswap all the items of the array
|
|
68
|
+
count() -- return number of occurrences of an object
|
|
69
|
+
extend() -- extend array by appending multiple elements from an iterable
|
|
70
|
+
fromfile() -- read items from a file object
|
|
71
|
+
fromlist() -- append items from the list
|
|
72
|
+
frombytes() -- append items from the string
|
|
73
|
+
index() -- return index of first occurrence of an object
|
|
74
|
+
insert() -- insert a new item into the array at a provided position
|
|
75
|
+
pop() -- remove and return item (default last)
|
|
76
|
+
remove() -- remove first occurrence of an object
|
|
77
|
+
reverse() -- reverse the order of the items in the array
|
|
78
|
+
tofile() -- write all items to a file object
|
|
79
|
+
tolist() -- return the array converted to an ordinary list
|
|
80
|
+
tobytes() -- return the array converted to a string
|
|
81
|
+
|
|
82
|
+
Attributes:
|
|
83
|
+
|
|
84
|
+
typecode -- the typecode character used to create the array
|
|
85
|
+
itemsize -- the length in bytes of one array item
|
|
86
|
+
"""
|
|
22
87
|
@property
|
|
23
|
-
def typecode(self) -> _TypeCode:
|
|
88
|
+
def typecode(self) -> _TypeCode:
|
|
89
|
+
"""the typecode character used to create the array"""
|
|
90
|
+
...
|
|
24
91
|
@property
|
|
25
|
-
def itemsize(self) -> int:
|
|
92
|
+
def itemsize(self) -> int:
|
|
93
|
+
"""the size, in bytes, of one array item"""
|
|
94
|
+
...
|
|
26
95
|
@overload
|
|
27
96
|
def __init__(self: array[int], typecode: _IntTypeCode, initializer: bytes | bytearray | Iterable[int] = ..., /) -> None: ...
|
|
28
97
|
@overload
|
|
@@ -37,56 +106,176 @@ class array(MutableSequence[_T]):
|
|
|
37
106
|
def __init__(self, typecode: str, initializer: Iterable[_T], /) -> None: ...
|
|
38
107
|
@overload
|
|
39
108
|
def __init__(self, typecode: str, initializer: bytes | bytearray = ..., /) -> None: ...
|
|
40
|
-
def append(self, v: _T, /) -> None:
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
def
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
109
|
+
def append(self, v: _T, /) -> None:
|
|
110
|
+
"""Append new value v to the end of the array."""
|
|
111
|
+
...
|
|
112
|
+
def buffer_info(self) -> tuple[int, int]:
|
|
113
|
+
"""
|
|
114
|
+
Return a tuple (address, length) giving the current memory address and the length in items of the buffer used to hold array's contents.
|
|
115
|
+
|
|
116
|
+
The length should be multiplied by the itemsize attribute to calculate
|
|
117
|
+
the buffer length in bytes.
|
|
118
|
+
"""
|
|
119
|
+
...
|
|
120
|
+
def byteswap(self) -> None:
|
|
121
|
+
"""
|
|
122
|
+
Byteswap all items of the array.
|
|
123
|
+
|
|
124
|
+
If the items in the array are not 1, 2, 4, or 8 bytes in size, RuntimeError is
|
|
125
|
+
raised.
|
|
126
|
+
"""
|
|
127
|
+
...
|
|
128
|
+
def count(self, v: _T, /) -> int:
|
|
129
|
+
"""Return number of occurrences of v in the array."""
|
|
130
|
+
...
|
|
131
|
+
def extend(self, bb: Iterable[_T], /) -> None:
|
|
132
|
+
"""Append items to the end of the array."""
|
|
133
|
+
...
|
|
134
|
+
def frombytes(self, buffer: ReadableBuffer, /) -> None:
|
|
135
|
+
"""Appends items from the string, interpreting it as an array of machine values, as if it had been read from a file using the fromfile() method)."""
|
|
136
|
+
...
|
|
137
|
+
def fromfile(self, f: SupportsRead[bytes], n: int, /) -> None:
|
|
138
|
+
"""Read n objects from the file object f and append them to the end of the array."""
|
|
139
|
+
...
|
|
140
|
+
def fromlist(self, list: list[_T], /) -> None:
|
|
141
|
+
"""Append items to array from list."""
|
|
142
|
+
...
|
|
143
|
+
def fromunicode(self, ustr: str, /) -> None:
|
|
144
|
+
"""
|
|
145
|
+
Extends this array with data from the unicode string ustr.
|
|
146
|
+
|
|
147
|
+
The array must be a unicode type array; otherwise a ValueError is raised.
|
|
148
|
+
Use array.frombytes(ustr.encode(...)) to append Unicode data to an array of
|
|
149
|
+
some other type.
|
|
150
|
+
"""
|
|
151
|
+
...
|
|
49
152
|
if sys.version_info >= (3, 10):
|
|
50
|
-
def index(self, v: _T, start: int = 0, stop: int = sys.maxsize, /) -> int:
|
|
153
|
+
def index(self, v: _T, start: int = 0, stop: int = sys.maxsize, /) -> int:
|
|
154
|
+
"""
|
|
155
|
+
Return index of first occurrence of v in the array.
|
|
156
|
+
|
|
157
|
+
Raise ValueError if the value is not present.
|
|
158
|
+
"""
|
|
159
|
+
...
|
|
51
160
|
else:
|
|
52
|
-
def index(self, v: _T, /) -> int:
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
def
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
def
|
|
60
|
-
|
|
161
|
+
def index(self, v: _T, /) -> int:
|
|
162
|
+
"""Return index of first occurrence of v in the array."""
|
|
163
|
+
...
|
|
164
|
+
|
|
165
|
+
def insert(self, i: int, v: _T, /) -> None:
|
|
166
|
+
"""Insert a new item v into the array before position i."""
|
|
167
|
+
...
|
|
168
|
+
def pop(self, i: int = -1, /) -> _T:
|
|
169
|
+
"""
|
|
170
|
+
Return the i-th element and delete it from the array.
|
|
171
|
+
|
|
172
|
+
i defaults to -1.
|
|
173
|
+
"""
|
|
174
|
+
...
|
|
175
|
+
def remove(self, v: _T, /) -> None:
|
|
176
|
+
"""Remove the first occurrence of v in the array."""
|
|
177
|
+
...
|
|
178
|
+
def tobytes(self) -> bytes:
|
|
179
|
+
"""Convert the array to an array of machine values and return the bytes representation."""
|
|
180
|
+
...
|
|
181
|
+
def tofile(self, f: SupportsWrite[bytes], /) -> None:
|
|
182
|
+
"""Write all items (as machine values) to the file object f."""
|
|
183
|
+
...
|
|
184
|
+
def tolist(self) -> list[_T]:
|
|
185
|
+
"""Convert array to an ordinary list with the same items."""
|
|
186
|
+
...
|
|
187
|
+
def tounicode(self) -> str:
|
|
188
|
+
"""
|
|
189
|
+
Extends this array with data from the unicode string ustr.
|
|
190
|
+
|
|
191
|
+
Convert the array to a unicode string. The array must be a unicode type array;
|
|
192
|
+
otherwise a ValueError is raised. Use array.tobytes().decode() to obtain a
|
|
193
|
+
unicode string from an array of some other type.
|
|
194
|
+
"""
|
|
195
|
+
...
|
|
61
196
|
if sys.version_info < (3, 9):
|
|
62
|
-
def fromstring(self, buffer: str | ReadableBuffer, /) -> None:
|
|
63
|
-
|
|
197
|
+
def fromstring(self, buffer: str | ReadableBuffer, /) -> None:
|
|
198
|
+
"""
|
|
199
|
+
Appends items from the string, interpreting it as an array of machine values, as if it had been read from a file using the fromfile() method).
|
|
200
|
+
|
|
201
|
+
This method is deprecated. Use frombytes instead.
|
|
202
|
+
"""
|
|
203
|
+
...
|
|
204
|
+
def tostring(self) -> bytes:
|
|
205
|
+
"""
|
|
206
|
+
Convert the array to an array of machine values and return the bytes representation.
|
|
207
|
+
|
|
208
|
+
This method is deprecated. Use tobytes instead.
|
|
209
|
+
"""
|
|
210
|
+
...
|
|
64
211
|
|
|
65
|
-
def __len__(self) -> int:
|
|
212
|
+
def __len__(self) -> int:
|
|
213
|
+
"""Return len(self)."""
|
|
214
|
+
...
|
|
66
215
|
@overload
|
|
67
|
-
def __getitem__(self, key: SupportsIndex, /) -> _T:
|
|
216
|
+
def __getitem__(self, key: SupportsIndex, /) -> _T:
|
|
217
|
+
"""Return self[key]."""
|
|
218
|
+
...
|
|
68
219
|
@overload
|
|
69
|
-
def __getitem__(self, key: slice, /) -> array[_T]:
|
|
220
|
+
def __getitem__(self, key: slice, /) -> array[_T]:
|
|
221
|
+
"""Return self[key]."""
|
|
222
|
+
...
|
|
70
223
|
@overload # type: ignore[override]
|
|
71
|
-
def __setitem__(self, key: SupportsIndex, value: _T, /) -> None:
|
|
224
|
+
def __setitem__(self, key: SupportsIndex, value: _T, /) -> None:
|
|
225
|
+
"""Set self[key] to value."""
|
|
226
|
+
...
|
|
72
227
|
@overload
|
|
73
|
-
def __setitem__(self, key: slice, value: array[_T], /) -> None:
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
def
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
def
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
def
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
def
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
def
|
|
228
|
+
def __setitem__(self, key: slice, value: array[_T], /) -> None:
|
|
229
|
+
"""Set self[key] to value."""
|
|
230
|
+
...
|
|
231
|
+
def __delitem__(self, key: SupportsIndex | slice, /) -> None:
|
|
232
|
+
"""Delete self[key]."""
|
|
233
|
+
...
|
|
234
|
+
def __add__(self, value: array[_T], /) -> array[_T]:
|
|
235
|
+
"""Return self+value."""
|
|
236
|
+
...
|
|
237
|
+
def __eq__(self, value: object, /) -> bool:
|
|
238
|
+
"""Return self==value."""
|
|
239
|
+
...
|
|
240
|
+
def __ge__(self, value: array[_T], /) -> bool:
|
|
241
|
+
"""Return self>=value."""
|
|
242
|
+
...
|
|
243
|
+
def __gt__(self, value: array[_T], /) -> bool:
|
|
244
|
+
"""Return self>value."""
|
|
245
|
+
...
|
|
246
|
+
def __iadd__(self, value: array[_T], /) -> Self:
|
|
247
|
+
"""Implement self+=value."""
|
|
248
|
+
...
|
|
249
|
+
def __imul__(self, value: int, /) -> Self:
|
|
250
|
+
"""Implement self*=value."""
|
|
251
|
+
...
|
|
252
|
+
def __le__(self, value: array[_T], /) -> bool:
|
|
253
|
+
"""Return self<=value."""
|
|
254
|
+
...
|
|
255
|
+
def __lt__(self, value: array[_T], /) -> bool:
|
|
256
|
+
"""Return self<value."""
|
|
257
|
+
...
|
|
258
|
+
def __mul__(self, value: int, /) -> array[_T]:
|
|
259
|
+
"""Return self*value."""
|
|
260
|
+
...
|
|
261
|
+
def __rmul__(self, value: int, /) -> array[_T]:
|
|
262
|
+
"""Return value*self."""
|
|
263
|
+
...
|
|
264
|
+
def __copy__(self) -> array[_T]:
|
|
265
|
+
"""Return a copy of the array."""
|
|
266
|
+
...
|
|
267
|
+
def __deepcopy__(self, unused: Any, /) -> array[_T]:
|
|
268
|
+
"""Return a copy of the array."""
|
|
269
|
+
...
|
|
270
|
+
def __buffer__(self, flags: int, /) -> memoryview:
|
|
271
|
+
"""Return a buffer object that exposes the underlying memory of the object."""
|
|
272
|
+
...
|
|
273
|
+
def __release_buffer__(self, buffer: memoryview, /) -> None:
|
|
274
|
+
"""Release the buffer object that exposes the underlying memory of the object."""
|
|
275
|
+
...
|
|
89
276
|
if sys.version_info >= (3, 12):
|
|
90
|
-
def __class_getitem__(cls, item: Any, /) -> GenericAlias:
|
|
277
|
+
def __class_getitem__(cls, item: Any, /) -> GenericAlias:
|
|
278
|
+
"""See PEP 585"""
|
|
279
|
+
...
|
|
91
280
|
|
|
92
281
|
ArrayType = array
|
|
@@ -1,3 +1,9 @@
|
|
|
1
|
+
"""
|
|
2
|
+
allow programmer to define multiple exit functions to be executedupon normal program termination.
|
|
3
|
+
|
|
4
|
+
Two public functions, register and unregister, are defined.
|
|
5
|
+
"""
|
|
6
|
+
|
|
1
7
|
from collections.abc import Callable
|
|
2
8
|
from typing import TypeVar
|
|
3
9
|
from typing_extensions import ParamSpec
|
|
@@ -5,8 +11,47 @@ from typing_extensions import ParamSpec
|
|
|
5
11
|
_T = TypeVar("_T")
|
|
6
12
|
_P = ParamSpec("_P")
|
|
7
13
|
|
|
8
|
-
def _clear() -> None:
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
14
|
+
def _clear() -> None:
|
|
15
|
+
"""
|
|
16
|
+
_clear() -> None
|
|
17
|
+
|
|
18
|
+
Clear the list of previously registered exit functions.
|
|
19
|
+
"""
|
|
20
|
+
...
|
|
21
|
+
def _ncallbacks() -> int:
|
|
22
|
+
"""
|
|
23
|
+
_ncallbacks() -> int
|
|
24
|
+
|
|
25
|
+
Return the number of registered exit functions.
|
|
26
|
+
"""
|
|
27
|
+
...
|
|
28
|
+
def _run_exitfuncs() -> None:
|
|
29
|
+
"""
|
|
30
|
+
_run_exitfuncs() -> None
|
|
31
|
+
|
|
32
|
+
Run all registered exit functions.
|
|
33
|
+
"""
|
|
34
|
+
...
|
|
35
|
+
def register(func: Callable[_P, _T], /, *args: _P.args, **kwargs: _P.kwargs) -> Callable[_P, _T]:
|
|
36
|
+
"""
|
|
37
|
+
register(func, *args, **kwargs) -> func
|
|
38
|
+
|
|
39
|
+
Register a function to be executed upon normal program termination
|
|
40
|
+
|
|
41
|
+
func - function to be called at exit
|
|
42
|
+
args - optional arguments to pass to func
|
|
43
|
+
kwargs - optional keyword arguments to pass to func
|
|
44
|
+
|
|
45
|
+
func is returned to facilitate usage as a decorator.
|
|
46
|
+
"""
|
|
47
|
+
...
|
|
48
|
+
def unregister(func: Callable[..., object], /) -> None:
|
|
49
|
+
"""
|
|
50
|
+
unregister(func) -> None
|
|
51
|
+
|
|
52
|
+
Unregister an exit function which was previously registered using
|
|
53
|
+
atexit.register
|
|
54
|
+
|
|
55
|
+
func - function to be unregistered
|
|
56
|
+
"""
|
|
57
|
+
...
|
|
@@ -5,26 +5,66 @@ _RatecvState: TypeAlias = tuple[int, tuple[tuple[int, int], ...]]
|
|
|
5
5
|
|
|
6
6
|
class error(Exception): ...
|
|
7
7
|
|
|
8
|
-
def add(fragment1: Buffer, fragment2: Buffer, width: int, /) -> bytes:
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
def
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
def
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
def
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
def
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
def
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
def
|
|
27
|
-
|
|
8
|
+
def add(fragment1: Buffer, fragment2: Buffer, width: int, /) -> bytes:
|
|
9
|
+
"""Return a fragment which is the addition of the two samples passed as parameters."""
|
|
10
|
+
...
|
|
11
|
+
def adpcm2lin(fragment: Buffer, width: int, state: _AdpcmState | None, /) -> tuple[bytes, _AdpcmState]:
|
|
12
|
+
"""Decode an Intel/DVI ADPCM coded fragment to a linear fragment."""
|
|
13
|
+
...
|
|
14
|
+
def alaw2lin(fragment: Buffer, width: int, /) -> bytes:
|
|
15
|
+
"""Convert sound fragments in a-LAW encoding to linearly encoded sound fragments."""
|
|
16
|
+
...
|
|
17
|
+
def avg(fragment: Buffer, width: int, /) -> int:
|
|
18
|
+
"""Return the average over all samples in the fragment."""
|
|
19
|
+
...
|
|
20
|
+
def avgpp(fragment: Buffer, width: int, /) -> int:
|
|
21
|
+
"""Return the average peak-peak value over all samples in the fragment."""
|
|
22
|
+
...
|
|
23
|
+
def bias(fragment: Buffer, width: int, bias: int, /) -> bytes:
|
|
24
|
+
"""Return a fragment that is the original fragment with a bias added to each sample."""
|
|
25
|
+
...
|
|
26
|
+
def byteswap(fragment: Buffer, width: int, /) -> bytes:
|
|
27
|
+
"""Convert big-endian samples to little-endian and vice versa."""
|
|
28
|
+
...
|
|
29
|
+
def cross(fragment: Buffer, width: int, /) -> int:
|
|
30
|
+
"""Return the number of zero crossings in the fragment passed as an argument."""
|
|
31
|
+
...
|
|
32
|
+
def findfactor(fragment: Buffer, reference: Buffer, /) -> float:
|
|
33
|
+
"""Return a factor F such that rms(add(fragment, mul(reference, -F))) is minimal."""
|
|
34
|
+
...
|
|
35
|
+
def findfit(fragment: Buffer, reference: Buffer, /) -> tuple[int, float]:
|
|
36
|
+
"""Try to match reference as well as possible to a portion of fragment."""
|
|
37
|
+
...
|
|
38
|
+
def findmax(fragment: Buffer, length: int, /) -> int:
|
|
39
|
+
"""Search fragment for a slice of specified number of samples with maximum energy."""
|
|
40
|
+
...
|
|
41
|
+
def getsample(fragment: Buffer, width: int, index: int, /) -> int:
|
|
42
|
+
"""Return the value of sample index from the fragment."""
|
|
43
|
+
...
|
|
44
|
+
def lin2adpcm(fragment: Buffer, width: int, state: _AdpcmState | None, /) -> tuple[bytes, _AdpcmState]:
|
|
45
|
+
"""Convert samples to 4 bit Intel/DVI ADPCM encoding."""
|
|
46
|
+
...
|
|
47
|
+
def lin2alaw(fragment: Buffer, width: int, /) -> bytes:
|
|
48
|
+
"""Convert samples in the audio fragment to a-LAW encoding."""
|
|
49
|
+
...
|
|
50
|
+
def lin2lin(fragment: Buffer, width: int, newwidth: int, /) -> bytes:
|
|
51
|
+
"""Convert samples between 1-, 2-, 3- and 4-byte formats."""
|
|
52
|
+
...
|
|
53
|
+
def lin2ulaw(fragment: Buffer, width: int, /) -> bytes:
|
|
54
|
+
"""Convert samples in the audio fragment to u-LAW encoding."""
|
|
55
|
+
...
|
|
56
|
+
def max(fragment: Buffer, width: int, /) -> int:
|
|
57
|
+
"""Return the maximum of the absolute value of all samples in a fragment."""
|
|
58
|
+
...
|
|
59
|
+
def maxpp(fragment: Buffer, width: int, /) -> int:
|
|
60
|
+
"""Return the maximum peak-peak value in the sound fragment."""
|
|
61
|
+
...
|
|
62
|
+
def minmax(fragment: Buffer, width: int, /) -> tuple[int, int]:
|
|
63
|
+
"""Return the minimum and maximum values of all samples in the sound fragment."""
|
|
64
|
+
...
|
|
65
|
+
def mul(fragment: Buffer, width: int, factor: float, /) -> bytes:
|
|
66
|
+
"""Return a fragment that has all samples in the original fragment multiplied by the floating-point value factor."""
|
|
67
|
+
...
|
|
28
68
|
def ratecv(
|
|
29
69
|
fragment: Buffer,
|
|
30
70
|
width: int,
|
|
@@ -35,9 +75,21 @@ def ratecv(
|
|
|
35
75
|
weightA: int = 1,
|
|
36
76
|
weightB: int = 0,
|
|
37
77
|
/,
|
|
38
|
-
) -> tuple[bytes, _RatecvState]:
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
def
|
|
42
|
-
|
|
43
|
-
|
|
78
|
+
) -> tuple[bytes, _RatecvState]:
|
|
79
|
+
"""Convert the frame rate of the input fragment."""
|
|
80
|
+
...
|
|
81
|
+
def reverse(fragment: Buffer, width: int, /) -> bytes:
|
|
82
|
+
"""Reverse the samples in a fragment and returns the modified fragment."""
|
|
83
|
+
...
|
|
84
|
+
def rms(fragment: Buffer, width: int, /) -> int:
|
|
85
|
+
"""Return the root-mean-square of the fragment, i.e. sqrt(sum(S_i^2)/n)."""
|
|
86
|
+
...
|
|
87
|
+
def tomono(fragment: Buffer, width: int, lfactor: float, rfactor: float, /) -> bytes:
|
|
88
|
+
"""Convert a stereo fragment to a mono fragment."""
|
|
89
|
+
...
|
|
90
|
+
def tostereo(fragment: Buffer, width: int, lfactor: float, rfactor: float, /) -> bytes:
|
|
91
|
+
"""Generate a stereo fragment from a mono fragment."""
|
|
92
|
+
...
|
|
93
|
+
def ulaw2lin(fragment: Buffer, width: int, /) -> bytes:
|
|
94
|
+
"""Convert sound fragments in u-LAW encoding to linearly encoded sound fragments."""
|
|
95
|
+
...
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
"""Conversion between binary data and ASCII"""
|
|
2
|
+
|
|
1
3
|
import sys
|
|
2
4
|
from _typeshed import ReadableBuffer
|
|
3
5
|
from typing_extensions import TypeAlias
|
|
@@ -6,31 +8,116 @@ from typing_extensions import TypeAlias
|
|
|
6
8
|
# or ASCII-only strings.
|
|
7
9
|
_AsciiBuffer: TypeAlias = str | ReadableBuffer
|
|
8
10
|
|
|
9
|
-
def a2b_uu(data: _AsciiBuffer, /) -> bytes:
|
|
10
|
-
|
|
11
|
+
def a2b_uu(data: _AsciiBuffer, /) -> bytes:
|
|
12
|
+
"""Decode a line of uuencoded data."""
|
|
13
|
+
...
|
|
14
|
+
def b2a_uu(data: ReadableBuffer, /, *, backtick: bool = False) -> bytes:
|
|
15
|
+
"""Uuencode line of data."""
|
|
16
|
+
...
|
|
11
17
|
|
|
12
18
|
if sys.version_info >= (3, 11):
|
|
13
|
-
def a2b_base64(data: _AsciiBuffer, /, *, strict_mode: bool = False) -> bytes:
|
|
19
|
+
def a2b_base64(data: _AsciiBuffer, /, *, strict_mode: bool = False) -> bytes:
|
|
20
|
+
"""
|
|
21
|
+
Decode a line of base64 data.
|
|
22
|
+
|
|
23
|
+
strict_mode
|
|
24
|
+
When set to True, bytes that are not part of the base64 standard are not allowed.
|
|
25
|
+
The same applies to excess data after padding (= / ==).
|
|
26
|
+
"""
|
|
27
|
+
...
|
|
14
28
|
|
|
15
29
|
else:
|
|
16
|
-
def a2b_base64(data: _AsciiBuffer, /) -> bytes:
|
|
30
|
+
def a2b_base64(data: _AsciiBuffer, /) -> bytes:
|
|
31
|
+
"""Decode a line of base64 data."""
|
|
32
|
+
...
|
|
33
|
+
|
|
34
|
+
def b2a_base64(data: ReadableBuffer, /, *, newline: bool = True) -> bytes:
|
|
35
|
+
"""Base64-code line of data."""
|
|
36
|
+
...
|
|
37
|
+
def a2b_qp(data: _AsciiBuffer, header: bool = False) -> bytes:
|
|
38
|
+
"""Decode a string of qp-encoded data."""
|
|
39
|
+
...
|
|
40
|
+
def b2a_qp(data: ReadableBuffer, quotetabs: bool = False, istext: bool = True, header: bool = False) -> bytes:
|
|
41
|
+
r"""
|
|
42
|
+
Encode a string using quoted-printable encoding.
|
|
17
43
|
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
44
|
+
On encoding, when istext is set, newlines are not encoded, and white
|
|
45
|
+
space at end of lines is. When istext is not set, \r and \n (CR/LF)
|
|
46
|
+
are both encoded. When quotetabs is set, space and tabs are encoded.
|
|
47
|
+
"""
|
|
48
|
+
...
|
|
21
49
|
|
|
22
50
|
if sys.version_info < (3, 11):
|
|
23
|
-
def a2b_hqx(data: _AsciiBuffer, /) -> bytes:
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
def
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
def
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
def
|
|
33
|
-
|
|
51
|
+
def a2b_hqx(data: _AsciiBuffer, /) -> bytes:
|
|
52
|
+
"""Decode .hqx coding."""
|
|
53
|
+
...
|
|
54
|
+
def rledecode_hqx(data: ReadableBuffer, /) -> bytes:
|
|
55
|
+
"""Decode hexbin RLE-coded string."""
|
|
56
|
+
...
|
|
57
|
+
def rlecode_hqx(data: ReadableBuffer, /) -> bytes:
|
|
58
|
+
"""Binhex RLE-code binary data."""
|
|
59
|
+
...
|
|
60
|
+
def b2a_hqx(data: ReadableBuffer, /) -> bytes:
|
|
61
|
+
"""Encode .hqx data."""
|
|
62
|
+
...
|
|
63
|
+
|
|
64
|
+
def crc_hqx(data: ReadableBuffer, crc: int, /) -> int:
|
|
65
|
+
"""Compute CRC-CCITT incrementally."""
|
|
66
|
+
...
|
|
67
|
+
def crc32(data: ReadableBuffer, crc: int = 0, /) -> int:
|
|
68
|
+
"""Compute CRC-32 incrementally."""
|
|
69
|
+
...
|
|
70
|
+
def b2a_hex(data: ReadableBuffer, sep: str | bytes = ..., bytes_per_sep: int = ...) -> bytes:
|
|
71
|
+
r"""
|
|
72
|
+
Hexadecimal representation of binary data.
|
|
73
|
+
|
|
74
|
+
sep
|
|
75
|
+
An optional single character or byte to separate hex bytes.
|
|
76
|
+
bytes_per_sep
|
|
77
|
+
How many bytes between separators. Positive values count from the
|
|
78
|
+
right, negative values count from the left.
|
|
79
|
+
|
|
80
|
+
The return value is a bytes object. This function is also
|
|
81
|
+
available as "hexlify()".
|
|
82
|
+
|
|
83
|
+
Example:
|
|
84
|
+
>>> binascii.b2a_hex(b'\xb9\x01\xef')
|
|
85
|
+
b'b901ef'
|
|
86
|
+
>>> binascii.hexlify(b'\xb9\x01\xef', ':')
|
|
87
|
+
b'b9:01:ef'
|
|
88
|
+
>>> binascii.b2a_hex(b'\xb9\x01\xef', b'_', 2)
|
|
89
|
+
b'b9_01ef'
|
|
90
|
+
"""
|
|
91
|
+
...
|
|
92
|
+
def hexlify(data: ReadableBuffer, sep: str | bytes = ..., bytes_per_sep: int = ...) -> bytes:
|
|
93
|
+
"""
|
|
94
|
+
Hexadecimal representation of binary data.
|
|
95
|
+
|
|
96
|
+
sep
|
|
97
|
+
An optional single character or byte to separate hex bytes.
|
|
98
|
+
bytes_per_sep
|
|
99
|
+
How many bytes between separators. Positive values count from the
|
|
100
|
+
right, negative values count from the left.
|
|
101
|
+
|
|
102
|
+
The return value is a bytes object. This function is also
|
|
103
|
+
available as "b2a_hex()".
|
|
104
|
+
"""
|
|
105
|
+
...
|
|
106
|
+
def a2b_hex(hexstr: _AsciiBuffer, /) -> bytes:
|
|
107
|
+
"""
|
|
108
|
+
Binary data of hexadecimal representation.
|
|
109
|
+
|
|
110
|
+
hexstr must contain an even number of hex digits (upper or lower case).
|
|
111
|
+
This function is also available as "unhexlify()".
|
|
112
|
+
"""
|
|
113
|
+
...
|
|
114
|
+
def unhexlify(hexstr: _AsciiBuffer, /) -> bytes:
|
|
115
|
+
"""
|
|
116
|
+
Binary data of hexadecimal representation.
|
|
117
|
+
|
|
118
|
+
hexstr must contain an even number of hex digits (upper or lower case).
|
|
119
|
+
"""
|
|
120
|
+
...
|
|
34
121
|
|
|
35
122
|
class Error(ValueError): ...
|
|
36
123
|
class Incomplete(Exception): ...
|