Skip to content

Entity objects

Multiple entity object classes are available. Besides the ones documented here, a StatementEntity is implemented to support statement-based data processing.

followthemoney.entity.ValueEntity

Bases: EntityProxy

This class has the extended attributes from StatementEntity but without statements. Useful for streaming around. Starting from followthemoeny 4.0, applications should use this entity class as the base class.

followthemoney.proxy.EntityProxy

Bases: object

A wrapper object for an entity, with utility functions for the introspection and manipulation of its properties.

This is the main working object in the library, used to generate, validate and emit data.

caption property

The user-facing label to be used for this entity. This checks a list of properties defined by the schema (caption) and returns the first available value. If no caption is available, return the schema label.

countries property

Get the set of all country-type values set of the entity.

country_hints property

Some property types, such as phone numbers and IBAN codes imply a country that may be associated with the entity. This list can be used for a more generous matching approach than the actual country values.

names property

Get the set of all name-type values set of the entity.

properties property

Return a mapping of the properties and set values of the entity.

temporal_end property

Get a date that can be used to represent the end of the entity in a timeline. If therer are multiple possible dates, the latest date is returned.

temporal_start property

Get a date that can be used to represent the start of the entity in a timeline. If there are multiple possible dates, the earliest date is returned.

add(prop, values, cleaned=False, quiet=False, fuzzy=False, format=None)

Add the given value(s) to the property if they are valid for the type of the property.

:param prop: can be given as a name or an instance of :class:~followthemoney.property.Property. :param values: either a single value, or a list of values to be added. :param cleaned: should the data be normalised before adding it. :param quiet: a reference to an non-existent property will return an empty list instead of raising an error. :param fuzzy: when normalising the data, should fuzzy matching be allowed. :param format: when normalising the data, formatting for a date.

clone()

Make a deep copy of the current entity proxy.

edgepairs()

Return all the possible pairs of values for the edge source and target if the schema allows for an edge representation of the entity.

first(prop, quiet=False)

Get only the first value set for the property.

:param prop: can be given as a name or an instance of :class:~followthemoney.property.Property. :param quiet: a reference to an non-existent property will return an empty list instead of raising an error. :return: A value, or None.

from_dict(data, cleaned=True) classmethod

Instantiate a proxy based on the given model and serialised dictionary.

Use :meth:followthemoney.model.Model.get_proxy instead.

get(prop, quiet=False)

Get all values of a property.

:param prop: can be given as a name or an instance of :class:~followthemoney.property.Property. :param quiet: a reference to an non-existent property will return an empty list instead of raising an error. :return: A list of values.

get_type_inverted(matchable=False)

Return all the values of the entity arranged into a mapping with the group name of their property type. These groups include countries, addresses, emails, etc.

get_type_values(type_, matchable=False)

All values of a particular type associated with a the entity. For example, this lets you return all countries linked to an entity, rather than manually checking each property to see if it contains countries.

:param type_: The type object to be searched. :param matchable: Whether to return only property values marked as matchable.

has(prop, quiet=False)

Check to see if the given property has at least one value set.

:param prop: can be given as a name or an instance of :class:~followthemoney.property.Property. :param quiet: a reference to an non-existent property will return an empty list instead of raising an error. :return: a boolean.

iterprops()

Iterate across all the properties for which a value is set in the proxy (but do not return their values).

itervalues()

Iterate across all values in the proxy one by one, each given as a tuple of the property and the value.

make_id(*parts)

Generate a (hopefully unique) ID for the given entity, composed of the given components, and the :attr:~key_prefix defined in the proxy.

merge(other)

Merge another entity proxy into this one. This will try and find the common schema between both entities and then add all property values from the other entity into this one.

pop(prop, quiet=True)

Remove all the values from the given property and return them.

:param prop: can be given as a name or an instance of :class:~followthemoney.property.Property. :param quiet: a reference to an non-existent property will return an empty list instead of raising an error. :return: a list of values, possibly empty.

remove(prop, value, quiet=True)

Remove a single value from the given property. If it is not there, no action takes place.

:param prop: can be given as a name or an instance of :class:~followthemoney.property.Property. :param value: will not be cleaned before checking. :param quiet: a reference to an non-existent property will return an empty list instead of raising an error.

set(prop, values, cleaned=False, quiet=False, fuzzy=False, format=None)

Replace the values of the property with the given value(s).

:param prop: can be given as a name or an instance of :class:~followthemoney.property.Property. :param values: either a single value, or a list of values to be added. :param cleaned: should the data be normalised before adding it. :param quiet: a reference to an non-existent property will return an empty list instead of raising an error.

to_dict()

Serialise the proxy into a dictionary with the defined properties, ID, schema and any contextual values that were handed in initially. The resulting dictionary can be used to make a new proxy, and it is commonly written to disk or a database.

to_full_dict(matchable=False)

Return a serialised version of the entity with inverted type groups mixed in. See :meth:~get_type_inverted.

unsafe_add(prop, value, cleaned=False, fuzzy=False, format=None)

A version of add() to be used only in type-checking code. This accepts only a single value, and performs input cleaning on the premise that the value is already valid unicode. Returns the value that has been added.