tlc.client.helpers#

Miscellaneous helper functions.

Module Contents#

Functions#

Function

Description

active_run

Return the active Run, if any.

set_active_run

Set the active Run.

active_project_name

Return the active project name, if any.

register_url_alias

Register an alias for a URL.

unregister_url_alias

Unregister an alias for a URL.

get_registered_url_aliases

Return the registered URL aliases.

register_project_url_alias

Register and persist a project URL alias.

API#

tlc.client.helpers.active_run() tlc.core.objects.mutable_objects.run.Run | None#

Return the active Run, if any.

tlc.client.helpers.set_active_run(run: tlc.core.objects.mutable_objects.run.Run | tlc.core.url.Url) None#

Set the active Run.

tlc.client.helpers.active_project_name() str | None#

Return the active project name, if any.

tlc.client.helpers.register_url_alias(token: str, path: str, force: bool = True) None#

Register an alias for a URL.

Parameters:
  • token – The alias token to register. Must be match the regex [A-Z][A-Z0-9_]*.

  • path – The path to alias.

  • force – If True, force the registration of the alias even if it is already registered.

Raises:

ValueError – If the token is already registered and force is False.

tlc.client.helpers.unregister_url_alias(token: str) None#

Unregister an alias for a URL.

Parameters:

token – The alias token to unregister. Must match the regex [A-Z][A-Z0-9_]*.

Raises:

KeyError – If the token is not registered.

tlc.client.helpers.get_registered_url_aliases() dict[str, str]#

Return the registered URL aliases.

Returns:

A dictionary mapping alias tokens to paths.

tlc.client.helpers.register_project_url_alias(token: str, path: str, force: bool = True, project: str | None = None, root: str | None = None) None#

Register and persist a project URL alias.

A project URL alias is a per-project alias that is persisted in the project’s configuration file and will be loaded for other users that share the same project but not necessarily the same startup-config. The alias is also registered in the current session and is immediately available for use.

Parameters:
  • token – The alias token to register. Must match the regex [A-Z][A-Z0-9_]*.

  • path – The path to alias.

  • force – If True, force the registration of the alias even if it is already registered.

  • project – The project name. If None, the active project is used.

  • root – The root name. If None, the active root is used.

Raises:

ValueError – If the token is already registered and force is False.