fkie_mas_pylib.names module

fkie_mas_pylib.names.basename(p) str

Returns the final component of a node name

fkie_mas_pylib.names.namespace(name: str, with_sep_suffix: bool = True, global_on_none: bool = False, raise_err_on_none: bool = True) str

Get the namespace of name. The namespace is returned with a trailing slash in order to favor easy concatenation and easier use within the global context.

Parameters:

name (str) – name to return the namespace of. Must be a legal name. NOTE: an empty name will return the global namespace.

Return str:

Namespace of name. For example, ‘/wg/node1’ returns ‘/wg/’. The global namespace is ‘/’.

Return type:

str

Raises:

ValueError – if name is invalid

fkie_mas_pylib.names.ns_join(ns: str, name: str) str

Join a namespace and name. If name is unjoinable (i.e. ~private or /global) it will be returned without joining

Parameters:
  • ns (str) – namespace (‘/’ and ‘~’ are both legal). If ns is the empty string, name will be returned.

  • name (str) – a legal name

Returns:

name concatenated to ns, or name if it is unjoinable.

Return type:

str