solidipes.scanners.scanner module

class solidipes.scanners.scanner.DictTree(*args, **kwargs)[source]

Bases: dict

apply(func: Callable) DictTree[source]

Apply a function to all values in the tree.

count_leaves() int[source]

Count the number of leaves in the tree.

filter(value_filter: ~typing.Callable = <function DictTree.<lambda>>, keys_join_func: ~typing.Callable[[list[str]], str] = <function DictTree.<lambda>>, joined_keys_filter: ~typing.Callable = <function DictTree.<lambda>>, keep_empty_dicts: bool = False, keys: list[str] = []) DictTree[source]

Filter the tree based on the values and keys. Both filters must be satisfied.

flatten(value_func: ~typing.Callable = <function DictTree.<lambda>>, keys_join_func: ~typing.Callable[[list[str]], str] = <function DictTree.<lambda>>, add_dicts: bool = False, dict_func: ~typing.Callable = <function DictTree.<lambda>>, keys: list[str] = []) dict[source]

Flatten the tree into a flat dictionary.

reduce(func: Callable, initial: Any) Any[source]

Reduce the tree to a single value.

class solidipes.scanners.scanner.ExportScanner(root_path: str = '.')[source]

Bases: Scanner

A scanner that keeps the .solidipes directory. Individual paths inside .solidipes can still be excluded.

is_excluded(path: str, excluded_patterns: Set[str] | None = None) bool[source]

Check whether the provided path is excluded by any of the scanner’s patterns

solidipes.scanners.scanner.FilepathTree

alias of DictTree

solidipes.scanners.scanner.LoaderTree

alias of DictTree

class solidipes.scanners.scanner.ProgressBar(*args, **kwargs)[source]

Bases: Protocol

_abc_impl = <_abc._abc_data object>
_is_protocol = True
close() None[source]
reset() None[source]
set_postfix_str(desc: str) None[source]
total: float
update(n: float | None) bool | None[source]
class solidipes.scanners.scanner.Scanner(root_path: str = '.')[source]

Bases: object

A class to scan a directory to load files and groups.

All paths are given relative to the scanner’s root path.

get_dirpath_tree(*args, force_rescan: bool = False, **kwargs)[source]
get_filepath_list(*args, force_rescan: bool = False, **kwargs)[source]
get_filepath_tree(*args, force_rescan: bool = False, **kwargs)[source]
get_filtered_loader_dict(dirs: list[str] = [], recursive: bool = True) dict[str, File | Group][source]

Get a dictionary mapping paths (potentially grouped) to loaders.

get_filtered_loader_tree(dirs: list[str] = [], recursive: bool = True) DictTree[source]

Get a tree of loaders for the given directories.

get_loader_dict(*args, force_rescan: bool = False, **kwargs)[source]
get_loader_path_list(*args, force_rescan: bool = False, **kwargs)[source]
get_loader_tree(*args, force_rescan: bool = False, **kwargs)[source]
get_modified_time(*args, force_rescan: bool = False, **kwargs)[source]
get_path_list(*args, force_rescan: bool = False, **kwargs)[source]
get_total_size(*args, force_rescan: bool = False, **kwargs)[source]
is_excluded(path: str, excluded_patterns: Set[str] | None = None) bool[source]

Check whether the provided path is excluded by any of the scanner’s patterns

scan()[source]

Trigger the creation of loaders.

class solidipes.scanners.scanner.StreamlitProgressBar(text, container=None)[source]

Bases: ProgressBar

_abc_impl = <_abc._abc_data object>
_is_protocol = False
_update()[source]
close()[source]
reset()[source]
set_postfix_str(desc: str)[source]
update(value)[source]
solidipes.scanners.scanner.cached_scan(func: Callable) Callable[source]

Decorator to cache the result of the scan.

Adds a “force_rescan” parameter to the decorated function. Assumes that the result of the scan only depends on root_path and excluded_patterns.

solidipes.scanners.scanner.convert_filepath_tree_to_loader_tree(tree: DictTree, root_path: str, progress_bar: ProgressBar | None = None) DictTree[source]

Convert a tree of filepaths to a tree of loaders, while detecting file groups.

solidipes.scanners.scanner.list_files(found, current_dir='')[source]