API Reference
Find and group files together using glob-like patterns.
A single pattern will create a tag with a default name:
"data/image_{index}.png"
{"001": {"default": "data/image_001.png"}, "002": {"default": "data/image_002.png"}...}
.
A dictionary will create one tag for each key in the dictionary. The values of the dictionary can be either a pattern, or a dictionary specifying tag-specific options, e.g.:
{
"image": "data/{year}/image_{index}.png",
"legend": {
"spec": "legends/legend_*_{year}_{index}.txt,
"allow_multiple": True,
"on_missing": "ignore",
}
}
image
and legend
, the latter being optional and accepting multiple files.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
patterns |
Union[TagSpec, Dict[str, TagSpec]]
|
describes how to find and group files. It can be a single pattern (in which case a tag with a default name will be created) or a mapping from tag names to patterns. For tag-specific options (i.e. indicate what to do if a tag is missing from a group), a mapping from tag names to tag options can be provided |
required |
root_dir |
Union[str, Path]
|
where to look for files. |
required |
key_formatter |
Union[str, Callable[[MultiPartKey], GroupKey], None]
|
specify how to format keys. By default, all key parts (such as |
None
|
use_relative_paths |
bool
|
if True, return paths relative to |
False
|
squeeze |
bool
|
if True, the output will be squeezed when possible (i.e. tag will be omitted from the output if it is not ambiguous) |
True
|
with_keys |
Optional[bool]
|
whether to include the group keys in the output |
None
|
compress_to_list |
bool
|
if True, the value of |
True
|
Returns:
Type | Description |
---|---|
FormattedGroups
|
files matching |
Source code in grob/core/finder.py
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 |
|
options: show_root_toc_entry: true show_root_heading: true show_signature: false show_source: false