Territories
rigour.territories
This module provides a set of classes and functions to work with countries, territories and jurisdictions. It is based on the notion that a territory is any political entity that may be referred to by a code, such as a country, a territory or a jurisdiction. Jurisdictions are most countries, but also sub-national entities like states, especially if they have their own legal incorporation regime.
For all territories, mappings to Wikidata QIDs are provided, as well as a set of other codes that may be used to refer to the same territory. The module also provides a set of functions to retrieve territories by their codes or QIDs.
get_ftm_countries()
Get all the countries that were supported by the FtM country
property type.
Returns:
Type | Description |
---|---|
List[Territory]
|
A list of territories. |
Source code in rigour/territories/__init__.py
get_territories()
cached
Get all the territories in the index.
Returns:
Type | Description |
---|---|
List[Territory]
|
A list of territories. |
get_territory(code)
Get a territory object for the given code.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
code
|
str
|
Country, territory or jurisdiction code. |
required |
Returns:
Type | Description |
---|---|
Optional[Territory]
|
A territory object. |
Source code in rigour/territories/__init__.py
get_territory_by_qid(qid)
cached
Get a territory object for the given Wikidata QID.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
qid
|
str
|
Wikidata QID. |
required |
Returns:
Type | Description |
---|---|
Optional[Territory]
|
A territory object. |
Source code in rigour/territories/__init__.py
lookup_by_identifier(identifier)
Lookup a territory by its identifier, which can be a 2- or 3-letter code, or QID.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
identifier
|
str
|
The identifier to lookup. |
required |
Returns:
Type | Description |
---|---|
Optional[Territory]
|
An instance of Territory if found, otherwise None. |
Source code in rigour/territories/lookup.py
lookup_territory(text, fuzzy=False)
cached
Lookup a territory by various codes and names.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
text
|
str
|
The text to lookup, which can be a code, name, or other identifier. |
required |
fuzzy
|
bool
|
If true, try a fuzzy search if the direct lookup didn't succeed. |
False
|
Returns:
Type | Description |
---|---|
Optional[Territory]
|
An instance of Territory if found, otherwise None. |