wikidata.entity — Wikidata entities#

class wikidata.entity.Entity(id: EntityId, client: Client)#

Wikidata entity. Can be an item or a property. Its attrributes can be lazily loaded.

To get an entity use Client.get() method instead of the constructor of Entity.

Note

Although it implements Mapping[EntityId, object], it actually is multidict. See also getlist() method.

Changed in version 0.2.0: Implemented Mapping[EntityId, object] protocol for easy access of statement values.

Changed in version 0.2.0: Implemented Hashable protocol and ==/= operators for equality test.

state#

(EntityState) The loading state.

New in version 0.7.0.

getlist(key: Entity) Sequence[object]#

Return all values associated to the given key property in sequence.

Parameters:

key (Entity) – The property entity.

Returns:

A sequence of all values associated to the given key property. It can be empty if nothing is associated to the property.

Return type:

Sequence[object]

lists() Sequence[Tuple[Entity, Sequence[object]]]#

Similar to items() except the returning pairs have each list of values instead of each single value.

Returns:

The pairs of (key, values) where values is a sequence.

Return type:

Sequence[Tuple[Entity, Sequence[object]]]

property type: EntityType#

(EntityType) The type of entity, item or property.

New in version 0.2.0.

class wikidata.entity.EntityId#

The identifier of each Entity. Alias of str.

alias of str

class wikidata.entity.EntityState(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)#

Define state of Entity.

New in version 0.7.0.

loaded = 'loaded'#

(EntityState) The entity exists and is already loaded.

non_existent = 'non_existent'#

(EntityState) The entity does not exist.

not_loaded = 'not_loaded'#

(EntityState) Not loaded yet. Unknown whether the entity does exist or not.

class wikidata.entity.EntityType(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)#

The enumerated type which consists of two possible values:

New in version 0.2.0.

item = 'item'#

(EntityType) Items are Entity objects that are typically represented by Wikipage (at least in some Wikipedia languages). They can be viewed as “the thing that a Wikipage is about,” which could be an individual thing (the person Albert Einstein), a general class of things (the class of all Physicists), and any other concept that is the subject of some Wikipedia page (including things like History of Berlin).

See also

Items — Wikibase Data Model

The data model of Wikibase describes the structure of the data that is handled in Wikibase.

property = 'property'#

(EntityType) Properties are Entity objects that describe a relationship between items (or other Entity objects) and values of the property. Typical properties are population (using numbers as values), binomial name (using strings as values), but also has father and author of (both using items as values).

See also

Properties — Wikibase Data Model

The data model of Wikibase describes the structure of the data that is handled in Wikibase.