Schema IO¶
This module introduce the base classes for reading and writing data based on schema. The preferred way is using reader is writer rather than using the schema itself. It gives more flexibility and more extensibility.
-
class
pyrs.schema.schemaio.
JSONReader
(schema)[source]¶ Bases:
pyrs.schema.schemaio.Reader
-
class
pyrs.schema.schemaio.
JSONWriter
(schema)[source]¶ Bases:
pyrs.schema.schemaio.Writer
-
class
pyrs.schema.schemaio.
Reader
(schema)[source]¶ Bases:
pyrs.schema.schemaio.SchemaIO
Reader abstract class At least the read method should be implemented
sw = Reader(CustomSchema()) data = sw.write(<custom datastructure>)
-
class
pyrs.schema.schemaio.
SchemaIO
(schema)[source]¶ Bases:
object
The schema IO gives chance to Schema remain independent from the serialisation method. Even the schema provide conversion still just based on primitive values.
-
class
pyrs.schema.schemaio.
SchemaWriter
[source]¶ Bases:
object
Abstract implementation of schema writer. The main purpose of this class to ensure different useage of the schema. Add extra value if it’s necessary which can’t be implemented by the schema itself.
-
class
pyrs.schema.schemaio.
Validator
(schema)[source]¶ Bases:
pyrs.schema.schemaio.SchemaIO
Abstract base class of validators.
-
class
pyrs.schema.schemaio.
Writer
(schema)[source]¶ Bases:
pyrs.schema.schemaio.SchemaIO
Writer abstract class At least the write method should be implemented
sw = Writer(CustomSchema()) encoded_data = sw.write({'custom': 'value'})