datumaro.util.os_util#
Functions
|
|
|
|
|
|
|
Extract subset name from the given url. |
|
|
|
Generates the "next" name by appending a next index to the occurrence of the basename with the highest index in the input collection. |
|
|
|
|
|
Tests if a path is subpath of another path or the paths are equal. |
Normalizes string, converts to lowercase, removes non-alpha characters, and converts spaces to hyphens. |
|
|
|
|
|
|
- datumaro.util.os_util.walk(path, max_depth: int | None = None, min_depth: int | None = None)[source]#
- datumaro.util.os_util.find_files(dirpath: str, exts: str | Iterable[str], recursive: bool = False, max_depth: int | None = None, min_depth: int | None = None) Iterator[str] [source]#
- datumaro.util.os_util.is_subpath(path: str, base: str) bool [source]#
Tests if a path is subpath of another path or the paths are equal.
- datumaro.util.os_util.make_file_name(s: str) str [source]#
Normalizes string, converts to lowercase, removes non-alpha characters, and converts spaces to hyphens.
- datumaro.util.os_util.generate_next_name(names: Iterable[str], basename: str, sep: str = '.', suffix: str = '', default: str | None = None) str [source]#
Generates the “next” name by appending a next index to the occurrence of the basename with the highest index in the input collection.
Returns: next string name
Example:
- Inputs:
name_abc
name_base
name_base1
name_base5
Basename: name_base
Output: name_base6
- datumaro.util.os_util.extract_subset_name_from_parent(url: str, start: str) str [source]#
Extract subset name from the given url.
For example, if url = “/a/b/images/train/img.jpg” and start = “/a/b”, it will return “train”. On the other hand, if url = “/a/b/images/img.jpg” and start = “/a/b”, it will return DEFAULT_SUBSET_NAME.