tmsgpack 0.1.2__tar.gz → 0.1.4__tar.gz

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.
Files changed (44) hide show
  1. tmsgpack-0.1.4/COPYING +2 -0
  2. tmsgpack-0.1.4/LICENSE +201 -0
  3. {tmsgpack-0.1.2/tmsgpack.egg-info → tmsgpack-0.1.4}/PKG-INFO +7 -5
  4. {tmsgpack-0.1.2 → tmsgpack-0.1.4}/README.md +2 -1
  5. {tmsgpack-0.1.2 → tmsgpack-0.1.4}/setup.cfg +3 -3
  6. {tmsgpack-0.1.2 → tmsgpack-0.1.4}/test/contexts_for_tests.py +5 -5
  7. {tmsgpack-0.1.2 → tmsgpack-0.1.4}/test/test_memoryview.py +1 -1
  8. {tmsgpack-0.1.2 → tmsgpack-0.1.4}/test/test_trace_from_x.py +5 -5
  9. {tmsgpack-0.1.2 → tmsgpack-0.1.4}/test/test_typed_objects.py +5 -5
  10. tmsgpack-0.1.4/tmsgpack/__init__.py +121 -0
  11. {tmsgpack-0.1.2 → tmsgpack-0.1.4}/tmsgpack/_ctmsgpack.cpp +1 -1
  12. {tmsgpack-0.1.2 → tmsgpack-0.1.4}/tmsgpack/_unpacker.pyx +1 -1
  13. {tmsgpack-0.1.2 → tmsgpack-0.1.4}/tmsgpack/fallback.py +1 -1
  14. {tmsgpack-0.1.2 → tmsgpack-0.1.4/tmsgpack.egg-info}/PKG-INFO +7 -5
  15. {tmsgpack-0.1.2 → tmsgpack-0.1.4}/tmsgpack.egg-info/SOURCES.txt +1 -0
  16. tmsgpack-0.1.2/COPYING +0 -14
  17. tmsgpack-0.1.2/tmsgpack/__init__.py +0 -131
  18. {tmsgpack-0.1.2 → tmsgpack-0.1.4}/MANIFEST.in +0 -0
  19. {tmsgpack-0.1.2 → tmsgpack-0.1.4}/pyproject.toml +0 -0
  20. {tmsgpack-0.1.2 → tmsgpack-0.1.4}/setup.py +0 -0
  21. {tmsgpack-0.1.2 → tmsgpack-0.1.4}/test/test_buffer.py +0 -0
  22. {tmsgpack-0.1.2 → tmsgpack-0.1.4}/test/test_case.py +0 -0
  23. {tmsgpack-0.1.2 → tmsgpack-0.1.4}/test/test_except.py +0 -0
  24. {tmsgpack-0.1.2 → tmsgpack-0.1.4}/test/test_format.py +0 -0
  25. {tmsgpack-0.1.2 → tmsgpack-0.1.4}/test/test_limits.py +0 -0
  26. {tmsgpack-0.1.2 → tmsgpack-0.1.4}/test/test_newspec.py +0 -0
  27. {tmsgpack-0.1.2 → tmsgpack-0.1.4}/test/test_pack.py +0 -0
  28. {tmsgpack-0.1.2 → tmsgpack-0.1.4}/test/test_roundtrip.py +0 -0
  29. {tmsgpack-0.1.2 → tmsgpack-0.1.4}/test/test_seq.py +0 -0
  30. {tmsgpack-0.1.2 → tmsgpack-0.1.4}/test/test_sequnpack.py +0 -0
  31. {tmsgpack-0.1.2 → tmsgpack-0.1.4}/test/test_subtype.py +0 -0
  32. {tmsgpack-0.1.2 → tmsgpack-0.1.4}/test/test_unpack.py +0 -0
  33. {tmsgpack-0.1.2 → tmsgpack-0.1.4}/tmsgpack/_ctmsgpack.pyx +0 -0
  34. {tmsgpack-0.1.2 → tmsgpack-0.1.4}/tmsgpack/_packer.pyx +0 -0
  35. {tmsgpack-0.1.2 → tmsgpack-0.1.4}/tmsgpack/buff_converter.h +0 -0
  36. {tmsgpack-0.1.2 → tmsgpack-0.1.4}/tmsgpack/exceptions.py +0 -0
  37. {tmsgpack-0.1.2 → tmsgpack-0.1.4}/tmsgpack/pack.h +0 -0
  38. {tmsgpack-0.1.2 → tmsgpack-0.1.4}/tmsgpack/pack_template.h +0 -0
  39. {tmsgpack-0.1.2 → tmsgpack-0.1.4}/tmsgpack/sysdep.h +0 -0
  40. {tmsgpack-0.1.2 → tmsgpack-0.1.4}/tmsgpack/unpack.h +0 -0
  41. {tmsgpack-0.1.2 → tmsgpack-0.1.4}/tmsgpack/unpack_define.h +0 -0
  42. {tmsgpack-0.1.2 → tmsgpack-0.1.4}/tmsgpack/unpack_template.h +0 -0
  43. {tmsgpack-0.1.2 → tmsgpack-0.1.4}/tmsgpack.egg-info/dependency_links.txt +0 -0
  44. {tmsgpack-0.1.2 → tmsgpack-0.1.4}/tmsgpack.egg-info/top_level.txt +0 -0
tmsgpack-0.1.4/COPYING ADDED
@@ -0,0 +1,2 @@
1
+ Copyright (C) 2025 Yaakov Belch <yaakov.belch@gmail.com>
2
+ Licensed under the Apache License, Version 2.0. See LICENSE file for details.
tmsgpack-0.1.4/LICENSE ADDED
@@ -0,0 +1,201 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright [yyyy] [name of copyright owner]
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
@@ -1,13 +1,13 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: tmsgpack
3
- Version: 0.1.2
3
+ Version: 0.1.4
4
4
  Summary: Typed MessagePack serializer (similar but incompatible with msgpack)
5
- Home-page: https://github.com/Yaakov-Belch/tmsgpack
5
+ Home-page: https://github.com/Yaakov-Belch/tmsgpack-py
6
6
  Author: Inada Naoki, Yaakov Belch
7
7
  Author-email: yaakov.belch@gmail.com
8
8
  License: Apache-2.0
9
- Project-URL: Source, https://github.com/Yaakov-Belch/tmsgpack
10
- Project-URL: Tracker, https://github.com/Yaakov-Belch/tmsgpack/issues
9
+ Project-URL: Source, https://github.com/Yaakov-Belch/tmsgpack-py
10
+ Project-URL: Tracker, https://github.com/Yaakov-Belch/tmsgpack-py/issues
11
11
  Classifier: Programming Language :: Python :: 3
12
12
  Classifier: Programming Language :: Python :: 3.9
13
13
  Classifier: Programming Language :: Python :: 3.10
@@ -19,12 +19,14 @@ Classifier: Programming Language :: Python :: Implementation :: CPython
19
19
  Classifier: Programming Language :: Python :: Implementation :: PyPy
20
20
  Classifier: Intended Audience :: Developers
21
21
  Description-Content-Type: text/markdown
22
+ License-File: LICENSE
22
23
  License-File: COPYING
23
24
  Dynamic: license-file
24
25
 
25
26
  # tmsgpack: Typed MessagePack-inspired pack/unpack component
26
27
 
27
- See also: [FORMAT.md](FORMAT.md) and [DEVELOP.md](DEVELOP.md)
28
+ See also: [FORMAT.md](FORMAT.md), [DEVELOP.md](DEVELOP.md)
29
+ [tmsgpack-js](https://github.com/Yaakov-Belch/tmsgpack-js)
28
30
 
29
31
  The tmsgpack format expresses **typed objects**: maps and arrays (or: dicts and
30
32
  tuples/lists) with an `object_type` property.
@@ -1,6 +1,7 @@
1
1
  # tmsgpack: Typed MessagePack-inspired pack/unpack component
2
2
 
3
- See also: [FORMAT.md](FORMAT.md) and [DEVELOP.md](DEVELOP.md)
3
+ See also: [FORMAT.md](FORMAT.md), [DEVELOP.md](DEVELOP.md)
4
+ [tmsgpack-js](https://github.com/Yaakov-Belch/tmsgpack-js)
4
5
 
5
6
  The tmsgpack format expresses **typed objects**: maps and arrays (or: dicts and
6
7
  tuples/lists) with an `object_type` property.
@@ -7,11 +7,11 @@ author_email = yaakov.belch@gmail.com
7
7
  description = Typed MessagePack serializer (similar but incompatible with msgpack)
8
8
  long_description = file: README.md
9
9
  long_description_content_type = text/markdown
10
- url = https://github.com/Yaakov-Belch/tmsgpack
10
+ url = https://github.com/Yaakov-Belch/tmsgpack-py
11
11
  python_requires = >=3.9
12
12
  project_urls =
13
- Source = https://github.com/Yaakov-Belch/tmsgpack
14
- Tracker = https://github.com/Yaakov-Belch/tmsgpack/issues
13
+ Source = https://github.com/Yaakov-Belch/tmsgpack-py
14
+ Tracker = https://github.com/Yaakov-Belch/tmsgpack-py/issues
15
15
  classifiers =
16
16
  Programming Language :: Python :: 3
17
17
  Programming Language :: Python :: 3.9
@@ -1,11 +1,11 @@
1
- from tmsgpack import PackConfig, UnpackConfig
1
+ from tmsgpack import PackOptions, UnpackOptions
2
2
  from dataclasses import dataclass
3
3
 
4
4
  @dataclass
5
5
  class TestPackCtrl:
6
6
  def from_obj(self, obj):
7
7
  raise TypeError(f'Cannot serialize {type(obj)} object.')
8
- options: PackConfig
8
+ options: PackOptions
9
9
 
10
10
  @dataclass
11
11
  class TestUnpackCtrl:
@@ -13,7 +13,7 @@ class TestUnpackCtrl:
13
13
  raise ValueError(f'Unpack type not supported: {ctype} data: {dct}')
14
14
  def from_tuple(self, ctype, lst):
15
15
  raise ValueError(f'Unpack type not supported: {ctype} data: {lst}')
16
- options: UnpackConfig
16
+ options: UnpackOptions
17
17
 
18
- def pctrl(**kwargs): return TestPackCtrl(options=PackConfig(**kwargs))
19
- def uctrl(**kwargs): return TestUnpackCtrl(options=UnpackConfig(**kwargs))
18
+ def pctrl(**kwargs): return TestPackCtrl(options=PackOptions(**kwargs))
19
+ def uctrl(**kwargs): return TestUnpackCtrl(options=UnpackOptions(**kwargs))
@@ -65,7 +65,7 @@ def test_bin32_from_float():
65
65
 
66
66
 
67
67
  def test_multidim_memoryview():
68
- # See https://github.com/tmsgpack/tmsgpack-python/issues/526
68
+ # See https://github.com/msgpack/msgpack-python/issues/526
69
69
  view = memoryview(b"\00" * 6)
70
70
  data = view.cast(view.format, (3, 2))
71
71
  packed = packb(data, pack_ctrl=pctrl())
@@ -1,5 +1,5 @@
1
1
  from contexts_for_tests import pctrl, uctrl
2
- from tmsgpack import packb, unpackb, PackConfig, UnpackConfig
2
+ from tmsgpack import packb, unpackb, PackOptions, UnpackOptions
3
3
  from pytest import raises
4
4
  from dataclasses import dataclass, is_dataclass, fields
5
5
 
@@ -21,17 +21,17 @@ class PackTracer:
21
21
  for field in fields(obj)
22
22
  ]
23
23
  return as_dict, object_type, data
24
- options: PackConfig
24
+ options: PackOptions
25
25
 
26
26
  @dataclass
27
27
  class UnpackTracer:
28
28
  def from_dict(self, ctype, dct): return ['dict', ctype, dct]
29
29
  def from_tuple(self, ctype, lst): return ['list', ctype, lst]
30
- options: UnpackConfig
30
+ options: UnpackOptions
31
31
 
32
32
 
33
- def pt(**kwargs): return PackTracer(options=PackConfig(**kwargs))
34
- def ut(**kwargs): return UnpackTracer(options=UnpackConfig(**kwargs))
33
+ def pt(**kwargs): return PackTracer(options=PackOptions(**kwargs))
34
+ def ut(**kwargs): return UnpackTracer(options=UnpackOptions(**kwargs))
35
35
 
36
36
  def run(input, expected, sort_keys=False):
37
37
  packed = packb(input, pack_ctrl=pt(sort_keys=sort_keys))
@@ -1,4 +1,4 @@
1
- from tmsgpack import packb, unpackb, PackConfig, UnpackConfig
1
+ from tmsgpack import packb, unpackb, PackOptions, UnpackOptions
2
2
  from dataclasses import dataclass, is_dataclass, fields
3
3
  from typing import Dict
4
4
 
@@ -20,7 +20,7 @@ class TypedPackCtrl:
20
20
  for field in fields(obj)
21
21
  ]
22
22
  return as_dict, object_type, data
23
- options: PackConfig
23
+ options: PackOptions
24
24
 
25
25
  def pack(self, data):
26
26
  return packb(data, pack_ctrl=self)
@@ -30,16 +30,16 @@ class TypedUnpackCtrl:
30
30
  constructors: Dict[str, callable]
31
31
  def from_dict(self, ctype, data): return self.constructors[ctype](**data)
32
32
  def from_tuple(self, ctype, data): return self.constructors[ctype]( *data)
33
- options: UnpackConfig
33
+ options: UnpackOptions
34
34
 
35
35
  def unpack(self, packed):
36
36
  return unpackb(packed, unpack_ctrl=self)
37
37
 
38
- def pc(**kwargs): return TypedPackCtrl(options=PackConfig(**kwargs))
38
+ def pc(**kwargs): return TypedPackCtrl(options=PackOptions(**kwargs))
39
39
  def uc(fns, **kwargs):
40
40
  return TypedUnpackCtrl(
41
41
  constructors={fn.__name__:fn for fn in fns},
42
- options=UnpackConfig(**kwargs),
42
+ options=UnpackOptions(**kwargs),
43
43
  )
44
44
 
45
45
  @dataclass
@@ -0,0 +1,121 @@
1
+ from .exceptions import *
2
+ import os
3
+ import sys
4
+ from dataclasses import dataclass
5
+
6
+ version = (0, 1, 4)
7
+ __version__ = "0.1.4"
8
+
9
+
10
+ @dataclass
11
+ class PackOptions:
12
+ """
13
+ Config object for pack_ctrl.options
14
+ """
15
+
16
+ # If true, pack dicts, tuples, lists without calling from_obj(...).
17
+ # Object types: {...} => None; (...) => None; [...] => False
18
+ p_shortcuts: bool = True
19
+
20
+ # Sort output dictionaries by key.
21
+ sort_keys: bool = False
22
+
23
+ # If true, accept only strings as dict keys.
24
+ p_str_keys: bool = False
25
+
26
+ # Use single precision float type for float.
27
+ use_single_float: bool = False
28
+
29
+ def _packb(self, data, pack_ctrl): return packb(data, pack_ctrl=pack_ctrl)
30
+
31
+ @dataclass
32
+ class UnpackOptions:
33
+ """
34
+ Config object for unpack_ctrl.options
35
+ """
36
+
37
+ # If true, unpack dicts, tuples, lists without calling from_dict/list(...)
38
+ # Object types: None => {...}/(...), False => [...]
39
+ u_shortcuts: bool = True
40
+
41
+ # If true, accept only strings as dict keys.
42
+ u_str_keys: bool = False
43
+
44
+ # Used as `file_like.read(read_size)`.
45
+ read_size: int = 16*1024
46
+
47
+ # Limits size of data waiting unpacked.
48
+ # Raises `BufferFull` exception when it is insufficient.
49
+ # You should set this parameter when unpacking data from untrusted source.
50
+ max_buffer_size: int = 0 # 0 means: 2**32-1
51
+
52
+ # Limits max length of str. (default: max_buffer_size)
53
+ max_str_len: int = -1 # -1 means max_buffer_size
54
+
55
+ # Limits max length of bin.
56
+ max_bin_len: int = -1 # -1 means max_buffer_size
57
+
58
+ # Limits max length of list.
59
+ max_list_len: int = -1 # -1 means max_buffer_size
60
+
61
+ # Limits max length of dict.
62
+ max_dict_len: int = -1 # -1 means max_buffer_size//2
63
+
64
+
65
+ def __post_init__(self): self._init_unpack_config()
66
+
67
+ def _init_unpack_config(self):
68
+ if self.max_buffer_size == 0: self.max_buffer_size = 2**32-1
69
+ self.read_size = min(self.read_size, self.max_buffer_size)
70
+
71
+ if self.max_str_len == -1: self.max_str_len = self.max_buffer_size
72
+ if self.max_bin_len == -1: self.max_bin_len = self.max_buffer_size
73
+ if self.max_list_len == -1: self.max_list_len = self.max_buffer_size
74
+ if self.max_dict_len == -1: self.max_dict_len = self.max_buffer_size//2
75
+
76
+ def _unpackb(self, data, unpack_ctrl): return unpackb(data, unpack_ctrl=unpack_ctrl)
77
+
78
+ @dataclass
79
+ class PackUnpackOptions(PackOptions, UnpackOptions):
80
+ def __post_init__(self): self._init_unpack_config()
81
+
82
+
83
+ if os.environ.get("TMSGPACK_PUREPYTHON"):
84
+ from .fallback import Packer, unpackb, Unpacker
85
+ else:
86
+ try:
87
+ from ._ctmsgpack import Packer, unpackb, Unpacker
88
+ except ImportError:
89
+ from .fallback import Packer, unpackb, Unpacker
90
+
91
+
92
+ def pack(o, stream, pack_ctrl):
93
+ """
94
+ Pack object `o` and write it to `stream`
95
+
96
+ See :class:`PackOptions`.
97
+ """
98
+ packer = Packer(pack_ctrl=pack_ctrl)
99
+ stream.write(packer.pack(o))
100
+
101
+
102
+ def packb(o, pack_ctrl):
103
+ """
104
+ Pack object `o` and return packed bytes
105
+
106
+ See :class:`PackOptions`.
107
+ """
108
+ return Packer(pack_ctrl=pack_ctrl).pack(o)
109
+
110
+
111
+ def unpack(stream, unpack_ctrl):
112
+ """
113
+ Unpack an object from `stream`.
114
+
115
+ Raises `ExtraData` when `stream` contains extra bytes.
116
+ See :class:`UnpackOptions`.
117
+ """
118
+ data = stream.read()
119
+ return unpackb(data, unpack_ctrl=unpack_ctrl)
120
+
121
+
@@ -8448,7 +8448,7 @@ PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds
8448
8448
  PyObject *__pyx_args, PyObject *__pyx_kwds
8449
8449
  #endif
8450
8450
  ); /*proto*/
8451
- PyDoc_STRVAR(__pyx_doc_8tmsgpack_10_ctmsgpack_unpackb, "unpackb(packed, *, unpack_ctrl=None)\n\n Unpack packed_bytes to object. Returns an unpacked object.\n\n Raises ``ExtraData`` when *packed* contains extra bytes.\n Raises ``ValueError`` when *packed* is incomplete.\n Raises ``FormatError`` when *packed* is not valid tmsgpack.\n Raises ``StackError`` when *packed* contains too nested.\n Other exceptions can be raised during unpacking.\n\n See :class:`Unpacker` for options.\n\n *max_xxx_len* options are configured automatically from ``len(packed)``.\n ");
8451
+ PyDoc_STRVAR(__pyx_doc_8tmsgpack_10_ctmsgpack_unpackb, "unpackb(packed, *, unpack_ctrl=None)\n\n Unpack packed_bytes to object. Returns an unpacked object.\n\n Raises ``ExtraData`` when *packed* contains extra bytes.\n Raises ``ValueError`` when *packed* is incomplete.\n Raises ``FormatError`` when *packed* is not valid tmsgpack.\n Raises ``StackError`` when *packed* contains too nested.\n Other exceptions can be raised during unpacking.\n\n See :class:`UnpackOptions`.\n\n *max_xxx_len* options are configured automatically from ``len(packed)``.\n ");
8452
8452
  static PyMethodDef __pyx_mdef_8tmsgpack_10_ctmsgpack_1unpackb = {"unpackb", (PyCFunction)(void*)(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_8tmsgpack_10_ctmsgpack_1unpackb, __Pyx_METH_FASTCALL|METH_KEYWORDS, __pyx_doc_8tmsgpack_10_ctmsgpack_unpackb};
8453
8453
  static PyObject *__pyx_pw_8tmsgpack_10_ctmsgpack_1unpackb(PyObject *__pyx_self,
8454
8454
  #if CYTHON_METH_FASTCALL
@@ -98,7 +98,7 @@ def unpackb(object packed, *, object unpack_ctrl=None):
98
98
  Raises ``StackError`` when *packed* contains too nested.
99
99
  Other exceptions can be raised during unpacking.
100
100
 
101
- See :class:`Unpacker` for options.
101
+ See :class:`UnpackOptions`.
102
102
 
103
103
  *max_xxx_len* options are configured automatically from ``len(packed)``.
104
104
  """
@@ -66,7 +66,7 @@ def unpackb(packed, *, unpack_ctrl):
66
66
  Raises ``StackError`` when *packed* contains too nested.
67
67
  Other exceptions can be raised during unpacking.
68
68
 
69
- See :class:`Unpacker` for options.
69
+ See :class:`UnpackOptions`.
70
70
  """
71
71
  unpacker = Unpacker(None, unpack_ctrl=unpack_ctrl, buffer_size=len(packed))
72
72
  unpacker.feed(packed)
@@ -1,13 +1,13 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: tmsgpack
3
- Version: 0.1.2
3
+ Version: 0.1.4
4
4
  Summary: Typed MessagePack serializer (similar but incompatible with msgpack)
5
- Home-page: https://github.com/Yaakov-Belch/tmsgpack
5
+ Home-page: https://github.com/Yaakov-Belch/tmsgpack-py
6
6
  Author: Inada Naoki, Yaakov Belch
7
7
  Author-email: yaakov.belch@gmail.com
8
8
  License: Apache-2.0
9
- Project-URL: Source, https://github.com/Yaakov-Belch/tmsgpack
10
- Project-URL: Tracker, https://github.com/Yaakov-Belch/tmsgpack/issues
9
+ Project-URL: Source, https://github.com/Yaakov-Belch/tmsgpack-py
10
+ Project-URL: Tracker, https://github.com/Yaakov-Belch/tmsgpack-py/issues
11
11
  Classifier: Programming Language :: Python :: 3
12
12
  Classifier: Programming Language :: Python :: 3.9
13
13
  Classifier: Programming Language :: Python :: 3.10
@@ -19,12 +19,14 @@ Classifier: Programming Language :: Python :: Implementation :: CPython
19
19
  Classifier: Programming Language :: Python :: Implementation :: PyPy
20
20
  Classifier: Intended Audience :: Developers
21
21
  Description-Content-Type: text/markdown
22
+ License-File: LICENSE
22
23
  License-File: COPYING
23
24
  Dynamic: license-file
24
25
 
25
26
  # tmsgpack: Typed MessagePack-inspired pack/unpack component
26
27
 
27
- See also: [FORMAT.md](FORMAT.md) and [DEVELOP.md](DEVELOP.md)
28
+ See also: [FORMAT.md](FORMAT.md), [DEVELOP.md](DEVELOP.md)
29
+ [tmsgpack-js](https://github.com/Yaakov-Belch/tmsgpack-js)
28
30
 
29
31
  The tmsgpack format expresses **typed objects**: maps and arrays (or: dicts and
30
32
  tuples/lists) with an `object_type` property.
@@ -1,4 +1,5 @@
1
1
  COPYING
2
+ LICENSE
2
3
  MANIFEST.in
3
4
  README.md
4
5
  pyproject.toml
tmsgpack-0.1.2/COPYING DELETED
@@ -1,14 +0,0 @@
1
- Copyright (C) 2025 Yaakov Belch <yaakov.belch@gmail.com>
2
-
3
- Licensed under the Apache License, Version 2.0 (the "License");
4
- you may not use this file except in compliance with the License.
5
- You may obtain a copy of the License at
6
-
7
- http://www.apache.org/licenses/LICENSE-2.0
8
-
9
- Unless required by applicable law or agreed to in writing, software
10
- distributed under the License is distributed on an "AS IS" BASIS,
11
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
- See the License for the specific language governing permissions and
13
- limitations under the License.
14
-
@@ -1,131 +0,0 @@
1
- from .exceptions import *
2
- import os
3
- import sys
4
-
5
-
6
- version = (0, 1, 2)
7
- __version__ = "0.1.2"
8
-
9
-
10
- class PackConfig:
11
- """
12
- Config object for pack_ctrl.options
13
-
14
- :param bool p_shortcuts:
15
- If true, pack dicts, tuples, lists without calling from_obj(...).
16
- Object types: {...} => None; (...) => None; [...] => False
17
- (default: True)
18
-
19
- :param bool sort_keys:
20
- Sort output dictionaries by key. (default: False)
21
-
22
- :param bool p_str_keys:
23
- If true, accept only strings as dict keys. (default: False)
24
-
25
- :param bool use_single_float:
26
- Use single precision float type for float. (default: False)
27
- """
28
-
29
- def __init__(self, p_shortcuts=True, sort_keys=False, p_str_keys=False,
30
- use_single_float=False):
31
- self.p_shortcuts = p_shortcuts
32
- self.sort_keys = sort_keys
33
- self.p_str_keys = p_str_keys
34
- self.use_single_float = use_single_float
35
-
36
- class UnpackConfig:
37
- """
38
- Config object for unpack_ctrl.options
39
-
40
- :param bool u_shortcuts:
41
- If true, unpack dicts, tuples, lists without calling from_dict/list(...)
42
- Object types: None => {...}/(...), False => [...]
43
- (default: True)
44
-
45
- :param bool u_str_keys:
46
- If true, accept only strings as dict keys. (default: False)
47
-
48
- :param int read_size:
49
- Used as `file_like.read(read_size)`. (default: `min(16*1024, max_buffer_size)`)
50
-
51
- :param int max_buffer_size:
52
- (default: 100*1024*1024 (100MiB))
53
- Limits size of data waiting unpacked. 0 means 2**32-1.
54
- Raises `BufferFull` exception when it is insufficient.
55
- You should set this parameter when unpacking data from untrusted source.
56
-
57
- :param int max_str_len:
58
- Limits max length of str. (default: max_buffer_size)
59
-
60
- :param int max_bin_len:
61
- Limits max length of bin. (default: max_buffer_size)
62
-
63
- :param int max_list_len:
64
- Limits max length of list.
65
- (default: max_buffer_size)
66
-
67
- :param int max_dict_len:
68
- Limits max length of dict.
69
- (default: max_buffer_size//2)
70
- """
71
-
72
- def __init__(self, u_shortcuts=True, u_str_keys=False,
73
- read_size=16*1024, max_buffer_size=0,
74
- max_str_len=-1, max_bin_len=-1, max_list_len=-1, max_dict_len=-1):
75
- self.u_shortcuts = u_shortcuts
76
- self.u_str_keys = u_str_keys
77
-
78
- if max_buffer_size == 0: max_buffer_size = 2**32-1
79
- self.max_buffer_size = max_buffer_size
80
- self.read_size = min(read_size, max_buffer_size)
81
-
82
- if max_str_len == -1: max_str_len = max_buffer_size
83
- if max_bin_len == -1: max_bin_len = max_buffer_size
84
- if max_list_len == -1: max_list_len = max_buffer_size
85
- if max_dict_len == -1: max_dict_len = max_buffer_size//2
86
-
87
- self.max_str_len = max_str_len
88
- self.max_bin_len = max_bin_len
89
- self.max_list_len = max_list_len
90
- self.max_dict_len = max_dict_len
91
-
92
-
93
- if os.environ.get("TMSGPACK_PUREPYTHON"):
94
- from .fallback import Packer, unpackb, Unpacker
95
- else:
96
- try:
97
- from ._ctmsgpack import Packer, unpackb, Unpacker
98
- except ImportError:
99
- from .fallback import Packer, unpackb, Unpacker
100
-
101
-
102
- def pack(o, stream, pack_ctrl):
103
- """
104
- Pack object `o` and write it to `stream`
105
-
106
- See :class:`Packer` for options.
107
- """
108
- packer = Packer(pack_ctrl=pack_ctrl)
109
- stream.write(packer.pack(o))
110
-
111
-
112
- def packb(o, pack_ctrl):
113
- """
114
- Pack object `o` and return packed bytes
115
-
116
- See :class:`Packer` for options.
117
- """
118
- return Packer(pack_ctrl=pack_ctrl).pack(o)
119
-
120
-
121
- def unpack(stream, unpack_ctrl):
122
- """
123
- Unpack an object from `stream`.
124
-
125
- Raises `ExtraData` when `stream` contains extra bytes.
126
- See :class:`Unpacker` for options.
127
- """
128
- data = stream.read()
129
- return unpackb(data, unpack_ctrl=unpack_ctrl)
130
-
131
-
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes