polymerist.genutils.fileutils.jsonio
Utilities for extending the Python-JSON interface
Submodules
Attributes
Classes
For type-hinting classes which are jsonifiable |
|
Interface for defining how types which are not JSON serializable by default should be encoded and decoded |
|
For dynamically merging multiple TypeSerializer encoders and decoders |
|
For JSON-serializing OpenMM Quantities |
|
For JSON-serializing OpenMM Quantities |
|
Dict subclass which also updates an underlying JSON file - effectively and on-disc dict |
Functions
|
Modify a dataclass to make its attributes writeable-to and readable-from JSON files |
|
Add an entry to an existing JSON file |
Package Contents
- class polymerist.genutils.fileutils.jsonio.JSONifiable[source]
For type-hinting classes which are jsonifiable
- polymerist.genutils.fileutils.jsonio.make_jsonifiable(cls: C | None = None, type_serializer: polymerist.genutils.fileutils.jsonio.serialize.TypeSerializer | polymerist.genutils.fileutils.jsonio.serialize.MultiTypeSerializer | None = None) C[source]
Modify a dataclass to make its attributes writeable-to and readable-from JSON files Can optionally specify additional TypeSerializers to support objects with attributes whose types are, by default, not JSON-serializable
- polymerist.genutils.fileutils.jsonio.JSONSerializable
- class polymerist.genutils.fileutils.jsonio.TypeSerializer[source]
Bases:
abc.ABCInterface for defining how types which are not JSON serializable by default should be encoded and decoded
- python_type: ClassVar[Type[T]]
- class polymerist.genutils.fileutils.jsonio.MultiTypeSerializer(*type_sers: tuple[Type[TypeSerializer]])[source]
For dynamically merging multiple TypeSerializer encoders and decoders
- property type_sers: list[Type[TypeSerializer]]
Read-only wrapper for the internal registry of TypeSerializers
- add_type_serializer(obj: TypeSerializer | MultiTypeSerializer) None[source]
For type, instance, and uniqueness checking of Type
- class polymerist.genutils.fileutils.jsonio.PathSerializer[source]
Bases:
TypeSerializerFor JSON-serializing OpenMM Quantities
- class polymerist.genutils.fileutils.jsonio.QuantitySerializer[source]
Bases:
TypeSerializerFor JSON-serializing OpenMM Quantities
- polymerist.genutils.fileutils.jsonio.append_to_json(json_path: pathlib.Path, **kwargs) None[source]
Add an entry to an existing JSON file
- class polymerist.genutils.fileutils.jsonio.JSONDict(json_path: pathlib.Path, *args, **kwargs)[source]
Bases:
dictDict subclass which also updates an underlying JSON file - effectively and on-disc dict !NOTE! - JSON doesn’t support non-string keys, so all keys given will be stringified - plan accordingly!
- json_path: pathlib.Path