hfutils.entry.tree
This module provides functionality for listing and displaying files from a HuggingFace repository in a tree-like structure.
It includes functions for parsing repository paths, retrieving file information, and formatting the output as a tree. The module also defines a CLI command for easy interaction with the tree functionality.
Key components:
TreeItem: A dataclass representing an item (file or folder) in the tree structure.
_get_tree: Function to retrieve the tree structure of files in a HuggingFace repository.
_add_tree_subcommand: Function to add the ‘tree’ subcommand to a Click CLI group.
Usage: This module is typically used as part of a larger CLI application for interacting with HuggingFace repositories. The ‘tree’ command can be used to visualize the structure of files in a repository.
TreeItem
- class hfutils.entry.tree.TreeItem(name: str, type_: FileItemType, children: List[TreeItem] | None, exist: bool = True)[source]
Represents an item (file or folder) in the tree structure.
- Parameters:
name (str) – The name of the item.
type (FileItemType) – The type of the item (file or folder).
children (Optional[List[TreeItem]]) – List of child items if this is a folder.
exist (bool) – Whether the item exists in the repository.
- Variables:
name – The name of the item.
type – The type of the item.
children – List of child items.
exist – Existence status of the item.