installation_instruction.helpers ================================ .. py:module:: installation_instruction.helpers Attributes ---------- .. autoapisummary:: installation_instruction.helpers.CONFIG_FILE_NAME installation_instruction.helpers.ALLOWED_GIT_URL_PREFIXES Functions --------- .. autoapisummary:: installation_instruction.helpers._red_echo installation_instruction.helpers._is_remote_git_repository installation_instruction.helpers._clone_git_repo installation_instruction.helpers._config_file_is_in_folder installation_instruction.helpers._get_install_config_file installation_instruction.helpers._get_error_message_from_string installation_instruction.helpers._replace_whitespace_in_string_and_split_it installation_instruction.helpers._split_string_at_delimiter installation_instruction.helpers._load_template_from_string Module Contents --------------- .. py:data:: CONFIG_FILE_NAME :value: 'install.cfg' .. py:data:: ALLOWED_GIT_URL_PREFIXES :value: ['http://', 'https://', 'git://', 'ssh://', 'ftp://', 'ftps://'] .. py:function:: _red_echo(text: str) .. py:function:: _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. :param url: URL to be checked. :type url: str :return: True if the URL is a remote git repository, else False. :rtype: bool .. py:function:: _clone_git_repo(url: str) -> tempfile.TemporaryDirectory Clones a git repository to a temporary directory. :param url: URL of the remote git repository. :type url: str :return: `TemporaryDirectory` object with git repo. :rtype: tempfile.TemporaryDirectory .. py:function:: _config_file_is_in_folder(dir_path: str) -> str | None Checks if the file `install.cfg` is in the folder. :param dir_path: Path to the folder. :type dir_path: str :return: Path to the `install.cfg` file if it exists, else None. :rtype: str or None .. py:function:: _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. :param path: Url, path to dir or file. :type path: str :return: 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. :rtype: tuple[TemporaryDirectory|None, str] .. py:function:: _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`. :param string: This is the raw error string where an error message might be. :type string: str :return: Error message if found else None. :rtpye: str or None .. py:function:: _replace_whitespace_in_string_and_split_it(string: str) -> list[str] Replaces eol whitespaces of a string with a single whitespace or none. :param string: String to be processed. :type string: str :return: String where whitespace is replaced with one whitespace and whitspace before and after are stripped. :rtype: str .. py:function:: _split_string_at_delimiter(string: str) -> tuple[str, str] Extracts part before and after the delimiter "------" or more. :param string: The string with a delimiter. :type string: str :raise Exception: If no delimiter is found. :return: Returns a tuple with the part before and after the delimiter. :rtype: tuple[str, str] .. py:function:: _load_template_from_string(string: str) -> jinja2.Template Returns `jinja2.Template`. :param string: String to be processed. :type string: str :return: jinja2 Template object. :rtype: jinja2.Template