Module ds.searchers

Find keys, names, directories and files.

Global variables

var GlobMatches

Mapping a path to whether it should be included.

Functions

def get_key(src: Dict[str, Any], name: Union[str, List[str]], default: Optional[Any] = None) ‑> Any

Return value of name within src or default if it's missing.

>>> get_key({"a": {"b": {"c": 1}}}, "a.b.c") == 1
True
>>> get_key({"a": {"b": {"c": 1}}}, ["a", "b", "c"]) == 1
True
def glob_parents(start: pathlib.Path, patterns: Dict[str, str]) ‑> Iterator[Tuple[str, pathlib.Path]]

Yield glob matches in every parent.

def glob_names(names: Iterable[str], patterns: List[str]) ‑> List[str]

Return the names of tasks that match patterns.

Prefixing a pattern with ! will remove that matched pattern from the result.

>>> names = ['cab', 'car', 'cat', 'crab']
>>> glob_names(names, ['c?r', 'c*b'])
['cab', 'car', 'crab']
>>> glob_names(names, ['*', '!crab'])
['cab', 'car', 'cat']
def glob_paths(path: pathlib.Path, patterns: List[str], *, allow_all: bool = False, allow_excludes: bool = False, allow_new: bool = False, previous: Optional[Dict[pathlib.Path, bool]] = None) ‑> Dict[pathlib.Path, bool]

Apply glob patterns to path.

>>> here = Path(__file__).resolve()
>>> members = {here: False}
>>> glob_paths(
...     here.parent,
...     ["*.py"],
...     allow_new=False,
...     previous=members) == {here: True}
True