text
Text utilities.
- anemoi.utils.text.dotted_line(width: int = 84) str
Return a dotted line using ‘┈’.
>>> dotted_line(40) ┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈
- anemoi.utils.text.visual_len(s: str | list[tuple[str, int]]) int
Compute the length of a string as it appears on the terminal.
- anemoi.utils.text.boxed(text: str, min_width: int = 80, max_width: int = 80) str
Put a box around a text.
>>> boxed("Hello,\nWorld!", max_width=40) ┌──────────────────────────────────────────┐ │ Hello, │ │ World! │ └──────────────────────────────────────────┘
- class anemoi.utils.text.Tree(actor: Any, parent: Tree | None = None)
Bases:
objectTree data structure.
- Parameters:
actor (Any) – The actor associated with the tree node.
parent (Tree, optional) – The parent tree node, by default None.
- adopt(kid: Tree) None
Adopt a child tree node.
- Parameters:
kid (Tree) – The child tree node to adopt.
- as_dict() dict
Convert the tree node to a dictionary.
- Returns:
The dictionary representation of the tree node.
- Return type:
- anemoi.utils.text.table(rows: list[list[Any]], header: list[str], align: list[str], margin: int = 0) str
Format a table.
>>> table([['Aa', 12, 5], ['B', 120, 1], ['C', 9, 123]], ['C1', 'C2', 'C3'], ['<', '>', '>']) C1 │ C2 │ C3 ───┼─────┼──── Aa │ 12 │ 5 B │ 120 │ 1 C │ 9 │ 123 ───┴─────┴────
- Parameters:
- Returns:
A table as a string
- Return type: