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, context=None)[source]¶ Bases:
pyrs.schema.schemaio.Reader
-
class
pyrs.schema.schemaio.JSONWriter(schema, context=None)[source]¶ Bases:
pyrs.schema.schemaio.Writer
-
class
pyrs.schema.schemaio.Reader(schema, context=None)[source]¶ Bases:
pyrs.schema.schemaio.SchemaIOReader abstract class At least the read method should be implemented
sw = Reader(CustomSchema()) data = sw.write(<custom datastructure>)
-
class
pyrs.schema.schemaio.SchemaIO(schema, context=None)[source]¶ Bases:
objectThe 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(context=None)[source]¶ Bases:
objectAbstract 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, context=None)[source]¶ Bases:
pyrs.schema.schemaio.SchemaIOAbstract base class of validators.
-
class
pyrs.schema.schemaio.Writer(schema, context=None)[source]¶ Bases:
pyrs.schema.schemaio.SchemaIOWriter abstract class At least the write method should be implemented
sw = Writer(CustomSchema()) encoded_data = sw.write({'custom': 'value'})