coinex-api 0.0.14__py3-none-any.whl → 0.0.15__py3-none-any.whl
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.
- {coinex_api-0.0.14.dist-info → coinex_api-0.0.15.dist-info}/METADATA +1 -1
- coinex_api-0.0.15.dist-info/RECORD +3 -0
- coinex/__init__.py +0 -7
- coinex/ccxt/__init__.py +0 -101
- coinex/ccxt/abstract/coinex.py +0 -237
- coinex/ccxt/async_support/__init__.py +0 -80
- coinex/ccxt/async_support/base/__init__.py +0 -1
- coinex/ccxt/async_support/base/exchange.py +0 -2100
- coinex/ccxt/async_support/base/throttler.py +0 -50
- coinex/ccxt/async_support/base/ws/__init__.py +0 -38
- coinex/ccxt/async_support/base/ws/aiohttp_client.py +0 -147
- coinex/ccxt/async_support/base/ws/cache.py +0 -213
- coinex/ccxt/async_support/base/ws/client.py +0 -214
- coinex/ccxt/async_support/base/ws/fast_client.py +0 -97
- coinex/ccxt/async_support/base/ws/functions.py +0 -59
- coinex/ccxt/async_support/base/ws/future.py +0 -69
- coinex/ccxt/async_support/base/ws/order_book.py +0 -78
- coinex/ccxt/async_support/base/ws/order_book_side.py +0 -174
- coinex/ccxt/async_support/coinex.py +0 -5833
- coinex/ccxt/base/__init__.py +0 -27
- coinex/ccxt/base/decimal_to_precision.py +0 -174
- coinex/ccxt/base/errors.py +0 -267
- coinex/ccxt/base/exchange.py +0 -6769
- coinex/ccxt/base/precise.py +0 -297
- coinex/ccxt/base/types.py +0 -577
- coinex/ccxt/coinex.py +0 -5832
- coinex/ccxt/pro/__init__.py +0 -21
- coinex/ccxt/pro/coinex.py +0 -1366
- coinex/ccxt/static_dependencies/README.md +0 -1
- coinex/ccxt/static_dependencies/__init__.py +0 -1
- coinex/ccxt/static_dependencies/ecdsa/__init__.py +0 -14
- coinex/ccxt/static_dependencies/ecdsa/_version.py +0 -520
- coinex/ccxt/static_dependencies/ecdsa/curves.py +0 -56
- coinex/ccxt/static_dependencies/ecdsa/der.py +0 -221
- coinex/ccxt/static_dependencies/ecdsa/ecdsa.py +0 -310
- coinex/ccxt/static_dependencies/ecdsa/ellipticcurve.py +0 -197
- coinex/ccxt/static_dependencies/ecdsa/keys.py +0 -332
- coinex/ccxt/static_dependencies/ecdsa/numbertheory.py +0 -531
- coinex/ccxt/static_dependencies/ecdsa/rfc6979.py +0 -100
- coinex/ccxt/static_dependencies/ecdsa/util.py +0 -266
- coinex/ccxt/static_dependencies/ethereum/__init__.py +0 -7
- coinex/ccxt/static_dependencies/ethereum/abi/__init__.py +0 -16
- coinex/ccxt/static_dependencies/ethereum/abi/abi.py +0 -19
- coinex/ccxt/static_dependencies/ethereum/abi/base.py +0 -152
- coinex/ccxt/static_dependencies/ethereum/abi/codec.py +0 -217
- coinex/ccxt/static_dependencies/ethereum/abi/constants.py +0 -3
- coinex/ccxt/static_dependencies/ethereum/abi/decoding.py +0 -565
- coinex/ccxt/static_dependencies/ethereum/abi/encoding.py +0 -720
- coinex/ccxt/static_dependencies/ethereum/abi/exceptions.py +0 -139
- coinex/ccxt/static_dependencies/ethereum/abi/grammar.py +0 -443
- coinex/ccxt/static_dependencies/ethereum/abi/packed.py +0 -13
- coinex/ccxt/static_dependencies/ethereum/abi/py.typed +0 -0
- coinex/ccxt/static_dependencies/ethereum/abi/registry.py +0 -643
- coinex/ccxt/static_dependencies/ethereum/abi/tools/__init__.py +0 -3
- coinex/ccxt/static_dependencies/ethereum/abi/tools/_strategies.py +0 -230
- coinex/ccxt/static_dependencies/ethereum/abi/utils/__init__.py +0 -0
- coinex/ccxt/static_dependencies/ethereum/abi/utils/numeric.py +0 -83
- coinex/ccxt/static_dependencies/ethereum/abi/utils/padding.py +0 -27
- coinex/ccxt/static_dependencies/ethereum/abi/utils/string.py +0 -19
- coinex/ccxt/static_dependencies/ethereum/account/__init__.py +0 -3
- coinex/ccxt/static_dependencies/ethereum/account/encode_typed_data/__init__.py +0 -4
- coinex/ccxt/static_dependencies/ethereum/account/encode_typed_data/encoding_and_hashing.py +0 -239
- coinex/ccxt/static_dependencies/ethereum/account/encode_typed_data/helpers.py +0 -40
- coinex/ccxt/static_dependencies/ethereum/account/messages.py +0 -263
- coinex/ccxt/static_dependencies/ethereum/account/py.typed +0 -0
- coinex/ccxt/static_dependencies/ethereum/hexbytes/__init__.py +0 -5
- coinex/ccxt/static_dependencies/ethereum/hexbytes/_utils.py +0 -54
- coinex/ccxt/static_dependencies/ethereum/hexbytes/main.py +0 -65
- coinex/ccxt/static_dependencies/ethereum/hexbytes/py.typed +0 -0
- coinex/ccxt/static_dependencies/ethereum/typing/__init__.py +0 -63
- coinex/ccxt/static_dependencies/ethereum/typing/abi.py +0 -6
- coinex/ccxt/static_dependencies/ethereum/typing/bls.py +0 -7
- coinex/ccxt/static_dependencies/ethereum/typing/discovery.py +0 -5
- coinex/ccxt/static_dependencies/ethereum/typing/encoding.py +0 -7
- coinex/ccxt/static_dependencies/ethereum/typing/enums.py +0 -17
- coinex/ccxt/static_dependencies/ethereum/typing/ethpm.py +0 -9
- coinex/ccxt/static_dependencies/ethereum/typing/evm.py +0 -20
- coinex/ccxt/static_dependencies/ethereum/typing/networks.py +0 -1122
- coinex/ccxt/static_dependencies/ethereum/typing/py.typed +0 -0
- coinex/ccxt/static_dependencies/ethereum/utils/__init__.py +0 -115
- coinex/ccxt/static_dependencies/ethereum/utils/abi.py +0 -72
- coinex/ccxt/static_dependencies/ethereum/utils/address.py +0 -171
- coinex/ccxt/static_dependencies/ethereum/utils/applicators.py +0 -151
- coinex/ccxt/static_dependencies/ethereum/utils/conversions.py +0 -190
- coinex/ccxt/static_dependencies/ethereum/utils/currency.py +0 -107
- coinex/ccxt/static_dependencies/ethereum/utils/curried/__init__.py +0 -269
- coinex/ccxt/static_dependencies/ethereum/utils/debug.py +0 -20
- coinex/ccxt/static_dependencies/ethereum/utils/decorators.py +0 -132
- coinex/ccxt/static_dependencies/ethereum/utils/encoding.py +0 -6
- coinex/ccxt/static_dependencies/ethereum/utils/exceptions.py +0 -4
- coinex/ccxt/static_dependencies/ethereum/utils/functional.py +0 -75
- coinex/ccxt/static_dependencies/ethereum/utils/hexadecimal.py +0 -74
- coinex/ccxt/static_dependencies/ethereum/utils/humanize.py +0 -188
- coinex/ccxt/static_dependencies/ethereum/utils/logging.py +0 -159
- coinex/ccxt/static_dependencies/ethereum/utils/module_loading.py +0 -31
- coinex/ccxt/static_dependencies/ethereum/utils/numeric.py +0 -43
- coinex/ccxt/static_dependencies/ethereum/utils/py.typed +0 -0
- coinex/ccxt/static_dependencies/ethereum/utils/toolz.py +0 -76
- coinex/ccxt/static_dependencies/ethereum/utils/types.py +0 -54
- coinex/ccxt/static_dependencies/ethereum/utils/typing/__init__.py +0 -18
- coinex/ccxt/static_dependencies/ethereum/utils/typing/misc.py +0 -14
- coinex/ccxt/static_dependencies/ethereum/utils/units.py +0 -31
- coinex/ccxt/static_dependencies/keccak/__init__.py +0 -3
- coinex/ccxt/static_dependencies/keccak/keccak.py +0 -197
- coinex/ccxt/static_dependencies/lark/__init__.py +0 -38
- coinex/ccxt/static_dependencies/lark/__pyinstaller/__init__.py +0 -6
- coinex/ccxt/static_dependencies/lark/__pyinstaller/hook-lark.py +0 -14
- coinex/ccxt/static_dependencies/lark/ast_utils.py +0 -59
- coinex/ccxt/static_dependencies/lark/common.py +0 -86
- coinex/ccxt/static_dependencies/lark/exceptions.py +0 -292
- coinex/ccxt/static_dependencies/lark/grammar.py +0 -130
- coinex/ccxt/static_dependencies/lark/grammars/__init__.py +0 -0
- coinex/ccxt/static_dependencies/lark/grammars/common.lark +0 -59
- coinex/ccxt/static_dependencies/lark/grammars/lark.lark +0 -62
- coinex/ccxt/static_dependencies/lark/grammars/python.lark +0 -302
- coinex/ccxt/static_dependencies/lark/grammars/unicode.lark +0 -7
- coinex/ccxt/static_dependencies/lark/indenter.py +0 -143
- coinex/ccxt/static_dependencies/lark/lark.py +0 -658
- coinex/ccxt/static_dependencies/lark/lexer.py +0 -678
- coinex/ccxt/static_dependencies/lark/load_grammar.py +0 -1428
- coinex/ccxt/static_dependencies/lark/parse_tree_builder.py +0 -391
- coinex/ccxt/static_dependencies/lark/parser_frontends.py +0 -257
- coinex/ccxt/static_dependencies/lark/parsers/__init__.py +0 -0
- coinex/ccxt/static_dependencies/lark/parsers/cyk.py +0 -340
- coinex/ccxt/static_dependencies/lark/parsers/earley.py +0 -314
- coinex/ccxt/static_dependencies/lark/parsers/earley_common.py +0 -42
- coinex/ccxt/static_dependencies/lark/parsers/earley_forest.py +0 -801
- coinex/ccxt/static_dependencies/lark/parsers/grammar_analysis.py +0 -203
- coinex/ccxt/static_dependencies/lark/parsers/lalr_analysis.py +0 -332
- coinex/ccxt/static_dependencies/lark/parsers/lalr_interactive_parser.py +0 -158
- coinex/ccxt/static_dependencies/lark/parsers/lalr_parser.py +0 -122
- coinex/ccxt/static_dependencies/lark/parsers/lalr_parser_state.py +0 -110
- coinex/ccxt/static_dependencies/lark/parsers/xearley.py +0 -165
- coinex/ccxt/static_dependencies/lark/py.typed +0 -0
- coinex/ccxt/static_dependencies/lark/reconstruct.py +0 -107
- coinex/ccxt/static_dependencies/lark/tools/__init__.py +0 -70
- coinex/ccxt/static_dependencies/lark/tools/nearley.py +0 -202
- coinex/ccxt/static_dependencies/lark/tools/serialize.py +0 -32
- coinex/ccxt/static_dependencies/lark/tools/standalone.py +0 -196
- coinex/ccxt/static_dependencies/lark/tree.py +0 -267
- coinex/ccxt/static_dependencies/lark/tree_matcher.py +0 -186
- coinex/ccxt/static_dependencies/lark/tree_templates.py +0 -180
- coinex/ccxt/static_dependencies/lark/utils.py +0 -343
- coinex/ccxt/static_dependencies/lark/visitors.py +0 -596
- coinex/ccxt/static_dependencies/marshmallow/__init__.py +0 -81
- coinex/ccxt/static_dependencies/marshmallow/base.py +0 -65
- coinex/ccxt/static_dependencies/marshmallow/class_registry.py +0 -94
- coinex/ccxt/static_dependencies/marshmallow/decorators.py +0 -231
- coinex/ccxt/static_dependencies/marshmallow/error_store.py +0 -60
- coinex/ccxt/static_dependencies/marshmallow/exceptions.py +0 -71
- coinex/ccxt/static_dependencies/marshmallow/fields.py +0 -2114
- coinex/ccxt/static_dependencies/marshmallow/orderedset.py +0 -89
- coinex/ccxt/static_dependencies/marshmallow/py.typed +0 -0
- coinex/ccxt/static_dependencies/marshmallow/schema.py +0 -1228
- coinex/ccxt/static_dependencies/marshmallow/types.py +0 -12
- coinex/ccxt/static_dependencies/marshmallow/utils.py +0 -378
- coinex/ccxt/static_dependencies/marshmallow/validate.py +0 -678
- coinex/ccxt/static_dependencies/marshmallow/warnings.py +0 -2
- coinex/ccxt/static_dependencies/marshmallow_dataclass/__init__.py +0 -1047
- coinex/ccxt/static_dependencies/marshmallow_dataclass/collection_field.py +0 -51
- coinex/ccxt/static_dependencies/marshmallow_dataclass/lazy_class_attribute.py +0 -45
- coinex/ccxt/static_dependencies/marshmallow_dataclass/mypy.py +0 -71
- coinex/ccxt/static_dependencies/marshmallow_dataclass/py.typed +0 -0
- coinex/ccxt/static_dependencies/marshmallow_dataclass/typing.py +0 -14
- coinex/ccxt/static_dependencies/marshmallow_dataclass/union_field.py +0 -82
- coinex/ccxt/static_dependencies/marshmallow_oneofschema/__init__.py +0 -1
- coinex/ccxt/static_dependencies/marshmallow_oneofschema/one_of_schema.py +0 -193
- coinex/ccxt/static_dependencies/marshmallow_oneofschema/py.typed +0 -0
- coinex/ccxt/static_dependencies/msgpack/__init__.py +0 -55
- coinex/ccxt/static_dependencies/msgpack/_cmsgpack.pyx +0 -11
- coinex/ccxt/static_dependencies/msgpack/_packer.pyx +0 -374
- coinex/ccxt/static_dependencies/msgpack/_unpacker.pyx +0 -547
- coinex/ccxt/static_dependencies/msgpack/buff_converter.h +0 -8
- coinex/ccxt/static_dependencies/msgpack/exceptions.py +0 -48
- coinex/ccxt/static_dependencies/msgpack/ext.py +0 -168
- coinex/ccxt/static_dependencies/msgpack/fallback.py +0 -951
- coinex/ccxt/static_dependencies/msgpack/pack.h +0 -89
- coinex/ccxt/static_dependencies/msgpack/pack_template.h +0 -820
- coinex/ccxt/static_dependencies/msgpack/sysdep.h +0 -194
- coinex/ccxt/static_dependencies/msgpack/unpack.h +0 -391
- coinex/ccxt/static_dependencies/msgpack/unpack_define.h +0 -95
- coinex/ccxt/static_dependencies/msgpack/unpack_template.h +0 -464
- coinex/ccxt/static_dependencies/parsimonious/__init__.py +0 -10
- coinex/ccxt/static_dependencies/parsimonious/exceptions.py +0 -105
- coinex/ccxt/static_dependencies/parsimonious/expressions.py +0 -479
- coinex/ccxt/static_dependencies/parsimonious/grammar.py +0 -487
- coinex/ccxt/static_dependencies/parsimonious/nodes.py +0 -325
- coinex/ccxt/static_dependencies/parsimonious/utils.py +0 -40
- coinex/ccxt/static_dependencies/starknet/__init__.py +0 -0
- coinex/ccxt/static_dependencies/starknet/abi/v0/__init__.py +0 -2
- coinex/ccxt/static_dependencies/starknet/abi/v0/model.py +0 -44
- coinex/ccxt/static_dependencies/starknet/abi/v0/parser.py +0 -216
- coinex/ccxt/static_dependencies/starknet/abi/v0/schemas.py +0 -72
- coinex/ccxt/static_dependencies/starknet/abi/v0/shape.py +0 -63
- coinex/ccxt/static_dependencies/starknet/abi/v1/__init__.py +0 -2
- coinex/ccxt/static_dependencies/starknet/abi/v1/core_structures.json +0 -14
- coinex/ccxt/static_dependencies/starknet/abi/v1/model.py +0 -39
- coinex/ccxt/static_dependencies/starknet/abi/v1/parser.py +0 -220
- coinex/ccxt/static_dependencies/starknet/abi/v1/parser_transformer.py +0 -179
- coinex/ccxt/static_dependencies/starknet/abi/v1/schemas.py +0 -66
- coinex/ccxt/static_dependencies/starknet/abi/v1/shape.py +0 -47
- coinex/ccxt/static_dependencies/starknet/abi/v2/__init__.py +0 -2
- coinex/ccxt/static_dependencies/starknet/abi/v2/model.py +0 -89
- coinex/ccxt/static_dependencies/starknet/abi/v2/parser.py +0 -293
- coinex/ccxt/static_dependencies/starknet/abi/v2/parser_transformer.py +0 -192
- coinex/ccxt/static_dependencies/starknet/abi/v2/schemas.py +0 -132
- coinex/ccxt/static_dependencies/starknet/abi/v2/shape.py +0 -107
- coinex/ccxt/static_dependencies/starknet/cairo/__init__.py +0 -0
- coinex/ccxt/static_dependencies/starknet/cairo/data_types.py +0 -123
- coinex/ccxt/static_dependencies/starknet/cairo/deprecated_parse/__init__.py +0 -0
- coinex/ccxt/static_dependencies/starknet/cairo/deprecated_parse/cairo_types.py +0 -77
- coinex/ccxt/static_dependencies/starknet/cairo/deprecated_parse/parser.py +0 -46
- coinex/ccxt/static_dependencies/starknet/cairo/deprecated_parse/parser_transformer.py +0 -138
- coinex/ccxt/static_dependencies/starknet/cairo/felt.py +0 -64
- coinex/ccxt/static_dependencies/starknet/cairo/type_parser.py +0 -121
- coinex/ccxt/static_dependencies/starknet/cairo/v1/__init__.py +0 -0
- coinex/ccxt/static_dependencies/starknet/cairo/v1/type_parser.py +0 -59
- coinex/ccxt/static_dependencies/starknet/cairo/v2/__init__.py +0 -0
- coinex/ccxt/static_dependencies/starknet/cairo/v2/type_parser.py +0 -77
- coinex/ccxt/static_dependencies/starknet/ccxt_utils.py +0 -7
- coinex/ccxt/static_dependencies/starknet/common.py +0 -15
- coinex/ccxt/static_dependencies/starknet/constants.py +0 -39
- coinex/ccxt/static_dependencies/starknet/hash/__init__.py +0 -0
- coinex/ccxt/static_dependencies/starknet/hash/address.py +0 -79
- coinex/ccxt/static_dependencies/starknet/hash/compiled_class_hash_objects.py +0 -111
- coinex/ccxt/static_dependencies/starknet/hash/selector.py +0 -16
- coinex/ccxt/static_dependencies/starknet/hash/storage.py +0 -12
- coinex/ccxt/static_dependencies/starknet/hash/utils.py +0 -78
- coinex/ccxt/static_dependencies/starknet/models/__init__.py +0 -0
- coinex/ccxt/static_dependencies/starknet/models/typed_data.py +0 -45
- coinex/ccxt/static_dependencies/starknet/serialization/__init__.py +0 -24
- coinex/ccxt/static_dependencies/starknet/serialization/_calldata_reader.py +0 -40
- coinex/ccxt/static_dependencies/starknet/serialization/_context.py +0 -142
- coinex/ccxt/static_dependencies/starknet/serialization/data_serializers/__init__.py +0 -10
- coinex/ccxt/static_dependencies/starknet/serialization/data_serializers/_common.py +0 -82
- coinex/ccxt/static_dependencies/starknet/serialization/data_serializers/array_serializer.py +0 -43
- coinex/ccxt/static_dependencies/starknet/serialization/data_serializers/bool_serializer.py +0 -37
- coinex/ccxt/static_dependencies/starknet/serialization/data_serializers/byte_array_serializer.py +0 -66
- coinex/ccxt/static_dependencies/starknet/serialization/data_serializers/cairo_data_serializer.py +0 -71
- coinex/ccxt/static_dependencies/starknet/serialization/data_serializers/enum_serializer.py +0 -71
- coinex/ccxt/static_dependencies/starknet/serialization/data_serializers/felt_serializer.py +0 -50
- coinex/ccxt/static_dependencies/starknet/serialization/data_serializers/named_tuple_serializer.py +0 -58
- coinex/ccxt/static_dependencies/starknet/serialization/data_serializers/option_serializer.py +0 -43
- coinex/ccxt/static_dependencies/starknet/serialization/data_serializers/output_serializer.py +0 -40
- coinex/ccxt/static_dependencies/starknet/serialization/data_serializers/payload_serializer.py +0 -72
- coinex/ccxt/static_dependencies/starknet/serialization/data_serializers/struct_serializer.py +0 -36
- coinex/ccxt/static_dependencies/starknet/serialization/data_serializers/tuple_serializer.py +0 -36
- coinex/ccxt/static_dependencies/starknet/serialization/data_serializers/uint256_serializer.py +0 -76
- coinex/ccxt/static_dependencies/starknet/serialization/data_serializers/uint_serializer.py +0 -100
- coinex/ccxt/static_dependencies/starknet/serialization/data_serializers/unit_serializer.py +0 -32
- coinex/ccxt/static_dependencies/starknet/serialization/errors.py +0 -10
- coinex/ccxt/static_dependencies/starknet/serialization/factory.py +0 -229
- coinex/ccxt/static_dependencies/starknet/serialization/function_serialization_adapter.py +0 -110
- coinex/ccxt/static_dependencies/starknet/serialization/tuple_dataclass.py +0 -59
- coinex/ccxt/static_dependencies/starknet/utils/__init__.py +0 -0
- coinex/ccxt/static_dependencies/starknet/utils/constructor_args_translator.py +0 -86
- coinex/ccxt/static_dependencies/starknet/utils/iterable.py +0 -13
- coinex/ccxt/static_dependencies/starknet/utils/schema.py +0 -13
- coinex/ccxt/static_dependencies/starknet/utils/typed_data.py +0 -182
- coinex/ccxt/static_dependencies/starkware/__init__.py +0 -0
- coinex/ccxt/static_dependencies/starkware/crypto/__init__.py +0 -0
- coinex/ccxt/static_dependencies/starkware/crypto/fast_pedersen_hash.py +0 -50
- coinex/ccxt/static_dependencies/starkware/crypto/math_utils.py +0 -78
- coinex/ccxt/static_dependencies/starkware/crypto/signature.py +0 -2344
- coinex/ccxt/static_dependencies/starkware/crypto/utils.py +0 -63
- coinex/ccxt/static_dependencies/sympy/__init__.py +0 -0
- coinex/ccxt/static_dependencies/sympy/core/__init__.py +0 -0
- coinex/ccxt/static_dependencies/sympy/core/intfunc.py +0 -35
- coinex/ccxt/static_dependencies/sympy/external/__init__.py +0 -0
- coinex/ccxt/static_dependencies/sympy/external/gmpy.py +0 -345
- coinex/ccxt/static_dependencies/sympy/external/importtools.py +0 -187
- coinex/ccxt/static_dependencies/sympy/external/ntheory.py +0 -637
- coinex/ccxt/static_dependencies/sympy/external/pythonmpq.py +0 -341
- coinex/ccxt/static_dependencies/toolz/__init__.py +0 -26
- coinex/ccxt/static_dependencies/toolz/_signatures.py +0 -784
- coinex/ccxt/static_dependencies/toolz/_version.py +0 -520
- coinex/ccxt/static_dependencies/toolz/compatibility.py +0 -30
- coinex/ccxt/static_dependencies/toolz/curried/__init__.py +0 -101
- coinex/ccxt/static_dependencies/toolz/curried/exceptions.py +0 -22
- coinex/ccxt/static_dependencies/toolz/curried/operator.py +0 -22
- coinex/ccxt/static_dependencies/toolz/dicttoolz.py +0 -339
- coinex/ccxt/static_dependencies/toolz/functoolz.py +0 -1049
- coinex/ccxt/static_dependencies/toolz/itertoolz.py +0 -1057
- coinex/ccxt/static_dependencies/toolz/recipes.py +0 -46
- coinex/ccxt/static_dependencies/toolz/utils.py +0 -9
- coinex/ccxt/static_dependencies/typing_inspect/__init__.py +0 -0
- coinex/ccxt/static_dependencies/typing_inspect/typing_inspect.py +0 -851
- coinex_api-0.0.14.dist-info/RECORD +0 -288
- {coinex_api-0.0.14.dist-info → coinex_api-0.0.15.dist-info}/WHEEL +0 -0
@@ -1,547 +0,0 @@
|
|
1
|
-
# coding: utf-8
|
2
|
-
|
3
|
-
from cpython cimport *
|
4
|
-
cdef extern from "Python.h":
|
5
|
-
ctypedef struct PyObject
|
6
|
-
object PyMemoryView_GetContiguous(object obj, int buffertype, char order)
|
7
|
-
|
8
|
-
from libc.stdlib cimport *
|
9
|
-
from libc.string cimport *
|
10
|
-
from libc.limits cimport *
|
11
|
-
from libc.stdint cimport uint64_t
|
12
|
-
|
13
|
-
from .exceptions import (
|
14
|
-
BufferFull,
|
15
|
-
OutOfData,
|
16
|
-
ExtraData,
|
17
|
-
FormatError,
|
18
|
-
StackError,
|
19
|
-
)
|
20
|
-
from .ext import ExtType, Timestamp
|
21
|
-
|
22
|
-
cdef object giga = 1_000_000_000
|
23
|
-
|
24
|
-
|
25
|
-
cdef extern from "unpack.h":
|
26
|
-
ctypedef struct msgpack_user:
|
27
|
-
bint use_list
|
28
|
-
bint raw
|
29
|
-
bint has_pairs_hook # call object_hook with k-v pairs
|
30
|
-
bint strict_map_key
|
31
|
-
int timestamp
|
32
|
-
PyObject* object_hook
|
33
|
-
PyObject* list_hook
|
34
|
-
PyObject* ext_hook
|
35
|
-
PyObject* timestamp_t
|
36
|
-
PyObject *giga;
|
37
|
-
PyObject *utc;
|
38
|
-
char *unicode_errors
|
39
|
-
Py_ssize_t max_str_len
|
40
|
-
Py_ssize_t max_bin_len
|
41
|
-
Py_ssize_t max_array_len
|
42
|
-
Py_ssize_t max_map_len
|
43
|
-
Py_ssize_t max_ext_len
|
44
|
-
|
45
|
-
ctypedef struct unpack_context:
|
46
|
-
msgpack_user user
|
47
|
-
PyObject* obj
|
48
|
-
Py_ssize_t count
|
49
|
-
|
50
|
-
ctypedef int (*execute_fn)(unpack_context* ctx, const char* data,
|
51
|
-
Py_ssize_t len, Py_ssize_t* off) except? -1
|
52
|
-
execute_fn unpack_construct
|
53
|
-
execute_fn unpack_skip
|
54
|
-
execute_fn read_array_header
|
55
|
-
execute_fn read_map_header
|
56
|
-
void unpack_init(unpack_context* ctx)
|
57
|
-
object unpack_data(unpack_context* ctx)
|
58
|
-
void unpack_clear(unpack_context* ctx)
|
59
|
-
|
60
|
-
cdef inline init_ctx(unpack_context *ctx,
|
61
|
-
object object_hook, object object_pairs_hook,
|
62
|
-
object list_hook, object ext_hook,
|
63
|
-
bint use_list, bint raw, int timestamp,
|
64
|
-
bint strict_map_key,
|
65
|
-
const char* unicode_errors,
|
66
|
-
Py_ssize_t max_str_len, Py_ssize_t max_bin_len,
|
67
|
-
Py_ssize_t max_array_len, Py_ssize_t max_map_len,
|
68
|
-
Py_ssize_t max_ext_len):
|
69
|
-
unpack_init(ctx)
|
70
|
-
ctx.user.use_list = use_list
|
71
|
-
ctx.user.raw = raw
|
72
|
-
ctx.user.strict_map_key = strict_map_key
|
73
|
-
ctx.user.object_hook = ctx.user.list_hook = <PyObject*>NULL
|
74
|
-
ctx.user.max_str_len = max_str_len
|
75
|
-
ctx.user.max_bin_len = max_bin_len
|
76
|
-
ctx.user.max_array_len = max_array_len
|
77
|
-
ctx.user.max_map_len = max_map_len
|
78
|
-
ctx.user.max_ext_len = max_ext_len
|
79
|
-
|
80
|
-
if object_hook is not None and object_pairs_hook is not None:
|
81
|
-
raise TypeError("object_pairs_hook and object_hook are mutually exclusive.")
|
82
|
-
|
83
|
-
if object_hook is not None:
|
84
|
-
if not PyCallable_Check(object_hook):
|
85
|
-
raise TypeError("object_hook must be a callable.")
|
86
|
-
ctx.user.object_hook = <PyObject*>object_hook
|
87
|
-
|
88
|
-
if object_pairs_hook is None:
|
89
|
-
ctx.user.has_pairs_hook = False
|
90
|
-
else:
|
91
|
-
if not PyCallable_Check(object_pairs_hook):
|
92
|
-
raise TypeError("object_pairs_hook must be a callable.")
|
93
|
-
ctx.user.object_hook = <PyObject*>object_pairs_hook
|
94
|
-
ctx.user.has_pairs_hook = True
|
95
|
-
|
96
|
-
if list_hook is not None:
|
97
|
-
if not PyCallable_Check(list_hook):
|
98
|
-
raise TypeError("list_hook must be a callable.")
|
99
|
-
ctx.user.list_hook = <PyObject*>list_hook
|
100
|
-
|
101
|
-
if ext_hook is not None:
|
102
|
-
if not PyCallable_Check(ext_hook):
|
103
|
-
raise TypeError("ext_hook must be a callable.")
|
104
|
-
ctx.user.ext_hook = <PyObject*>ext_hook
|
105
|
-
|
106
|
-
if timestamp < 0 or 3 < timestamp:
|
107
|
-
raise ValueError("timestamp must be 0..3")
|
108
|
-
|
109
|
-
# Add Timestamp type to the user object so it may be used in unpack.h
|
110
|
-
ctx.user.timestamp = timestamp
|
111
|
-
ctx.user.timestamp_t = <PyObject*>Timestamp
|
112
|
-
ctx.user.giga = <PyObject*>giga
|
113
|
-
ctx.user.utc = <PyObject*>utc
|
114
|
-
ctx.user.unicode_errors = unicode_errors
|
115
|
-
|
116
|
-
def default_read_extended_type(typecode, data):
|
117
|
-
raise NotImplementedError("Cannot decode extended type with typecode=%d" % typecode)
|
118
|
-
|
119
|
-
cdef inline int get_data_from_buffer(object obj,
|
120
|
-
Py_buffer *view,
|
121
|
-
char **buf,
|
122
|
-
Py_ssize_t *buffer_len) except 0:
|
123
|
-
cdef object contiguous
|
124
|
-
cdef Py_buffer tmp
|
125
|
-
if PyObject_GetBuffer(obj, view, PyBUF_FULL_RO) == -1:
|
126
|
-
raise
|
127
|
-
if view.itemsize != 1:
|
128
|
-
PyBuffer_Release(view)
|
129
|
-
raise BufferError("cannot unpack from multi-byte object")
|
130
|
-
if PyBuffer_IsContiguous(view, b'A') == 0:
|
131
|
-
PyBuffer_Release(view)
|
132
|
-
# create a contiguous copy and get buffer
|
133
|
-
contiguous = PyMemoryView_GetContiguous(obj, PyBUF_READ, b'C')
|
134
|
-
PyObject_GetBuffer(contiguous, view, PyBUF_SIMPLE)
|
135
|
-
# view must hold the only reference to contiguous,
|
136
|
-
# so memory is freed when view is released
|
137
|
-
Py_DECREF(contiguous)
|
138
|
-
buffer_len[0] = view.len
|
139
|
-
buf[0] = <char*> view.buf
|
140
|
-
return 1
|
141
|
-
|
142
|
-
|
143
|
-
def unpackb(object packed, *, object object_hook=None, object list_hook=None,
|
144
|
-
bint use_list=True, bint raw=False, int timestamp=0, bint strict_map_key=True,
|
145
|
-
unicode_errors=None,
|
146
|
-
object_pairs_hook=None, ext_hook=ExtType,
|
147
|
-
Py_ssize_t max_str_len=-1,
|
148
|
-
Py_ssize_t max_bin_len=-1,
|
149
|
-
Py_ssize_t max_array_len=-1,
|
150
|
-
Py_ssize_t max_map_len=-1,
|
151
|
-
Py_ssize_t max_ext_len=-1):
|
152
|
-
"""
|
153
|
-
Unpack packed_bytes to object. Returns an unpacked object.
|
154
|
-
|
155
|
-
Raises ``ExtraData`` when *packed* contains extra bytes.
|
156
|
-
Raises ``ValueError`` when *packed* is incomplete.
|
157
|
-
Raises ``FormatError`` when *packed* is not valid msgpack.
|
158
|
-
Raises ``StackError`` when *packed* contains too nested.
|
159
|
-
Other exceptions can be raised during unpacking.
|
160
|
-
|
161
|
-
See :class:`Unpacker` for options.
|
162
|
-
|
163
|
-
*max_xxx_len* options are configured automatically from ``len(packed)``.
|
164
|
-
"""
|
165
|
-
cdef unpack_context ctx
|
166
|
-
cdef Py_ssize_t off = 0
|
167
|
-
cdef int ret
|
168
|
-
|
169
|
-
cdef Py_buffer view
|
170
|
-
cdef char* buf = NULL
|
171
|
-
cdef Py_ssize_t buf_len
|
172
|
-
cdef const char* cerr = NULL
|
173
|
-
|
174
|
-
if unicode_errors is not None:
|
175
|
-
cerr = unicode_errors
|
176
|
-
|
177
|
-
get_data_from_buffer(packed, &view, &buf, &buf_len)
|
178
|
-
|
179
|
-
if max_str_len == -1:
|
180
|
-
max_str_len = buf_len
|
181
|
-
if max_bin_len == -1:
|
182
|
-
max_bin_len = buf_len
|
183
|
-
if max_array_len == -1:
|
184
|
-
max_array_len = buf_len
|
185
|
-
if max_map_len == -1:
|
186
|
-
max_map_len = buf_len//2
|
187
|
-
if max_ext_len == -1:
|
188
|
-
max_ext_len = buf_len
|
189
|
-
|
190
|
-
try:
|
191
|
-
init_ctx(&ctx, object_hook, object_pairs_hook, list_hook, ext_hook,
|
192
|
-
use_list, raw, timestamp, strict_map_key, cerr,
|
193
|
-
max_str_len, max_bin_len, max_array_len, max_map_len, max_ext_len)
|
194
|
-
ret = unpack_construct(&ctx, buf, buf_len, &off)
|
195
|
-
finally:
|
196
|
-
PyBuffer_Release(&view);
|
197
|
-
|
198
|
-
if ret == 1:
|
199
|
-
obj = unpack_data(&ctx)
|
200
|
-
if off < buf_len:
|
201
|
-
raise ExtraData(obj, PyBytes_FromStringAndSize(buf+off, buf_len-off))
|
202
|
-
return obj
|
203
|
-
unpack_clear(&ctx)
|
204
|
-
if ret == 0:
|
205
|
-
raise ValueError("Unpack failed: incomplete input")
|
206
|
-
elif ret == -2:
|
207
|
-
raise FormatError
|
208
|
-
elif ret == -3:
|
209
|
-
raise StackError
|
210
|
-
raise ValueError("Unpack failed: error = %d" % (ret,))
|
211
|
-
|
212
|
-
|
213
|
-
cdef class Unpacker(object):
|
214
|
-
"""Streaming unpacker.
|
215
|
-
|
216
|
-
Arguments:
|
217
|
-
|
218
|
-
:param file_like:
|
219
|
-
File-like object having `.read(n)` method.
|
220
|
-
If specified, unpacker reads serialized data from it and `.feed()` is not usable.
|
221
|
-
|
222
|
-
:param int read_size:
|
223
|
-
Used as `file_like.read(read_size)`. (default: `min(16*1024, max_buffer_size)`)
|
224
|
-
|
225
|
-
:param bool use_list:
|
226
|
-
If true, unpack msgpack array to Python list.
|
227
|
-
Otherwise, unpack to Python tuple. (default: True)
|
228
|
-
|
229
|
-
:param bool raw:
|
230
|
-
If true, unpack msgpack raw to Python bytes.
|
231
|
-
Otherwise, unpack to Python str by decoding with UTF-8 encoding (default).
|
232
|
-
|
233
|
-
:param int timestamp:
|
234
|
-
Control how timestamp type is unpacked:
|
235
|
-
|
236
|
-
0 - Timestamp
|
237
|
-
1 - float (Seconds from the EPOCH)
|
238
|
-
2 - int (Nanoseconds from the EPOCH)
|
239
|
-
3 - datetime.datetime (UTC).
|
240
|
-
|
241
|
-
:param bool strict_map_key:
|
242
|
-
If true (default), only str or bytes are accepted for map (dict) keys.
|
243
|
-
|
244
|
-
:param object_hook:
|
245
|
-
When specified, it should be callable.
|
246
|
-
Unpacker calls it with a dict argument after unpacking msgpack map.
|
247
|
-
(See also simplejson)
|
248
|
-
|
249
|
-
:param object_pairs_hook:
|
250
|
-
When specified, it should be callable.
|
251
|
-
Unpacker calls it with a list of key-value pairs after unpacking msgpack map.
|
252
|
-
(See also simplejson)
|
253
|
-
|
254
|
-
:param str unicode_errors:
|
255
|
-
The error handler for decoding unicode. (default: 'strict')
|
256
|
-
This option should be used only when you have msgpack data which
|
257
|
-
contains invalid UTF-8 string.
|
258
|
-
|
259
|
-
:param int max_buffer_size:
|
260
|
-
Limits size of data waiting unpacked. 0 means 2**32-1.
|
261
|
-
The default value is 100*1024*1024 (100MiB).
|
262
|
-
Raises `BufferFull` exception when it is insufficient.
|
263
|
-
You should set this parameter when unpacking data from untrusted source.
|
264
|
-
|
265
|
-
:param int max_str_len:
|
266
|
-
Deprecated, use *max_buffer_size* instead.
|
267
|
-
Limits max length of str. (default: max_buffer_size)
|
268
|
-
|
269
|
-
:param int max_bin_len:
|
270
|
-
Deprecated, use *max_buffer_size* instead.
|
271
|
-
Limits max length of bin. (default: max_buffer_size)
|
272
|
-
|
273
|
-
:param int max_array_len:
|
274
|
-
Limits max length of array.
|
275
|
-
(default: max_buffer_size)
|
276
|
-
|
277
|
-
:param int max_map_len:
|
278
|
-
Limits max length of map.
|
279
|
-
(default: max_buffer_size//2)
|
280
|
-
|
281
|
-
:param int max_ext_len:
|
282
|
-
Deprecated, use *max_buffer_size* instead.
|
283
|
-
Limits max size of ext type. (default: max_buffer_size)
|
284
|
-
|
285
|
-
Example of streaming deserialize from file-like object::
|
286
|
-
|
287
|
-
unpacker = Unpacker(file_like)
|
288
|
-
for o in unpacker:
|
289
|
-
process(o)
|
290
|
-
|
291
|
-
Example of streaming deserialize from socket::
|
292
|
-
|
293
|
-
unpacker = Unpacker()
|
294
|
-
while True:
|
295
|
-
buf = sock.recv(1024**2)
|
296
|
-
if not buf:
|
297
|
-
break
|
298
|
-
unpacker.feed(buf)
|
299
|
-
for o in unpacker:
|
300
|
-
process(o)
|
301
|
-
|
302
|
-
Raises ``ExtraData`` when *packed* contains extra bytes.
|
303
|
-
Raises ``OutOfData`` when *packed* is incomplete.
|
304
|
-
Raises ``FormatError`` when *packed* is not valid msgpack.
|
305
|
-
Raises ``StackError`` when *packed* contains too nested.
|
306
|
-
Other exceptions can be raised during unpacking.
|
307
|
-
"""
|
308
|
-
cdef unpack_context ctx
|
309
|
-
cdef char* buf
|
310
|
-
cdef Py_ssize_t buf_size, buf_head, buf_tail
|
311
|
-
cdef object file_like
|
312
|
-
cdef object file_like_read
|
313
|
-
cdef Py_ssize_t read_size
|
314
|
-
# To maintain refcnt.
|
315
|
-
cdef object object_hook, object_pairs_hook, list_hook, ext_hook
|
316
|
-
cdef object unicode_errors
|
317
|
-
cdef Py_ssize_t max_buffer_size
|
318
|
-
cdef uint64_t stream_offset
|
319
|
-
|
320
|
-
def __cinit__(self):
|
321
|
-
self.buf = NULL
|
322
|
-
|
323
|
-
def __dealloc__(self):
|
324
|
-
PyMem_Free(self.buf)
|
325
|
-
self.buf = NULL
|
326
|
-
|
327
|
-
def __init__(self, file_like=None, *, Py_ssize_t read_size=0,
|
328
|
-
bint use_list=True, bint raw=False, int timestamp=0, bint strict_map_key=True,
|
329
|
-
object object_hook=None, object object_pairs_hook=None, object list_hook=None,
|
330
|
-
unicode_errors=None, Py_ssize_t max_buffer_size=100*1024*1024,
|
331
|
-
object ext_hook=ExtType,
|
332
|
-
Py_ssize_t max_str_len=-1,
|
333
|
-
Py_ssize_t max_bin_len=-1,
|
334
|
-
Py_ssize_t max_array_len=-1,
|
335
|
-
Py_ssize_t max_map_len=-1,
|
336
|
-
Py_ssize_t max_ext_len=-1):
|
337
|
-
cdef const char *cerr=NULL
|
338
|
-
|
339
|
-
self.object_hook = object_hook
|
340
|
-
self.object_pairs_hook = object_pairs_hook
|
341
|
-
self.list_hook = list_hook
|
342
|
-
self.ext_hook = ext_hook
|
343
|
-
|
344
|
-
self.file_like = file_like
|
345
|
-
if file_like:
|
346
|
-
self.file_like_read = file_like.read
|
347
|
-
if not PyCallable_Check(self.file_like_read):
|
348
|
-
raise TypeError("`file_like.read` must be a callable.")
|
349
|
-
|
350
|
-
if not max_buffer_size:
|
351
|
-
max_buffer_size = INT_MAX
|
352
|
-
if max_str_len == -1:
|
353
|
-
max_str_len = max_buffer_size
|
354
|
-
if max_bin_len == -1:
|
355
|
-
max_bin_len = max_buffer_size
|
356
|
-
if max_array_len == -1:
|
357
|
-
max_array_len = max_buffer_size
|
358
|
-
if max_map_len == -1:
|
359
|
-
max_map_len = max_buffer_size//2
|
360
|
-
if max_ext_len == -1:
|
361
|
-
max_ext_len = max_buffer_size
|
362
|
-
|
363
|
-
if read_size > max_buffer_size:
|
364
|
-
raise ValueError("read_size should be less or equal to max_buffer_size")
|
365
|
-
if not read_size:
|
366
|
-
read_size = min(max_buffer_size, 1024**2)
|
367
|
-
|
368
|
-
self.max_buffer_size = max_buffer_size
|
369
|
-
self.read_size = read_size
|
370
|
-
self.buf = <char*>PyMem_Malloc(read_size)
|
371
|
-
if self.buf == NULL:
|
372
|
-
raise MemoryError("Unable to allocate internal buffer.")
|
373
|
-
self.buf_size = read_size
|
374
|
-
self.buf_head = 0
|
375
|
-
self.buf_tail = 0
|
376
|
-
self.stream_offset = 0
|
377
|
-
|
378
|
-
if unicode_errors is not None:
|
379
|
-
self.unicode_errors = unicode_errors
|
380
|
-
cerr = unicode_errors
|
381
|
-
|
382
|
-
init_ctx(&self.ctx, object_hook, object_pairs_hook, list_hook,
|
383
|
-
ext_hook, use_list, raw, timestamp, strict_map_key, cerr,
|
384
|
-
max_str_len, max_bin_len, max_array_len,
|
385
|
-
max_map_len, max_ext_len)
|
386
|
-
|
387
|
-
def feed(self, object next_bytes):
|
388
|
-
"""Append `next_bytes` to internal buffer."""
|
389
|
-
cdef Py_buffer pybuff
|
390
|
-
cdef char* buf
|
391
|
-
cdef Py_ssize_t buf_len
|
392
|
-
|
393
|
-
if self.file_like is not None:
|
394
|
-
raise AssertionError(
|
395
|
-
"unpacker.feed() is not be able to use with `file_like`.")
|
396
|
-
|
397
|
-
get_data_from_buffer(next_bytes, &pybuff, &buf, &buf_len)
|
398
|
-
try:
|
399
|
-
self.append_buffer(buf, buf_len)
|
400
|
-
finally:
|
401
|
-
PyBuffer_Release(&pybuff)
|
402
|
-
|
403
|
-
cdef append_buffer(self, void* _buf, Py_ssize_t _buf_len):
|
404
|
-
cdef:
|
405
|
-
char* buf = self.buf
|
406
|
-
char* new_buf
|
407
|
-
Py_ssize_t head = self.buf_head
|
408
|
-
Py_ssize_t tail = self.buf_tail
|
409
|
-
Py_ssize_t buf_size = self.buf_size
|
410
|
-
Py_ssize_t new_size
|
411
|
-
|
412
|
-
if tail + _buf_len > buf_size:
|
413
|
-
if ((tail - head) + _buf_len) <= buf_size:
|
414
|
-
# move to front.
|
415
|
-
memmove(buf, buf + head, tail - head)
|
416
|
-
tail -= head
|
417
|
-
head = 0
|
418
|
-
else:
|
419
|
-
# expand buffer.
|
420
|
-
new_size = (tail-head) + _buf_len
|
421
|
-
if new_size > self.max_buffer_size:
|
422
|
-
raise BufferFull
|
423
|
-
new_size = min(new_size*2, self.max_buffer_size)
|
424
|
-
new_buf = <char*>PyMem_Malloc(new_size)
|
425
|
-
if new_buf == NULL:
|
426
|
-
# self.buf still holds old buffer and will be freed during
|
427
|
-
# obj destruction
|
428
|
-
raise MemoryError("Unable to enlarge internal buffer.")
|
429
|
-
memcpy(new_buf, buf + head, tail - head)
|
430
|
-
PyMem_Free(buf)
|
431
|
-
|
432
|
-
buf = new_buf
|
433
|
-
buf_size = new_size
|
434
|
-
tail -= head
|
435
|
-
head = 0
|
436
|
-
|
437
|
-
memcpy(buf + tail, <char*>(_buf), _buf_len)
|
438
|
-
self.buf = buf
|
439
|
-
self.buf_head = head
|
440
|
-
self.buf_size = buf_size
|
441
|
-
self.buf_tail = tail + _buf_len
|
442
|
-
|
443
|
-
cdef int read_from_file(self) except -1:
|
444
|
-
cdef Py_ssize_t remains = self.max_buffer_size - (self.buf_tail - self.buf_head)
|
445
|
-
if remains <= 0:
|
446
|
-
raise BufferFull
|
447
|
-
|
448
|
-
next_bytes = self.file_like_read(min(self.read_size, remains))
|
449
|
-
if next_bytes:
|
450
|
-
self.append_buffer(PyBytes_AsString(next_bytes), PyBytes_Size(next_bytes))
|
451
|
-
else:
|
452
|
-
self.file_like = None
|
453
|
-
return 0
|
454
|
-
|
455
|
-
cdef object _unpack(self, execute_fn execute, bint iter=0):
|
456
|
-
cdef int ret
|
457
|
-
cdef object obj
|
458
|
-
cdef Py_ssize_t prev_head
|
459
|
-
|
460
|
-
while 1:
|
461
|
-
prev_head = self.buf_head
|
462
|
-
if prev_head < self.buf_tail:
|
463
|
-
ret = execute(&self.ctx, self.buf, self.buf_tail, &self.buf_head)
|
464
|
-
self.stream_offset += self.buf_head - prev_head
|
465
|
-
else:
|
466
|
-
ret = 0
|
467
|
-
|
468
|
-
if ret == 1:
|
469
|
-
obj = unpack_data(&self.ctx)
|
470
|
-
unpack_init(&self.ctx)
|
471
|
-
return obj
|
472
|
-
elif ret == 0:
|
473
|
-
if self.file_like is not None:
|
474
|
-
self.read_from_file()
|
475
|
-
continue
|
476
|
-
if iter:
|
477
|
-
raise StopIteration("No more data to unpack.")
|
478
|
-
else:
|
479
|
-
raise OutOfData("No more data to unpack.")
|
480
|
-
elif ret == -2:
|
481
|
-
raise FormatError
|
482
|
-
elif ret == -3:
|
483
|
-
raise StackError
|
484
|
-
else:
|
485
|
-
raise ValueError("Unpack failed: error = %d" % (ret,))
|
486
|
-
|
487
|
-
def read_bytes(self, Py_ssize_t nbytes):
|
488
|
-
"""Read a specified number of raw bytes from the stream"""
|
489
|
-
cdef Py_ssize_t nread
|
490
|
-
nread = min(self.buf_tail - self.buf_head, nbytes)
|
491
|
-
ret = PyBytes_FromStringAndSize(self.buf + self.buf_head, nread)
|
492
|
-
self.buf_head += nread
|
493
|
-
if nread < nbytes and self.file_like is not None:
|
494
|
-
ret += self.file_like.read(nbytes - nread)
|
495
|
-
nread = len(ret)
|
496
|
-
self.stream_offset += nread
|
497
|
-
return ret
|
498
|
-
|
499
|
-
def unpack(self):
|
500
|
-
"""Unpack one object
|
501
|
-
|
502
|
-
Raises `OutOfData` when there are no more bytes to unpack.
|
503
|
-
"""
|
504
|
-
return self._unpack(unpack_construct)
|
505
|
-
|
506
|
-
def skip(self):
|
507
|
-
"""Read and ignore one object, returning None
|
508
|
-
|
509
|
-
Raises `OutOfData` when there are no more bytes to unpack.
|
510
|
-
"""
|
511
|
-
return self._unpack(unpack_skip)
|
512
|
-
|
513
|
-
def read_array_header(self):
|
514
|
-
"""assuming the next object is an array, return its size n, such that
|
515
|
-
the next n unpack() calls will iterate over its contents.
|
516
|
-
|
517
|
-
Raises `OutOfData` when there are no more bytes to unpack.
|
518
|
-
"""
|
519
|
-
return self._unpack(read_array_header)
|
520
|
-
|
521
|
-
def read_map_header(self):
|
522
|
-
"""assuming the next object is a map, return its size n, such that the
|
523
|
-
next n * 2 unpack() calls will iterate over its key-value pairs.
|
524
|
-
|
525
|
-
Raises `OutOfData` when there are no more bytes to unpack.
|
526
|
-
"""
|
527
|
-
return self._unpack(read_map_header)
|
528
|
-
|
529
|
-
def tell(self):
|
530
|
-
"""Returns the current position of the Unpacker in bytes, i.e., the
|
531
|
-
number of bytes that were read from the input, also the starting
|
532
|
-
position of the next object.
|
533
|
-
"""
|
534
|
-
return self.stream_offset
|
535
|
-
|
536
|
-
def __iter__(self):
|
537
|
-
return self
|
538
|
-
|
539
|
-
def __next__(self):
|
540
|
-
return self._unpack(unpack_construct, 1)
|
541
|
-
|
542
|
-
# for debug.
|
543
|
-
#def _buf(self):
|
544
|
-
# return PyString_FromStringAndSize(self.buf, self.buf_tail)
|
545
|
-
|
546
|
-
#def _off(self):
|
547
|
-
# return self.buf_head
|
@@ -1,48 +0,0 @@
|
|
1
|
-
class UnpackException(Exception):
|
2
|
-
"""Base class for some exceptions raised while unpacking.
|
3
|
-
|
4
|
-
NOTE: unpack may raise exception other than subclass of
|
5
|
-
UnpackException. If you want to catch all error, catch
|
6
|
-
Exception instead.
|
7
|
-
"""
|
8
|
-
|
9
|
-
|
10
|
-
class BufferFull(UnpackException):
|
11
|
-
pass
|
12
|
-
|
13
|
-
|
14
|
-
class OutOfData(UnpackException):
|
15
|
-
pass
|
16
|
-
|
17
|
-
|
18
|
-
class FormatError(ValueError, UnpackException):
|
19
|
-
"""Invalid msgpack format"""
|
20
|
-
|
21
|
-
|
22
|
-
class StackError(ValueError, UnpackException):
|
23
|
-
"""Too nested"""
|
24
|
-
|
25
|
-
|
26
|
-
# Deprecated. Use ValueError instead
|
27
|
-
UnpackValueError = ValueError
|
28
|
-
|
29
|
-
|
30
|
-
class ExtraData(UnpackValueError):
|
31
|
-
"""ExtraData is raised when there is trailing data.
|
32
|
-
|
33
|
-
This exception is raised while only one-shot (not streaming)
|
34
|
-
unpack.
|
35
|
-
"""
|
36
|
-
|
37
|
-
def __init__(self, unpacked, extra):
|
38
|
-
self.unpacked = unpacked
|
39
|
-
self.extra = extra
|
40
|
-
|
41
|
-
def __str__(self):
|
42
|
-
return "unpack(b) received extra data."
|
43
|
-
|
44
|
-
|
45
|
-
# Deprecated. Use Exception instead to catch all exception during packing.
|
46
|
-
PackException = Exception
|
47
|
-
PackValueError = ValueError
|
48
|
-
PackOverflowError = OverflowError
|