installation_instruction.helpers

Attributes

CONFIG_FILE_NAME

ALLOWED_GIT_URL_PREFIXES

Functions

_red_echo(text)

_is_remote_git_repository(→ bool)

Checks if the given URL might be a remote git repository.

_clone_git_repo(→ tempfile.TemporaryDirectory)

Clones a git repository to a temporary directory.

_config_file_is_in_folder(→ str | None)

Checks if the file install.cfg is in the folder.

_get_install_config_file(...)

Checks wether path is a git url or a dir, finds the config file and asserts that said file is a file.

_get_error_message_from_string(→ str | None)

Parses error message of error given by using jinja macro RAISE_JINJA_MACRO_STRING. If no error message is found returns None.

_replace_whitespace_in_string_and_split_it(→ list[str])

Replaces eol whitespaces of a string with a single whitespace or none.

_split_string_at_delimiter(→ tuple[str, str])

Extracts part before and after the delimiter "------" or more.

_load_template_from_string(→ jinja2.Template)

Returns jinja2.Template.

Module Contents

installation_instruction.helpers.CONFIG_FILE_NAME = 'install.cfg'
installation_instruction.helpers.ALLOWED_GIT_URL_PREFIXES = ['http://', 'https://', 'git://', 'ssh://', 'ftp://', 'ftps://']
installation_instruction.helpers._red_echo(text: str)
installation_instruction.helpers._is_remote_git_repository(url: str) bool

Checks if the given URL might be a remote git repository.

todo: Make this more robust. Check if it is actually a valid git repository by calling it.

Parameters:

url (str) – URL to be checked.

Returns:

True if the URL is a remote git repository, else False.

Return type:

bool

installation_instruction.helpers._clone_git_repo(url: str) tempfile.TemporaryDirectory

Clones a git repository to a temporary directory.

Parameters:

url (str) – URL of the remote git repository.

Returns:

TemporaryDirectory object with git repo.

Return type:

tempfile.TemporaryDirectory

installation_instruction.helpers._config_file_is_in_folder(dir_path: str) str | None

Checks if the file install.cfg is in the folder.

Parameters:

dir_path (str) – Path to the folder.

Returns:

Path to the install.cfg file if it exists, else None.

Return type:

str or None

installation_instruction.helpers._get_install_config_file(path: str) tuple[tempfile.TemporaryDirectory | None, str]

Checks wether path is a git url or a dir, finds the config file and asserts that said file is a file.

Parameters:

path (str) – Url, path to dir or file.

Returns:

Returns a tuple with a temporary dir needed for cloning a git repository (on distruction temporary dir is deleted), and the found config file path.

Return type:

tuple[TemporaryDirectory|None, str]

installation_instruction.helpers._get_error_message_from_string(string: str) str | None

Parses error message of error given by using jinja macro RAISE_JINJA_MACRO_STRING. If no error message is found returns None.

Parameters:

string (str) – This is the raw error string where an error message might be.

Returns:

Error message if found else None.

Rtpye:

str or None

installation_instruction.helpers._replace_whitespace_in_string_and_split_it(string: str) list[str]

Replaces eol whitespaces of a string with a single whitespace or none.

Parameters:

string (str) – String to be processed.

Returns:

String where whitespace is replaced with one whitespace and whitspace before and after are stripped.

Return type:

str

installation_instruction.helpers._split_string_at_delimiter(string: str) tuple[str, str]

Extracts part before and after the delimiter “——” or more.

Parameters:

string (str) – The string with a delimiter.

Raises:

Exception – If no delimiter is found.

Returns:

Returns a tuple with the part before and after the delimiter.

Return type:

tuple[str, str]

installation_instruction.helpers._load_template_from_string(string: str) jinja2.Template

Returns jinja2.Template.

Parameters:

string (str) – String to be processed.

Returns:

jinja2 Template object.

Return type:

jinja2.Template