utils
This module contains a set of generic purpose helpers
basename(pth)
¶
Returns the basename. Works with files and paths.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
pth |
str
|
path |
required |
Returns:
| Type | Description |
|---|---|
str
|
basename of the path |
download(url, out_filename, nb_retries=5)
¶
Download a remote file.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
url |
str
|
url of the file to download |
required |
out_filename |
str
|
local file name for the downloaded file |
required |
nb_retries |
number of retries |
5
|
Source code in scenes/utils.py
find_file_in_dir(pth, pattern)
¶
Returns the list of files matching the pattern in the input directory.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
pth |
str
|
path |
required |
pattern |
str
|
pattern |
required |
Returns:
| Type | Description |
|---|---|
List[str]
|
list of str |
Source code in scenes/utils.py
find_files_in_all_subdirs(pth, pattern, case_sensitive=True)
¶
Returns the list of files matching the pattern in all subdirectories of pth
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
pth |
str
|
path |
required |
pattern |
str
|
pattern |
required |
case_sensitive |
bool
|
boolean (Default value = True) |
True
|
Returns:
| Type | Description |
|---|---|
List[str]
|
list of str |
Source code in scenes/utils.py
get_parent_directory(pth)
¶
Return the parent directory of the input directory or file.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
pth |
str
|
input directory or file |
required |
Returns:
| Type | Description |
|---|---|
str
|
parent directory |
Source code in scenes/utils.py
list_files_in_zip(filename, endswith=None)
¶
List files in zip archive.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
filename |
str
|
path of the zip |
required |
endswith |
str
|
optional, end of filename to be matched (Default value is None) |
None
|
Returns:
| Type | Description |
|---|---|
List[str]
|
list of filepaths |
Source code in scenes/utils.py
pprint(dic)
¶
Returns a str pretty-printing the input dict.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
dic |
dict
|
dictionary |
required |
Returns:
| Type | Description |
|---|---|
str
|
string |
to_vsizip(zipfn, relpth)
¶
Create path from zip file.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
zipfn |
str
|
zip archive |
required |
relpth |
str
|
relative path (inside archive) |
required |
Returns:
| Type | Description |
|---|---|
str
|
vsizip path |