Snapshot configuration

The Snapshot class implements the wrapping handler over the configuration files stored for the user containing the environment variables’ values involved in a saved snapshot.

class Snapshot(configuration=None)

Represents a persisted configuration file of the user which stores the state of some environment variables.

Initialise a snapshot manager.

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

Parameters

configuration (context-capable dict, optional) –

UNDEFINE

UNDEFINE is a special tag instance that is returned by Snapshot if the stored action for a variable is to undefine it.

This value should always be identity-compared with the is keyword.

__delitem__(variable_name)

Marks the given variable to be undefined when the snapshot is loaded.

Parameters

variable_name (str) – The name of the variable to mark for undefinition.

__getitem__(variable_name)

Retrieve the stored actions for the given variable.

Returns

  • diff_actions (list(char, str)) – The representation of the diff actions to be taken for the variable to have the value in the saved snapshot.

    See envprobe.vartypes.EnvVar.diff() for the format.

  • UNDEFINE – Returned if the variable was marked to be undefined.

__setitem__(variable_name, difference)

Sets the stored action of the given variable to the new value.

Parameters

Warning

__setitem__() overwrites the information that is stored in the snapshot. In most cases, envprobe.vartypes.EnvVar.merge_diff() should be used to first create a diff that appends to the current one, and save that result.

keys()

Returns the variable names that are affected by the snapshot.