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.FileStruct(filepath: str, dirpath: str, full_filepath: str, virtual: bool = False, virtual_root: str = '', entry: dict = <factory>, uri: str = '', is_file: bool = True)[source]

Bases: object

dirpath: str
entry: dict
filepath: str
full_filepath: str
is_file: bool = True
uri: str = ''
virtual: bool = False
virtual_root: str = ''
class solidipes.scanners.scanner.FilepathTree(*args, **kwargs)[source]

Bases: DictTree

solidipes.scanners.scanner.LoaderTree

alias of DictTree

class solidipes.scanners.scanner.Scanner(search_path='.', reload_excluded=True)[source]

Bases: ABC

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

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

_abc_impl = <_abc._abc_data object>
_load_excluded() None[source]
add_filepath(filestruct: FileStruct) None[source]
add_subdir(dirname, subdir) None[source]
convert_filepath_tree_to_loader_tree(filepath_tree: FilepathTree, current_dir: str = None, progress_bar: ProgressBar | None = None) DictTree[source]

Convert a tree of filepaths (relative to search path) to a tree of loaders, while detecting file groups.

abstractmethod fill_filepath_tree()[source]
get_directory_tree(dirpath='')[source]
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.

abstractmethod get_loader(filestruct: FileStruct) File | Group[source]
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() None[source]

Trigger the creation of loaders.

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 search_path and excluded_patterns.

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