module documentation

This module provides various utility functions.

Function compareIDs Compare two resource IDs.
Function getAttributeSize Return a realistic size for the content of an attribute. Python does not really return good sizes for some of the data types.
Function getIDFromPath Split a full path e.g. from a http request into its component and return a CSE local ri . Also handle retargeting paths.
Function isUniqueRI Test whether a resource ID does not yet exists.
Function resourceFromCSI Get A CSEBase resource by its csi. This might be a different <CSEBase> resource then the hosting CSE.
Function resourceTypeFromID Get the resource type from a resource ID.
Function riFromCSI Get the resource ID from any CSEBase or remoteCSE resource by its csi.
Function riFromID Return the unstructured resource ID from either an unstructured or structured resource ID.
Function riFromStructuredPath Get the resource ID from a resource by its structured path. Makes a lookup to a table in the DB.
Function srnFromHybrid Get the structured part of a hybrid resource ID, including the necessary handling of virtual resources in the path.
Function structuredPathFromRI Get the structured path of a resource by its ri.
Variable storage Storage singleton instance.
def compareIDs(id1: str, id2: str) -> bool:

Compare two resource IDs.

Both IDs can be either unstructured or structured resource IDs. They match if they point to the same resource.

Parameters
id1:strFirst ID for the comparison.
id2:strSecond ID for the comparison
Returns
boolTrue if both IDs point to the same resource, False otherwise.
def getAttributeSize(attribute: Any) -> int:

Return a realistic size for the content of an attribute. Python does not really return good sizes for some of the data types.

Parameters
attribute:AnyAn attribute's content of any of the suppported types.
Returns
intByte size of the attribute's value.
def getIDFromPath(id: str) -> tuple[str, str, str, str, str]:

Split a full path e.g. from a http request into its component and return a CSE local ri . Also handle retargeting paths.

Parameters
id:strA resource ID to process. This could be a structured or unstructured, and in CSE-relative, SP-relative or Absolute format.
Returns
tuple[str, str, str, str, str]The return tupple is (RI, CSI of the resource ID, structured path of the ID, SPID if any, debug message or None).
def isUniqueRI(ri: str) -> bool:

Test whether a resource ID does not yet exists.

Parameters
ri:strResource ID to check
Returns
boolBoolean indicating the result of the test
def resourceFromCSI(csi: str) -> Any | None:

Get A CSEBase resource by its csi. This might be a different <CSEBase> resource then the hosting CSE.

Parameters
csi:strCSE-ID of the <CSEBase> resource to retrieve.
Returns
Any | None<CSEBase> resource or None if not found.
def resourceTypeFromID(id: str) -> ResourceTypes | None:

Get the resource type from a resource ID.

Parameters
id:strResource ID to check.
Returns
ResourceTypes | NoneResource type, or None in case of an error.
def riFromCSI(csi: str) -> str | None:

Get the resource ID from any CSEBase or remoteCSE resource by its csi.

Parameters
csi:strThe CSE-ID to search for.
Returns
str | NoneThe resource ID of the resource with the csi, or None in case of an error.
def riFromID(id: str) -> str:

Return the unstructured resource ID from either an unstructured or structured resource ID.

Parameters
id:strStructured or unstructured Resource ID.
Returns
strUnstructured resource ID.
def riFromStructuredPath(srn: str) -> str | None:

Get the resource ID from a resource by its structured path. Makes a lookup to a table in the DB.

Parameters
srn:strstructured path.
Returns
str | NoneResource ID, or None in case of an error.
def srnFromHybrid(srn: str, id: str) -> tuple[str, str]:

Get the structured part of a hybrid resource ID, including the necessary handling of virtual resources in the path.

Parameters
srn:strStructured version of a resource ID. This part will be filled in when ommitted.
id:strResource ID to check.
Returns
tuple[str, str]Tuple of the (possible new & filled) structured path and the resource ID.
def structuredPathFromRI(ri: str) -> str | None:

Get the structured path of a resource by its ri.

Parameters
ri:strResource ID.
Returns
str | NoneStructured path, or None in case of an error.
storage: Storage =

Storage singleton instance.