class documentation

class SecretsExpander: (source)

Constructor: SecretsExpander()

View In Hierarchy

This class expands secrets referenced in ini files.

A secret is declared as @{<secrets-filename>}.

All secret errors found in the INI file are collected and can be retrieved by calling the I{get_expand_errors()} method.

The location of the secrets directory varies depending on a platform.

The following python code snippet will show you where it's located:

>>> import site
>>> print(f'{site.USER_BASE}/secrets')
Method __init__ Initialize class attributes.
Method expand_secrets Return the text with secrets expanded.
Method get_expand_errors Return all expanding errors (missing secrets file).
Instance Variable error Validation errors.
Method _secret_of Return content from in the specified secrets file for matching objects.
def __init__(self): (source)

Initialize class attributes.

def expand_secrets(self, text: str) -> str: (source)

Return the text with secrets expanded.

Parameters
text:strExpanded text.
Returns
strExpanded text.
def get_expand_errors(self) -> list: (source)

Return all expanding errors (missing secrets file).

Returns
listList of expanding errors

Validation errors.

def _secret_of(self, match_obj: re.Match) -> str: (source)

Return content from in the specified secrets file for matching objects.

Keep track of all expand errors, so they can be retrieved later. When an error occurs, the unexpanded value is returned.

Parameters
match_obj:re.MatchMatched pattern object.
Returns
strContent of specified secrets file.