followthemoney.model.Model
Bases: object
A collection of all the schemata available in followthemoney. The model provides some helper functions to find schemata, properties or to instantiate entity proxies based on the schema metadata.
__getitem__(name)
Same as get(), but throws an exception when the given name does not exist.
__iter__()
Iterate across all schemata.
common_schema(left, right)
cached
Select the most narrow of two schemata.
When indexing data from a dataset, an entity may be declared as a LegalEntity in one query, and as a Person in another. This function will select the most specific of two schemata offered. In the example, that would be Person.
generate()
Loading the model is a weird process because the schemata reference each other in complex ways, so the generation process cannot be fully run as schemata are being instantiated. Hence this process needs to be called once all schemata are loaded to finalise dereferencing the schemata.
get(name)
Get a schema object based on a schema name. If the input is already a schema object, it will just be returned.
get_proxy(data, cleaned=True)
Create an entity proxy to reflect the entity data in the given
dictionary. If cleaned
is disabled, all property values are
fully re-validated and normalised. Use this if handling input data
from an untrusted source.
get_qname(qname)
Get a property object based on a qualified name (i.e. schema:property).
get_type_schemata(type_)
Return all the schemata which have a property of the given type.
make_entity(schema, key_prefix=None)
Instantiate an empty entity proxy of the given schema type.
make_mapping(mapping, key_prefix=None)
Parse a mapping that applies (tabular) source data to the model.
map_entities(mapping, key_prefix=None)
Given a mapping, yield a series of entities from the data source.
matchable_schemata()
Return a list of all schemata that are matchable.
to_dict()
Return metadata for all schemata and properties, in a serializable form.