isimip_utils.fetch
Functions to fetch files from urls or local paths.
fetch_json(url)
Fetch JSON content from a URL.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
url
|
str
|
URL to fetch JSON from. |
required |
Returns:
| Type | Description |
|---|---|
Any | None
|
Parsed JSON object, or None if request fails. |
fetch_file(url, target=None)
Download file from a URL.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
url
|
str
|
URL to download file from. |
required |
target
|
str | Path
|
Target path, or None if the content should be returned. |
None
|
Returns:
| Type | Description |
|---|---|
bool
|
Target path if it was provided, the content otherwise, or None if the request fails. |
load_json(path)
Load JSON content from a local path.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path
|
str | Path
|
Path to load the JSON from. |
required |
Returns:
| Type | Description |
|---|---|
Any | None
|
Parsed JSON object, or None if request fails. |
load_file(path, target=None)
Copy a file from a local path.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path
|
str | Path
|
Path to copy the file from. |
required |
target
|
str | Path
|
Target path, or None if the content should be returned. |
None
|
Returns:
| Type | Description |
|---|---|
bool
|
Target path if it was provided, the content otherwise, or None if the request fails. |