Tracking variables

Environment variable tracking is an integral feature of Envprobe’s persistence layer. A variable that is not tracked will not be handled when saved snapshots are accessed.

class VariableTracking(global_configuration=None, local_configuration=None)

Allows access to the user’s configuration files about which variables are tracked.

In most cases, the tracking is configured on two levels, a local (usually a shell’s configuration) level, and a global (user’s) level. The class’s behaviour reflects the two configurations in an overlay, with the local settings trumping the global ones.

Initialises the tracking manager.

This instantiation is cheap. Access to the underlying data is only done when a query or setter function is called.

Parameters
  • global_configuration (context-capable dict, optional) –

  • local_configuration (context-capable dict, optional) –

property default_tracking

Returns True if the current default tracking behaviour is ON.

property global_tracking

Returns True if the default behaviour for tracking is ON in the global configuration.

ignore_global(variable_name)

Marks the variable to be ignored in the global scope.

ignore_local(variable_name)

Marks the variable to be ignored in the local scope.

is_explicitly_configured_global(variable_name)

Returns whether variable_name has an explicit track/ignore record in the global scope.

is_explicitly_configured_local(variable_name)

Returns whether variable_name has an explicit track/ignore record in the local scope.

is_tracked(*variables)

Resolves whether the variable_name are tracked according to the loaded configuration.

The resolution order for the tracking status of a variable is the following:

  1. If the variable is explicitly tracked/ignored locally, the result.

  2. If the variable is explicitly tracked/ignored globally, the result.

  3. If there is a default tracking set locally, that value.

  4. The default global tracking setting.

  5. True, i.e. the variable is deemed tracked.

Parameters

*variables (list(str) or str) – The list of variable names to check, either a single string, a variable length argument pass, or a list.

Returns

If only one element was given to variables, a single result is returned, which is True if the variable should be considered tracked, and False otherwise. If multiple names were passed, a list is returned, with each result being the result for the passed varaible, in order.

Return type

list(bool) or bool

is_tracked_global(variable_name)

Returns whether the variable is set to be tracked in the global configuration file.

is_tracked_local(variable_name)

Returns whether the variable is set to be tracked in the local configuration file.

property local_tracking

Returns True if the default behaviour for tracking is ON in the local configuration.

track_global(variable_name)

Marks the variable to be tracked in the global scope.

track_local(variable_name)

Marks the variable to be tracked in the local scope.

unset_global(variable_name)

Removes the variable from the track or ignore lists in the global scope, making the default behaviour apply.

unset_local(variable_name)

Removes the variable from the track or ignore lists in the local scope, making the default behaviour apply.