minerva.utils.string_ops

Functions

indent_text(text[, spaces, char])

Add indentation to each line of a given text.

tree_like_formating(d[, initial_indent])

Format a dictionary into a tree-like structure.

Module Contents

minerva.utils.string_ops.indent_text(text, spaces=4, char=' ')[source]

Add indentation to each line of a given text.

Parameters

textstr

The text to be indented.

spacesint, optional

The number of spaces to indent each line, by default 4

charstr, optional

The character to use for indentation, by default “ “

Returns

str

The indented text.

Parameters:
  • text (str)

  • spaces (int)

  • char (str)

Return type:

str

minerva.utils.string_ops.tree_like_formating(d, initial_indent='')[source]

Format a dictionary into a tree-like structure.

Parameters

ddict

The dictionary to format.

initial_indentstr, optional

The initial indentation for the first level of the tree structure (default is no indentation), by default “”. This is useful for controlling the starting point of the tree structure. For example, if you want to start the tree structure with a specific indentation level, you can pass a string of spaces or other characters to this parameter. This allows for more flexibility in formatting the tree structure according to your preferences.

Returns

str

The formatted tree-like structure as a string.

Parameters:
  • d (dict)

  • initial_indent (str)

Return type:

str