mirror of
https://github.com/Stone-Red-Code/dvc.git
synced 2026-11-10 23:10:42 +01:00
* config: Support ~/.aws/config parsing * skip when the ~/.aws/config doesn't exist * Expand windows paths properly
25 lines
625 B
Python
25 lines
625 B
Python
# https://github.com/aws/aws-cli/blob/5aa599949f60b6af554fd5714d7161aa272716f7/awscli/customizations/s3/utils.py
|
|
|
|
MULTIPLIERS = {
|
|
"kb": 1024,
|
|
"mb": 1024 ** 2,
|
|
"gb": 1024 ** 3,
|
|
"tb": 1024 ** 4,
|
|
"kib": 1024,
|
|
"mib": 1024 ** 2,
|
|
"gib": 1024 ** 3,
|
|
"tib": 1024 ** 4,
|
|
}
|
|
|
|
|
|
def human_readable_to_bytes(value):
|
|
value = value.lower()
|
|
suffix = None
|
|
if value.endswith(tuple(MULTIPLIERS.keys())):
|
|
size = 2
|
|
size += value[-2] == "i" # KiB, MiB etc
|
|
value, suffix = value[:-size], value[-size:]
|
|
|
|
multiplier = MULTIPLIERS.get(suffix, 1)
|
|
return int(value) * multiplier
|