Util
Utilities.
Functions:
| Name | Description |
|---|---|
calc_depth_size |
Calc Either Depth Or Size. |
split_keyvaluepairs |
Split comma-separated fields into (name, value) pairs. |
calc_depth_size
Calc Either Depth Or Size.
calc_depth_size(32, depth=64) (64, Bytesize('256 bytes')) calc_depth_size(32, size='64') (16, Bytesize('64 bytes')) calc_depth_size(32, depth=64, size=256) (64, Bytesize('256 bytes')) calc_depth_size(32) Traceback (most recent call last): ... ValueError: Either 'depth' or 'size' are required. calc_depth_size(32, depth=64, size='64') Traceback (most recent call last): ... ValueError: 'depth' and 'size' are mutually exclusive.
split_keyvaluepairs
Split comma-separated fields into (name, value) pairs.
split_keyvaluepairs('a=4') {'a': '4'} split_keyvaluepairs('a=4, b=a') {'a': '4', 'b': 'a'} split_keyvaluepairs('a=4, b') Traceback (most recent call last): ... ValueError: Invalid key=value pair: 'b' split_keyvaluepairs('a=4, a=a') Traceback (most recent call last): ... ValueError: Duplicate key 'a'