Common utils
Common set of miscellaneous functions.
expand_paths(paths, *, ignore=('!*',), rglob='*.ipynb')
Get paths of existing file from list of directory or file paths.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
paths
|
List[Path]
|
Paths to consider (can be directories or files) |
required |
ignore
|
Sequence[str]
|
Glob expressions of files to ignore |
('!*',)
|
rglob
|
str
|
Glob expression for expanding directory paths and filtering out existing file paths (i.e.: to retrieve only notebooks) |
'*.ipynb'
|
Returns:
| Type | Description |
|---|---|
Optional[List[Path]]
|
List of existing file paths |
Source code in databooks/common.py
12 13 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 | |
find_common_parent(paths)
Find common parent amongst several file paths (includes current path).
Source code in databooks/common.py
47 48 49 50 51 | |
find_obj(obj_name, start, finish, is_dir=False)
Recursively find file along directory path, from the end (child) directory to start.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
obj_name
|
str
|
File name to locate |
required |
start
|
Path
|
Start (parent) directory |
required |
finish
|
Path
|
Finish (child) path |
required |
is_dir
|
bool
|
Whether object is a directory or a file |
False
|
Returns:
| Type | Description |
|---|---|
Optional[Path]
|
File path |
Source code in databooks/common.py
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 79 80 81 82 83 84 85 86 87 | |