tlc.client.helpers¶

Miscellaneous helper functions.

Module Contents¶

Functions¶

Function

Description

active_project_name

Return the active project name, if any.

active_run

Return the active Run, if any.

get_alias_path

Return the path of a registered URL alias.

get_registered_url_aliases

Return the registered URL aliases.

hex_to_rgb_tuple

register_project_url_alias

Register and persist a project URL alias.

register_url_alias

Register an alias for a URL.

rgb_tuple_to_hex

set_active_run

Set the active Run.

unregister_url_alias

Unregister an alias for a URL.

API¶

active_project_name() str | None¶

Return the active project name, if any.

active_run() Run | None¶

Return the active Run, if any.

get_alias_path(
token: str,
) str | None¶

Return the path of a registered URL alias.

get_registered_url_aliases() dict[str, str]¶

Return the registered URL aliases.

Returns:

A dictionary mapping alias tokens to paths.

hex_to_rgb_tuple(
hex_color: str,
) tuple[int, int, int]¶
register_project_url_alias(
token: str,
path: str | Url | Path,
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.

register_url_alias(
token: str,
path: str | Url | Path,
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.

rgb_tuple_to_hex(
rgb: tuple[int, int, int],
) str¶
set_active_run(
run: Run | Url,
) None¶

Set the active Run.

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.