Utilities
TWA_BASE_URL
module-attribute
¶
To be used by attaching specific namespace and class name to it e.g. https://www.theworldavatar.com/kg/ontolab/LabEquipment
check_valid_url ¶
This function checks if the provided URL for namespace starts with "http://" or "https://". If so, it returns the URL and add "/" if it's not already ending with a "/" or "#".
Parameters:
Name | Type | Description | Default |
---|---|---|---|
url
|
str
|
The URL to be checked |
required |
Raises:
Type | Description |
---|---|
Exception
|
The URL is not provided with either "http://" or "https://" as its start |
Returns:
Name | Type | Description |
---|---|---|
str |
str
|
The original URL or the processed URL with a "/" added at its end |
Source code in JPS_BASE_LIB/python_wrapper/twa/data_model/utils.py
construct_namespace_iri ¶
This function constructs the namespace IRI from the base URL and namespace. For example, if the base URL is "https://www.theworldavatar.com/kg" and the namespace is "ontolab", The function will return "https://www.theworldavatar.com/kg/ontolab".
Parameters:
Name | Type | Description | Default |
---|---|---|---|
base_url
|
str
|
The base URL of the namespace IRI, e.g. "https://www.theworldavatar.com/kg" |
required |
namespace
|
str
|
The namespace, e.g. "ontolab", will be ignored if None |
required |
Returns:
Name | Type | Description |
---|---|---|
str |
str
|
The namespace IRI, e.g. "https://www.theworldavatar.com/kg/ontolab" |
Source code in JPS_BASE_LIB/python_wrapper/twa/data_model/utils.py
construct_rdf_type ¶
This function constructs the RDF type IRI from the namespace IRI and class name.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
namespace_iri
|
str
|
The namespace IRI, e.g. "https://www.theworldavatar.com/kg/ontolab" |
required |
class_name
|
str
|
The class name, e.g. "LabEquipment" |
required |
Returns:
Name | Type | Description |
---|---|---|
str |
str
|
The RDF type IRI, e.g. "https://www.theworldavatar.com/kg/ontolab/LabEquipment" |
Source code in JPS_BASE_LIB/python_wrapper/twa/data_model/utils.py
init_instance_iri ¶
The function constructs a unique IRI for an instance of a class in a namespace.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
namespace_iri
|
str
|
The namespace IRI, e.g. "https://www.theworldavatar.com/kg/ontolab" |
required |
class_name
|
str
|
The class name, e.g. "LabEquipment" |
required |
Returns:
Name | Type | Description |
---|---|---|
str |
str
|
The unique IRI for the instance, e.g. "https://www.theworldavatar.com/kg/ontolab/LabEquipment_12345678" |
Source code in JPS_BASE_LIB/python_wrapper/twa/data_model/utils.py
trim_iri ¶
This function trims the "<" and ">" characters from the left and right side of the given IRI (or lists of IRIs).
Parameters:
Name | Type | Description | Default |
---|---|---|---|
iri
|
str or list
|
The IRI(s) to be trimmed |
required |
Returns:
Name | Type | Description |
---|---|---|
str |
Union[str, List[str]]
|
The trimmed IRI |