gpt_engineer.applications.cli.file_selector.DisplayablePath
- class gpt_engineer.applications.cli.file_selector.DisplayablePath(path: str | Path, parent_path: DisplayablePath, is_last: bool)[source]
Bases:
objectRepresents and displays a file system path in a tree-like structure.
This class is used to visually represent the structure of directories and files in a way that is similar to a file explorer’s tree view.
Initializes a DisplayablePath object with a given path and parent.
- Parameters:
path (Union[str, Path]) – The file system path to be displayed.
parent_path (DisplayablePath) – The parent path in the tree structure.
is_last (bool) – Indicates whether this is the last sibling in the tree structure.
- displayable() str[source]
Returns a string representation of the path for display in a tree-like structure.
- Returns:
The displayable string representation of the file or directory.
- Return type:
str
- classmethod make_tree(root: str | Path, parent=None, is_last=False, criteria=None) Generator[DisplayablePath, None, None][source]
Creates a tree of DisplayablePath objects from a root directory.
- Parameters:
root (Union[str, Path]) – The root directory from which to start creating the tree.
parent (DisplayablePath, optional) – The parent path in the tree structure.
is_last (bool, optional) – Indicates whether this is the last sibling in the tree structure.
criteria (callable, optional) – A function to filter the paths included in the tree.
- Yields:
DisplayablePath – The next DisplayablePath object in the tree.
- display_filename_prefix_last = '└── '
- display_filename_prefix_middle = '├── '
- property display_name: str
Get the display name of the file or directory.
- display_parent_prefix_last = '│ '
- display_parent_prefix_middle = ' '