dotfiles_tree
Group chezmoi-managed dotfiles into a nested tree for the "Sync dotfiles" tab.
chezmoi_managed_paths() returns a flat list of absolute file paths. This module
groups them by path segment (relative to a root, normally the user's home
directory) so the frontend can render a folder tree with per-folder cascading
selection instead of one long flat list.
DotfileTreeNode
¶
Bases: BaseModel
A single node in the dotfiles tree.
Leaf nodes (files) have path set; directory nodes have path=None and
one or more children, keyed by path segment name.
Source code in src/personal_os_setup/frontend/dotfiles_tree.py
is_file
property
¶
Whether this node represents a file rather than a directory.
all_file_paths()
¶
Return every file path in this node's subtree.
Returns:
| Type | Description |
|---|---|
list[Path]
|
|
list[Path]
|
found recursively under its children. |
Source code in src/personal_os_setup/frontend/dotfiles_tree.py
build_dotfiles_tree(paths, root, root_label='~')
¶
Group flat absolute file paths into a nested tree relative to a root.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
paths
|
list[Path]
|
Absolute file paths, e.g. from |
required |
root
|
Path
|
The directory paths are grouped relative to (normally |
required |
root_label
|
str
|
Display name for the tree's root node. |
'~'
|
Returns:
| Type | Description |
|---|---|
DotfileTreeNode
|
The tree's root node; its children are the top-level path segments. |
DotfileTreeNode
|
Paths not under |
DotfileTreeNode
|
being grouped by their full parts instead of raising. |