name_to_name_index#

lsst.ts.salobj.name_to_name_index(name)#

Parse a SAL component name of the form name[:index].

Parameters:

name (str) – Component name of the form name or name:index. The default index is 0.

Returns:

name_int – A tuple containing the component name (str) and index (int). The index is 0 if the input did not specify.

Return type:

tuple

Raises:

ValueError – If the name cannot be parsed.

Notes

Examples:

  • "Script" -> ("Script", 0)

  • "Script:0" -> ("Script", 0)

  • "Script:15" -> ("Script", 15)

  • " Script:15" -> raise ValueError (leading space)

  • "Script:15 " -> raise ValueError (trailing space)

  • "Script:" -> raise ValueError (colon with no index)

  • "Script:zero" -> raise ValueError (index not an integer)