serializable 0.2.1__tar.gz → 0.4.0__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 (33) hide show
  1. serializable-0.4.0/LICENSE +201 -0
  2. serializable-0.4.0/PKG-INFO +44 -0
  3. {serializable-0.2.1 → serializable-0.4.0}/README.md +11 -7
  4. {serializable-0.2.1 → serializable-0.4.0}/serializable/__init__.py +1 -2
  5. {serializable-0.2.1 → serializable-0.4.0}/serializable/helpers.py +2 -13
  6. {serializable-0.2.1 → serializable-0.4.0}/serializable/primitive_types.py +1 -4
  7. serializable-0.4.0/serializable.egg-info/PKG-INFO +44 -0
  8. {serializable-0.2.1 → serializable-0.4.0}/serializable.egg-info/SOURCES.txt +11 -10
  9. {serializable-0.2.1 → serializable-0.4.0}/serializable.egg-info/requires.txt +0 -1
  10. {serializable-0.2.1 → serializable-0.4.0}/setup.py +0 -4
  11. serializable-0.4.0/tests/test_class.py +30 -0
  12. serializable-0.4.0/tests/test_default_to_dict_implementation.py +24 -0
  13. serializable-0.4.0/tests/test_function.py +30 -0
  14. {serializable-0.2.1/test → serializable-0.4.0/tests}/test_keyword_aliases.py +14 -1
  15. serializable-0.4.0/tests/test_namedtuple.py +22 -0
  16. {serializable-0.2.1/test → serializable-0.4.0/tests}/test_nesting.py +1 -1
  17. {serializable-0.2.1/test → serializable-0.4.0/tests}/test_object.py +13 -1
  18. serializable-0.4.0/tests/test_primitive_values.py +29 -0
  19. serializable-0.4.0/tests/test_set.py +27 -0
  20. serializable-0.4.0/tests/test_tuple.py +27 -0
  21. serializable-0.2.1/PKG-INFO +0 -38
  22. serializable-0.2.1/serializable.egg-info/PKG-INFO +0 -38
  23. serializable-0.2.1/test/test_class.py +0 -17
  24. serializable-0.2.1/test/test_default_to_dict_implementation.py +0 -11
  25. serializable-0.2.1/test/test_function.py +0 -17
  26. serializable-0.2.1/test/test_namedtuple.py +0 -10
  27. serializable-0.2.1/test/test_primitive_values.py +0 -17
  28. serializable-0.2.1/test/test_set.py +0 -15
  29. serializable-0.2.1/test/test_tuple.py +0 -15
  30. {serializable-0.2.1 → serializable-0.4.0}/serializable/serializable.py +0 -0
  31. {serializable-0.2.1 → serializable-0.4.0}/serializable.egg-info/dependency_links.txt +0 -0
  32. {serializable-0.2.1 → serializable-0.4.0}/serializable.egg-info/top_level.txt +0 -0
  33. {serializable-0.2.1 → serializable-0.4.0}/setup.cfg +0 -0
@@ -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.
@@ -0,0 +1,44 @@
1
+ Metadata-Version: 2.1
2
+ Name: serializable
3
+ Version: 0.4.0
4
+ Summary: Base class with serialization helpers for user-defined Python objects
5
+ Home-page: https://github.com/iskandr/serializable
6
+ Author: Alex Rubinsteyn
7
+ Author-email: alex@openvax.org
8
+ License: http://www.apache.org/licenses/LICENSE-2.0.html
9
+ Classifier: Development Status :: 3 - Alpha
10
+ Classifier: Environment :: Console
11
+ Classifier: Operating System :: OS Independent
12
+ Classifier: License :: OSI Approved :: Apache Software License
13
+ Classifier: Programming Language :: Python
14
+ Description-Content-Type: text/markdown
15
+ License-File: LICENSE
16
+ Requires-Dist: typechecks>=0.0.2
17
+ Requires-Dist: simplejson
18
+
19
+ [![Tests](https://github.com/openvax/serializable/actions/workflows/tests.yml/badge.svg)](https://github.com/openvax/serializable/actions/workflows/tests.yml)
20
+ <a href="https://pypi.python.org/pypi/serializable/">
21
+ <img src="https://img.shields.io/pypi/v/serializable.svg?maxAge=1000" alt="PyPI" />
22
+ </a>
23
+ # serializable
24
+
25
+ Base class with serialization methods for user-defined Python objects
26
+
27
+ ## Usage
28
+
29
+ Classes which inherit from `Serializable` are enabled with default implementations of
30
+ `to_json`, `from_json`, `__reduce__` (for pickling), and other serialization
31
+ helpers.
32
+
33
+ A derived class must either:
34
+
35
+ - have a member data matching the name of each argument to `__init__`
36
+ - provide a user-defined `to_dict()` method which returns a dictionary whose keys match the arguments to `__init__`
37
+
38
+ If you change the keyword arguments to a class which derives from `Serializable` but would like to be able to deserialize older JSON representations then you can define a class-level dictionary called `_KEYWORD_ALIASES` which maps old keywords to new names (or `None` if a keyword was removed).
39
+
40
+ ## Limitations
41
+
42
+ - Serializable objects must inherit from `Serializable`, be tuples or namedtuples, be serializble primitive types such as dict, list, int, float, or str.
43
+
44
+ - The serialized representation of objects relies on reserved keywords (such as `"__name__"`, and `"__class__"`), so dictionaries are expected to not contain any keys which begin with two underscores.
@@ -1,22 +1,26 @@
1
- [![Build Status](https://travis-ci.org/iskandr/serializable.svg?branch=master)](https://travis-ci.org/iskandr/serializable)
2
-
1
+ [![Tests](https://github.com/openvax/serializable/actions/workflows/tests.yml/badge.svg)](https://github.com/openvax/serializable/actions/workflows/tests.yml)
2
+ <a href="https://pypi.python.org/pypi/serializable/">
3
+ <img src="https://img.shields.io/pypi/v/serializable.svg?maxAge=1000" alt="PyPI" />
4
+ </a>
3
5
  # serializable
6
+
4
7
  Base class with serialization methods for user-defined Python objects
5
8
 
6
9
  ## Usage
10
+
7
11
  Classes which inherit from `Serializable` are enabled with default implementations of
8
12
  `to_json`, `from_json`, `__reduce__` (for pickling), and other serialization
9
- helpers.
13
+ helpers.
10
14
 
11
15
  A derived class must either:
12
16
 
13
- * have a member data matching the name of each argument to `__init__`
14
- * provide a user-defined `to_dict()` method which returns a dictionary whose keys match the arguments to `__init__`
17
+ - have a member data matching the name of each argument to `__init__`
18
+ - provide a user-defined `to_dict()` method which returns a dictionary whose keys match the arguments to `__init__`
15
19
 
16
20
  If you change the keyword arguments to a class which derives from `Serializable` but would like to be able to deserialize older JSON representations then you can define a class-level dictionary called `_KEYWORD_ALIASES` which maps old keywords to new names (or `None` if a keyword was removed).
17
21
 
18
22
  ## Limitations
19
23
 
20
- * Serializable objects must inherit from `Serializable`, be tuples or namedtuples, be serializble primitive types such as dict, list, int, float, or str.
24
+ - Serializable objects must inherit from `Serializable`, be tuples or namedtuples, be serializble primitive types such as dict, list, int, float, or str.
21
25
 
22
- * The serialized representation of objects relies on reserved keywords (such as `"__name__"`, and `"__class__"`), so dictionaries are expected to not contain any keys which begin with two underscores.
26
+ - The serialized representation of objects relies on reserved keywords (such as `"__name__"`, and `"__class__"`), so dictionaries are expected to not contain any keys which begin with two underscores.
@@ -10,7 +10,6 @@
10
10
  # See the License for the specific language governing permissions and
11
11
  # limitations under the License.
12
12
 
13
- from __future__ import print_function, division, absolute_import
14
13
 
15
14
  from .serializable import Serializable
16
15
  from .helpers import (
@@ -21,7 +20,7 @@ from .helpers import (
21
20
  to_dict,
22
21
  )
23
22
 
24
- __version__ = "0.2.1"
23
+ __version__ = "0.4.0"
25
24
 
26
25
  __all__ = [
27
26
  "Serializable",
@@ -14,11 +14,9 @@
14
14
  Helper functions for deconstructing classes, functions, and user-defined
15
15
  objects into serializable types.
16
16
  """
17
- from __future__ import print_function, division, absolute_import
18
17
  from types import FunctionType, BuiltinFunctionType
19
18
 
20
19
  import simplejson as json
21
- from six import string_types, PY2, PY3
22
20
 
23
21
  from .primitive_types import return_primitive
24
22
 
@@ -56,12 +54,6 @@ def _lookup_value(module_string, name, _cache={}):
56
54
  value = _cache[key]
57
55
  else:
58
56
  module_parts = module_string.split(".")
59
- # assuming that only JSON serialization from old Python2 runs
60
- # of serialization would generate __builtin__ as a module
61
- # name
62
-
63
- if PY3 and module_parts[0] == "__builtin__":
64
- module_parts = ["six", "moves", "builtins"] + module_parts[1:]
65
57
  value = None
66
58
  for i in range(1, len(module_parts) + 1):
67
59
  try:
@@ -94,10 +86,7 @@ def class_from_serializable_representation(class_repr):
94
86
 
95
87
  def get_module_name(obj):
96
88
  module_name = obj.__module__
97
- if PY2 and module_name == "__builtin__":
98
- return "six.moves.builtins"
99
- else:
100
- return module_name
89
+ return module_name
101
90
 
102
91
  def class_to_serializable_representation(cls):
103
92
  """
@@ -165,7 +154,7 @@ def dict_to_serializable_repr(x):
165
154
  # derived classes such as OrderedDict
166
155
  result = type(x)()
167
156
  for (k, v) in x.items():
168
- if not isinstance(k, string_types):
157
+ if not isinstance(k, str):
169
158
  # JSON does not support using complex types such as tuples
170
159
  # or user-defined objects with implementations of __hash__ as
171
160
  # keys in a dictionary so we must keep the serialized
@@ -14,14 +14,11 @@
14
14
  A type is considered "primitive" if it is a non-collection type which can
15
15
  be serialized and deserialized successfully.
16
16
  """
17
- from __future__ import print_function, division, absolute_import
18
-
19
17
  from functools import wraps
20
- from six import string_types, integer_types
21
18
 
22
19
  NoneType = type(None)
23
20
 
24
- PRIMITIVE_TYPES = (bool, float, NoneType) + string_types + integer_types
21
+ PRIMITIVE_TYPES = (bool, float, NoneType, str, int)
25
22
 
26
23
  def return_primitive(fn):
27
24
  """
@@ -0,0 +1,44 @@
1
+ Metadata-Version: 2.1
2
+ Name: serializable
3
+ Version: 0.4.0
4
+ Summary: Base class with serialization helpers for user-defined Python objects
5
+ Home-page: https://github.com/iskandr/serializable
6
+ Author: Alex Rubinsteyn
7
+ Author-email: alex@openvax.org
8
+ License: http://www.apache.org/licenses/LICENSE-2.0.html
9
+ Classifier: Development Status :: 3 - Alpha
10
+ Classifier: Environment :: Console
11
+ Classifier: Operating System :: OS Independent
12
+ Classifier: License :: OSI Approved :: Apache Software License
13
+ Classifier: Programming Language :: Python
14
+ Description-Content-Type: text/markdown
15
+ License-File: LICENSE
16
+ Requires-Dist: typechecks>=0.0.2
17
+ Requires-Dist: simplejson
18
+
19
+ [![Tests](https://github.com/openvax/serializable/actions/workflows/tests.yml/badge.svg)](https://github.com/openvax/serializable/actions/workflows/tests.yml)
20
+ <a href="https://pypi.python.org/pypi/serializable/">
21
+ <img src="https://img.shields.io/pypi/v/serializable.svg?maxAge=1000" alt="PyPI" />
22
+ </a>
23
+ # serializable
24
+
25
+ Base class with serialization methods for user-defined Python objects
26
+
27
+ ## Usage
28
+
29
+ Classes which inherit from `Serializable` are enabled with default implementations of
30
+ `to_json`, `from_json`, `__reduce__` (for pickling), and other serialization
31
+ helpers.
32
+
33
+ A derived class must either:
34
+
35
+ - have a member data matching the name of each argument to `__init__`
36
+ - provide a user-defined `to_dict()` method which returns a dictionary whose keys match the arguments to `__init__`
37
+
38
+ If you change the keyword arguments to a class which derives from `Serializable` but would like to be able to deserialize older JSON representations then you can define a class-level dictionary called `_KEYWORD_ALIASES` which maps old keywords to new names (or `None` if a keyword was removed).
39
+
40
+ ## Limitations
41
+
42
+ - Serializable objects must inherit from `Serializable`, be tuples or namedtuples, be serializble primitive types such as dict, list, int, float, or str.
43
+
44
+ - The serialized representation of objects relies on reserved keywords (such as `"__name__"`, and `"__class__"`), so dictionaries are expected to not contain any keys which begin with two underscores.
@@ -1,3 +1,4 @@
1
+ LICENSE
1
2
  README.md
2
3
  setup.py
3
4
  serializable/__init__.py
@@ -9,13 +10,13 @@ serializable.egg-info/SOURCES.txt
9
10
  serializable.egg-info/dependency_links.txt
10
11
  serializable.egg-info/requires.txt
11
12
  serializable.egg-info/top_level.txt
12
- test/test_class.py
13
- test/test_default_to_dict_implementation.py
14
- test/test_function.py
15
- test/test_keyword_aliases.py
16
- test/test_namedtuple.py
17
- test/test_nesting.py
18
- test/test_object.py
19
- test/test_primitive_values.py
20
- test/test_set.py
21
- test/test_tuple.py
13
+ tests/test_class.py
14
+ tests/test_default_to_dict_implementation.py
15
+ tests/test_function.py
16
+ tests/test_keyword_aliases.py
17
+ tests/test_namedtuple.py
18
+ tests/test_nesting.py
19
+ tests/test_object.py
20
+ tests/test_primitive_values.py
21
+ tests/test_set.py
22
+ tests/test_tuple.py
@@ -1,3 +1,2 @@
1
1
  typechecks>=0.0.2
2
- six>=1.9.0
3
2
  simplejson
@@ -1,5 +1,3 @@
1
- # Copyright (c) 2014-2019. Mount Sinai School of Medicine
2
- #
3
1
  # Licensed under the Apache License, Version 2.0 (the "License");
4
2
  # you may not use this file except in compliance with the License.
5
3
  # You may obtain a copy of the License at
@@ -12,7 +10,6 @@
12
10
  # See the License for the specific language governing permissions and
13
11
  # limitations under the License.
14
12
 
15
- from __future__ import print_function
16
13
  import os
17
14
  import re
18
15
 
@@ -57,7 +54,6 @@ if __name__ == '__main__':
57
54
  ],
58
55
  install_requires=[
59
56
  "typechecks>=0.0.2",
60
- "six>=1.9.0",
61
57
  "simplejson",
62
58
  ],
63
59
  long_description=readme,
@@ -0,0 +1,30 @@
1
+ # Licensed under the Apache License, Version 2.0 (the "License");
2
+ # you may not use this file except in compliance with the License.
3
+ # You may obtain a copy of the License at
4
+ #
5
+ # http://www.apache.org/licenses/LICENSE-2.0
6
+ #
7
+ # Unless required by applicable law or agreed to in writing, software
8
+ # distributed under the License is distributed on an "AS IS" BASIS,
9
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10
+ # See the License for the specific language governing permissions and
11
+ # limitations under the License.
12
+
13
+
14
+ from serializable import (
15
+ from_serializable_repr,
16
+ to_serializable_repr
17
+ )
18
+ from .common import eq_
19
+
20
+ class A(object):
21
+ pass
22
+
23
+ def test_serialize_custom_class():
24
+ A_reconstructed = from_serializable_repr(to_serializable_repr(A))
25
+ eq_(A, A_reconstructed)
26
+
27
+
28
+ def test_serialize_builtin_class():
29
+ int_reconstructed = from_serializable_repr(to_serializable_repr(int))
30
+ eq_(int, int_reconstructed)
@@ -0,0 +1,24 @@
1
+ # Licensed under the Apache License, Version 2.0 (the "License");
2
+ # you may not use this file except in compliance with the License.
3
+ # You may obtain a copy of the License at
4
+ #
5
+ # http://www.apache.org/licenses/LICENSE-2.0
6
+ #
7
+ # Unless required by applicable law or agreed to in writing, software
8
+ # distributed under the License is distributed on an "AS IS" BASIS,
9
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10
+ # See the License for the specific language governing permissions and
11
+ # limitations under the License.
12
+
13
+
14
+ from serializable import Serializable
15
+ from .common import eq_
16
+
17
+ class A(Serializable):
18
+ def __init__(self, x, y=1):
19
+ self.x = x
20
+ self.y = y
21
+
22
+ def test_serializable_default_to_dict():
23
+ a = A(10, 1)
24
+ eq_(a, A.from_dict(a.to_dict()))
@@ -0,0 +1,30 @@
1
+ # Licensed under the Apache License, Version 2.0 (the "License");
2
+ # you may not use this file except in compliance with the License.
3
+ # You may obtain a copy of the License at
4
+ #
5
+ # http://www.apache.org/licenses/LICENSE-2.0
6
+ #
7
+ # Unless required by applicable law or agreed to in writing, software
8
+ # distributed under the License is distributed on an "AS IS" BASIS,
9
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10
+ # See the License for the specific language governing permissions and
11
+ # limitations under the License.
12
+
13
+
14
+ from serializable import (
15
+ to_serializable_repr,
16
+ from_serializable_repr,
17
+ )
18
+ from .common import eq_
19
+
20
+ def global_fn():
21
+ pass
22
+
23
+ def test_serialize_custom_function():
24
+ fn_reconstructed = from_serializable_repr(to_serializable_repr(global_fn))
25
+ eq_(global_fn, fn_reconstructed)
26
+
27
+
28
+ def test_serialize_builtin_function():
29
+ fn_reconstructed = from_serializable_repr(to_serializable_repr(sum))
30
+ eq_(sum, fn_reconstructed)
@@ -1,5 +1,18 @@
1
+ # Licensed under the Apache License, Version 2.0 (the "License");
2
+ # you may not use this file except in compliance with the License.
3
+ # You may obtain a copy of the License at
4
+ #
5
+ # http://www.apache.org/licenses/LICENSE-2.0
6
+ #
7
+ # Unless required by applicable law or agreed to in writing, software
8
+ # distributed under the License is distributed on an "AS IS" BASIS,
9
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10
+ # See the License for the specific language governing permissions and
11
+ # limitations under the License.
12
+
13
+
1
14
  from serializable import Serializable
2
- from nose.tools import eq_
15
+ from .common import eq_
3
16
 
4
17
  class TestClassWithKeywordAliases(Serializable):
5
18
  _SERIALIZABLE_KEYWORD_ALIASES = {"old_x": "x", "old_gone": None}
@@ -0,0 +1,22 @@
1
+ # Licensed under the Apache License, Version 2.0 (the "License");
2
+ # you may not use this file except in compliance with the License.
3
+ # You may obtain a copy of the License at
4
+ #
5
+ # http://www.apache.org/licenses/LICENSE-2.0
6
+ #
7
+ # Unless required by applicable law or agreed to in writing, software
8
+ # distributed under the License is distributed on an "AS IS" BASIS,
9
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10
+ # See the License for the specific language governing permissions and
11
+ # limitations under the License.
12
+
13
+ from collections import namedtuple
14
+ from serializable import to_serializable_repr, from_serializable_repr
15
+ from .common import eq_
16
+
17
+ A = namedtuple("A", "x y")
18
+
19
+ instance = A(1, 2)
20
+
21
+ def test_namedtuple_to_json():
22
+ eq_(instance, from_serializable_repr(to_serializable_repr(instance)))
@@ -1,5 +1,5 @@
1
1
  from serializable import to_serializable_repr, from_serializable_repr, Serializable
2
- from nose.tools import eq_
2
+ from .common import eq_
3
3
 
4
4
  class A(Serializable):
5
5
  def __init__(self, a_val):
@@ -1,9 +1,21 @@
1
+ # Licensed under the Apache License, Version 2.0 (the "License");
2
+ # you may not use this file except in compliance with the License.
3
+ # You may obtain a copy of the License at
4
+ #
5
+ # http://www.apache.org/licenses/LICENSE-2.0
6
+ #
7
+ # Unless required by applicable law or agreed to in writing, software
8
+ # distributed under the License is distributed on an "AS IS" BASIS,
9
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10
+ # See the License for the specific language governing permissions and
11
+ # limitations under the License.
12
+
1
13
  from serializable import (
2
14
  from_serializable_repr,
3
15
  to_serializable_repr,
4
16
  Serializable,
5
17
  )
6
- from nose.tools import eq_
18
+ from .common import eq_
7
19
  import pickle
8
20
 
9
21
  class A(Serializable):
@@ -0,0 +1,29 @@
1
+ # Licensed under the Apache License, Version 2.0 (the "License");
2
+ # you may not use this file except in compliance with the License.
3
+ # You may obtain a copy of the License at
4
+ #
5
+ # http://www.apache.org/licenses/LICENSE-2.0
6
+ #
7
+ # Unless required by applicable law or agreed to in writing, software
8
+ # distributed under the License is distributed on an "AS IS" BASIS,
9
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10
+ # See the License for the specific language governing permissions and
11
+ # limitations under the License.
12
+
13
+ from serializable import (
14
+ from_serializable_repr,
15
+ to_serializable_repr
16
+ )
17
+ from .common import eq_
18
+
19
+ def test_int():
20
+ eq_(1, from_serializable_repr(to_serializable_repr(1)))
21
+
22
+ def test_float():
23
+ eq_(1.4, from_serializable_repr(to_serializable_repr(1.4)))
24
+
25
+ def test_bool():
26
+ eq_(False, from_serializable_repr(to_serializable_repr(False)))
27
+
28
+ def test_str():
29
+ eq_("waffles", from_serializable_repr(to_serializable_repr("waffles")))
@@ -0,0 +1,27 @@
1
+ # Licensed under the Apache License, Version 2.0 (the "License");
2
+ # you may not use this file except in compliance with the License.
3
+ # You may obtain a copy of the License at
4
+ #
5
+ # http://www.apache.org/licenses/LICENSE-2.0
6
+ #
7
+ # Unless required by applicable law or agreed to in writing, software
8
+ # distributed under the License is distributed on an "AS IS" BASIS,
9
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10
+ # See the License for the specific language governing permissions and
11
+ # limitations under the License.
12
+
13
+ from serializable import (
14
+ to_serializable_repr,
15
+ from_serializable_repr,
16
+ to_json,
17
+ from_json,
18
+ )
19
+ from .common import eq_
20
+
21
+ def test_tuple_to_serializable():
22
+ x = {1, 2.0, "wolves"}
23
+ eq_(x, from_serializable_repr(to_serializable_repr(x)))
24
+
25
+ def test_tuple_to_json():
26
+ x = {1, 2.0, "wolves"}
27
+ eq_(x, from_json(to_json(x)))
@@ -0,0 +1,27 @@
1
+ # Licensed under the Apache License, Version 2.0 (the "License");
2
+ # you may not use this file except in compliance with the License.
3
+ # You may obtain a copy of the License at
4
+ #
5
+ # http://www.apache.org/licenses/LICENSE-2.0
6
+ #
7
+ # Unless required by applicable law or agreed to in writing, software
8
+ # distributed under the License is distributed on an "AS IS" BASIS,
9
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10
+ # See the License for the specific language governing permissions and
11
+ # limitations under the License.
12
+
13
+ from serializable import (
14
+ to_serializable_repr,
15
+ from_serializable_repr,
16
+ to_json,
17
+ from_json,
18
+ )
19
+ from .common import eq_
20
+
21
+ def test_tuple_to_serializable():
22
+ x = (1, 2.0, "wolves")
23
+ eq_(x, from_serializable_repr(to_serializable_repr(x)))
24
+
25
+ def test_tuple_to_json():
26
+ x = (1, 2.0, "wolves")
27
+ eq_(x, from_json(to_json(x)))
@@ -1,38 +0,0 @@
1
- Metadata-Version: 2.1
2
- Name: serializable
3
- Version: 0.2.1
4
- Summary: Base class with serialization helpers for user-defined Python objects
5
- Home-page: https://github.com/iskandr/serializable
6
- Author: Alex Rubinsteyn
7
- Author-email: alex@openvax.org
8
- License: http://www.apache.org/licenses/LICENSE-2.0.html
9
- Description: [![Build Status](https://travis-ci.org/iskandr/serializable.svg?branch=master)](https://travis-ci.org/iskandr/serializable)
10
-
11
- # serializable
12
- Base class with serialization methods for user-defined Python objects
13
-
14
- ## Usage
15
- Classes which inherit from `Serializable` are enabled with default implementations of
16
- `to_json`, `from_json`, `__reduce__` (for pickling), and other serialization
17
- helpers.
18
-
19
- A derived class must either:
20
-
21
- * have a member data matching the name of each argument to `__init__`
22
- * provide a user-defined `to_dict()` method which returns a dictionary whose keys match the arguments to `__init__`
23
-
24
- If you change the keyword arguments to a class which derives from `Serializable` but would like to be able to deserialize older JSON representations then you can define a class-level dictionary called `_KEYWORD_ALIASES` which maps old keywords to new names (or `None` if a keyword was removed).
25
-
26
- ## Limitations
27
-
28
- * Serializable objects must inherit from `Serializable`, be tuples or namedtuples, be serializble primitive types such as dict, list, int, float, or str.
29
-
30
- * The serialized representation of objects relies on reserved keywords (such as `"__name__"`, and `"__class__"`), so dictionaries are expected to not contain any keys which begin with two underscores.
31
-
32
- Platform: UNKNOWN
33
- Classifier: Development Status :: 3 - Alpha
34
- Classifier: Environment :: Console
35
- Classifier: Operating System :: OS Independent
36
- Classifier: License :: OSI Approved :: Apache Software License
37
- Classifier: Programming Language :: Python
38
- Description-Content-Type: text/markdown
@@ -1,38 +0,0 @@
1
- Metadata-Version: 2.1
2
- Name: serializable
3
- Version: 0.2.1
4
- Summary: Base class with serialization helpers for user-defined Python objects
5
- Home-page: https://github.com/iskandr/serializable
6
- Author: Alex Rubinsteyn
7
- Author-email: alex@openvax.org
8
- License: http://www.apache.org/licenses/LICENSE-2.0.html
9
- Description: [![Build Status](https://travis-ci.org/iskandr/serializable.svg?branch=master)](https://travis-ci.org/iskandr/serializable)
10
-
11
- # serializable
12
- Base class with serialization methods for user-defined Python objects
13
-
14
- ## Usage
15
- Classes which inherit from `Serializable` are enabled with default implementations of
16
- `to_json`, `from_json`, `__reduce__` (for pickling), and other serialization
17
- helpers.
18
-
19
- A derived class must either:
20
-
21
- * have a member data matching the name of each argument to `__init__`
22
- * provide a user-defined `to_dict()` method which returns a dictionary whose keys match the arguments to `__init__`
23
-
24
- If you change the keyword arguments to a class which derives from `Serializable` but would like to be able to deserialize older JSON representations then you can define a class-level dictionary called `_KEYWORD_ALIASES` which maps old keywords to new names (or `None` if a keyword was removed).
25
-
26
- ## Limitations
27
-
28
- * Serializable objects must inherit from `Serializable`, be tuples or namedtuples, be serializble primitive types such as dict, list, int, float, or str.
29
-
30
- * The serialized representation of objects relies on reserved keywords (such as `"__name__"`, and `"__class__"`), so dictionaries are expected to not contain any keys which begin with two underscores.
31
-
32
- Platform: UNKNOWN
33
- Classifier: Development Status :: 3 - Alpha
34
- Classifier: Environment :: Console
35
- Classifier: Operating System :: OS Independent
36
- Classifier: License :: OSI Approved :: Apache Software License
37
- Classifier: Programming Language :: Python
38
- Description-Content-Type: text/markdown
@@ -1,17 +0,0 @@
1
- from serializable import (
2
- from_serializable_repr,
3
- to_serializable_repr
4
- )
5
- from nose.tools import eq_
6
-
7
- class A(object):
8
- pass
9
-
10
- def test_serialize_custom_class():
11
- A_reconstructed = from_serializable_repr(to_serializable_repr(A))
12
- eq_(A, A_reconstructed)
13
-
14
-
15
- def test_serialize_builtin_class():
16
- int_reconstructed = from_serializable_repr(to_serializable_repr(int))
17
- eq_(int, int_reconstructed)
@@ -1,11 +0,0 @@
1
- from serializable import Serializable
2
- from nose.tools import eq_
3
-
4
- class A(Serializable):
5
- def __init__(self, x, y=1):
6
- self.x = x
7
- self.y = y
8
-
9
- def test_serializable_default_to_dict():
10
- a = A(10, 1)
11
- eq_(a, A.from_dict(a.to_dict()))
@@ -1,17 +0,0 @@
1
- from serializable import (
2
- to_serializable_repr,
3
- from_serializable_repr,
4
- )
5
- from nose.tools import eq_
6
-
7
- def global_fn():
8
- pass
9
-
10
- def test_serialize_custom_function():
11
- fn_reconstructed = from_serializable_repr(to_serializable_repr(global_fn))
12
- eq_(global_fn, fn_reconstructed)
13
-
14
-
15
- def test_serialize_builtin_function():
16
- fn_reconstructed = from_serializable_repr(to_serializable_repr(sum))
17
- eq_(sum, fn_reconstructed)
@@ -1,10 +0,0 @@
1
- from collections import namedtuple
2
- from serializable import to_serializable_repr, from_serializable_repr
3
- from nose.tools import eq_
4
-
5
- A = namedtuple("A", "x y")
6
-
7
- instance = A(1, 2)
8
-
9
- def test_namedtuple_to_json():
10
- eq_(instance, from_serializable_repr(to_serializable_repr(instance)))
@@ -1,17 +0,0 @@
1
- from serializable import (
2
- from_serializable_repr,
3
- to_serializable_repr
4
- )
5
- from nose.tools import eq_
6
-
7
- def test_int():
8
- eq_(1, from_serializable_repr(to_serializable_repr(1)))
9
-
10
- def test_float():
11
- eq_(1.4, from_serializable_repr(to_serializable_repr(1.4)))
12
-
13
- def test_bool():
14
- eq_(False, from_serializable_repr(to_serializable_repr(False)))
15
-
16
- def test_str():
17
- eq_("waffles", from_serializable_repr(to_serializable_repr("waffles")))
@@ -1,15 +0,0 @@
1
- from serializable import (
2
- to_serializable_repr,
3
- from_serializable_repr,
4
- to_json,
5
- from_json,
6
- )
7
- from nose.tools import eq_
8
-
9
- def test_tuple_to_serializable():
10
- x = {1, 2.0, "wolves"}
11
- eq_(x, from_serializable_repr(to_serializable_repr(x)))
12
-
13
- def test_tuple_to_json():
14
- x = {1, 2.0, "wolves"}
15
- eq_(x, from_json(to_json(x)))
@@ -1,15 +0,0 @@
1
- from serializable import (
2
- to_serializable_repr,
3
- from_serializable_repr,
4
- to_json,
5
- from_json,
6
- )
7
- from nose.tools import eq_
8
-
9
- def test_tuple_to_serializable():
10
- x = (1, 2.0, "wolves")
11
- eq_(x, from_serializable_repr(to_serializable_repr(x)))
12
-
13
- def test_tuple_to_json():
14
- x = (1, 2.0, "wolves")
15
- eq_(x, from_json(to_json(x)))
File without changes