afnio.utils.datasets.utils
afnio.utils.datasets.utils.calculate_md5(fpath, chunk_size=1024 * 1024)
Calculates the MD5 checksum of a file.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
fpath
|
str | Path
|
Path to the file. |
required |
chunk_size
|
int
|
Size of the chunks to read from the file. |
1024 * 1024
|
Returns:
| Type | Description |
|---|---|
str
|
MD5 checksum of the file. |
Source code in afnio/utils/datasets/utils.py
54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 | |
afnio.utils.datasets.utils.check_md5(fpath, md5, **kwargs)
Checks the MD5 checksum of a file.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
fpath
|
str | Path
|
Path to the file. |
required |
md5
|
str
|
Expected MD5 checksum of the file. |
required |
**kwargs
|
Any
|
Additional arguments to pass to |
{}
|
Returns:
| Type | Description |
|---|---|
bool
|
True if the MD5 checksum matches, False otherwise. |
Source code in afnio/utils/datasets/utils.py
79 80 81 82 83 84 85 86 87 88 89 90 | |
afnio.utils.datasets.utils.check_integrity(fpath, md5=None)
Checks the integrity of a file.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
fpath
|
str | Path
|
Path to the file. |
required |
md5
|
str | None
|
Expected MD5 checksum of the file. If None, only checks if the file exists. |
None
|
Returns:
| Type | Description |
|---|---|
bool
|
|
Source code in afnio/utils/datasets/utils.py
93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 | |
afnio.utils.datasets.utils.download_url(url, root, filename=None, md5=None, max_redirect_hops=3)
Download a file from a url and place it in root.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
url
|
str
|
URL to download file from. |
required |
root
|
str | Path
|
Directory to place downloaded file in. |
required |
filename
|
str | Path | None
|
Name to save the file under. If |
None
|
md5
|
str | None
|
MD5 checksum of the download. If |
None
|
max_redirect_hops
|
int
|
Maximum number of redirect hops allowed. |
3
|
Source code in afnio/utils/datasets/utils.py
111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 | |
afnio.utils.datasets.utils.download(url, download_root, extract_root=None, filename=None, md5=None, remove_finished=False)
Downloads a file from a URL and optionally extracts it.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
url
|
str
|
URL to download file from. |
required |
download_root
|
str | Path
|
Directory to place downloaded file in. |
required |
extract_root
|
str | Path | None
|
Directory to extract the file to.
If |
None
|
filename
|
str | Path | None
|
Name to save the file under. If |
None
|
md5
|
str | None
|
MD5 checksum of the download. If |
None
|
remove_finished
|
bool
|
Whether to remove the downloaded file after extraction. |
False
|
Source code in afnio/utils/datasets/utils.py
159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 | |