wikibaseintegrator.models.forms
- class wikibaseintegrator.models.forms.Form(form_id=None, representations=None, grammatical_features=None, claims=None)[source]
Bases:
BaseModel
- Parameters:
form_id (Optional[str]) –
representations (Optional[Representations]) –
grammatical_features (Optional[Union[str, int, List[str]]]) –
claims (Optional[Claims]) –
- __init__(form_id=None, representations=None, grammatical_features=None, claims=None)[source]
- Parameters:
form_id (str | None) –
representations (Representations | None) –
grammatical_features (str | int | List[str] | None) –
claims (Claims | None) –
- property claims
- property grammatical_features
- property id
- property representations
- class wikibaseintegrator.models.forms.Representations[source]
Bases:
LanguageValues
- __init__()
- Return type:
None
- add(language_value)
Add a LanguageValue object to the list
- Parameters:
language_value (
LanguageValue
) – A LanguageValue object- Return type:
- Returns:
The current LanguageValues object
- from_json(json_data)
Create a new LanguageValues object from a JSON/dict object.
- Parameters:
json_data (
Dict
[str
,Dict
]) – A dict object who use the same format as Wikibase.- Return type:
- Returns:
The newly created or updated object.
- get(language=None)
Get a LanguageValue object with the specified language. Use the default language in wbi_config if none specified.
- Parameters:
language (
Optional
[str
]) – The requested language.- Return type:
Optional
[LanguageValue
]- Returns:
The related LanguageValue object or None if none found.
- get_json()
Get a formatted dict who respect the Wikibase format.
- Return type:
Dict
[str
,Dict
]- Returns:
A dict using Wikibase format.
- set(language=None, value=None, action_if_exists=ActionIfExists.REPLACE_ALL)
Create or update the specified language with the valued passed in arguments.
- Parameters:
language (
Optional
[str
]) – The desired language.value (
Optional
[str
]) – The desired value of the LanguageValue object. Use None to delete an existing LanguageValue object from the list.action_if_exists (
ActionIfExists
) – The action if the LanguageValue object is already defined. Can be ActionIfExists.REPLACE_ALL (default) or ActionIfExists.KEEP.
- Return type:
Optional
[LanguageValue
]- Returns:
The created or updated LanguageValue. None if there’s no LanguageValue object with this language.
- property values: Dict[str, LanguageValue]
A dict of LanguageValue with the language as key.