finalynx.portfolio.render

Module Contents

Classes

Render

Abstract class used to transform a render format to the output.

API

class finalynx.portfolio.render.Render(aliases: Optional[Dict[str, str]] = None, agents: Optional[Dict[str, Callable[..., str]]] = None)[source]

Abstract class used to transform a render format to the output.

Initialization

Abstract class used by subclasses to render themselves as string with a customizable format. This class offers a render method which takes a format as input and outputs the corresponding string. See formatting guidelines for more information.

Parameters:
  • aliases – A key:value dictionary, defaults to empty. Specified keywords will be recursively transformed into the value until all keywords don’t appear in the text.

  • agents – A key:value dictionary, defaults to empty. Keywords will be replaced by what the method given as value will output.

MAX_ALIAS_DEPTH

10

Maximum recursion depth when replacing aliases to prevent infinite loops.

render(output_format: str = '[console]', **args: Dict[str, Any]) str[source]

Render the instance as a string by following the output format. See formatting guidelines for more information.

Returns:

A string representation of the instance based on the output format.

_apply_aliases(output_format: str) str[source]

Internal method that recursively replaces alias keywords into their values specified in self._render_aliases.

Returns:

A string of the output format with aliases replaced.