The normalize package is primarily for writing “plain old data structures” to wrap data from network sources (typically JSON) in python objects, use them in python, and frequently send them back. It is also a useful generic class builder which can be leveraged for interesting and powerful meta-programming.
Put simply, you write python classes and declare your assumptions about the data structures you’re dealing with, feed in input data and you get regular python objects back which have attributes which you can use naturally. You can then perform basic operations with the objects, such as make changes to them and convert them back, or compare them to another version using the rich comparison API. You can also construct the objects ‘natively’ using regular python keyword/value constructors or by passing a dict as the first argument.
It is very similar in scope to the remoteobjects and schematics packages on PyPI, and may in time evolve to include all the features of those packages.
Contents of this manual:
It’s safest to stick with importing directly from the normalize top-level namespace. Useful classes and functions not being here may be a bug!
normalize.DictCollection | An implementation of keyed collections which obey the Record property protocol and the tuple collection protocol. |
normalize.exc | |
normalize.FieldSelector | A way to refer to fields/record/properties within a data structure. |
normalize.FieldSelectorException | |
normalize.from_json | JSON marshall in function: a ‘visitor’ function which looks for JSON types/hints on types being converted to, but does not require them. |
normalize.JsonListProperty | A property which map to a list of records in JSON. |
normalize.JsonProperty | Object property wrapper for record json data |
normalize.JsonRecord | Version of a Record which deals primarily in JSON form. |
normalize.JsonRecordList | Version of a RecordList which deals primarily in JSON |
normalize.LazyProperty | This declares a property which has late evaluation using its ‘default’ method. |
normalize.ListCollection | An implementation of sequences which obey the Record property protocol and the tuple collection protocol. |
normalize.ListProperty | |
normalize.make_property_type | Makes a new Property type, which supplies the given arguments as defaults to the Property() constructor. |
normalize.MultiFieldSelector | Version of a FieldSelector which stores multiple FieldSelectors combined into a single tree structure. |
normalize.Property | This is the base class for all property types. |
normalize.ROProperty | A read-only property throws an exception when the attribute slot is |
normalize.Record | Base class for normalize instances and collections. |
normalize.RecordList | alias of ListCollection |
normalize.RecordMeta | Metaclass for Record types. |
normalize.SafeProperty | A version of Property which always checks all assignments to properties. |
normalize.to_json | JSON conversion function: a ‘visitor’ function which implements marshall out (to JSON data form), honoring JSON property types/hints but does not require them. |