Account: Hierarchical Account Path#
- class means.types.Account.Account(root: RootModelRootType = PydanticUndefined)#
A hierarchical account path, stored as a tuple of colon-delimited segments.
I Construction and Templates#
- classmethod Account.new(val: str | tuple[str, ...] | Iterable[str]) Account#
Build an account from a path string, a tuple/iterable of segments, or another account.
- Parameters:
val – A colon-delimited path string, segment collection, or
Accountto copy.- Returns:
The constructed (or copied) account.
- classmethod Account.setup(root: Annotated[Path, PathType(path_type=dir)]) None#
Load the account and template registries from the given data directory.
Idempotent: does nothing if the class has already been set up.
- Parameters:
root – The means data directory containing
accounts.ledgerand parameter files.
- classmethod Account.build_template(node: dict[str, Any], parent: Account | None = None) dict[Account, list[tuple[Pattern, str]]]#
Parse a dictionary tree from YAML into template accounts and their regex pairs.
Each node can contain children nodes and/or leaf nodes, each of which represents a regex/replacement pair. Each leaf is associated with a full account path built by concatenating all of its parents with colon delimiters, such as
r:expenses:shopping.- Parameters:
node – A dictionary node from a yaml file.
parent – The account path built from this node’s parents. Should be left blank when calling on the root node.
- Returns:
A mapping of each template account to its regex/replacement pairs.