StorageUnit Enum¶
StorageUnit
¶
Bases: Enum
Enumeration of storage units with their byte conversion factors.
This enum defines both binary (base 1024) and decimal (base 1000) storage units commonly used in computing and storage devices.
Binary units (powers of 1024): - BYTES, KIB, MIB, GIB, TIB, PIB, EIB, ZIB, YIB
Decimal units (powers of 1000): - KB, MB, GB, TB, PB, EB, ZB, YB
Bit units
- BITS, KILOBITS, MEGABITS, GIGABITS, TERABITS
Each enum value represents the number of bytes in one unit.
Functions¶
get_unit_aliases() -> Dict[str, StorageUnit]
classmethod
¶
Get a mapping of unit name aliases to StorageUnit enum values.
This mapping supports case-insensitive parsing of unit names including common abbreviations and alternative spellings.
Returns:
Type | Description |
---|---|
Dict[str, StorageUnit]
|
Dict[str, StorageUnit]: Mapping of lowercase unit names to enum values. |
get_binary_units() -> Set[StorageUnit]
classmethod
¶
Get a set of binary storage units (powers of 1024).
Returns:
Type | Description |
---|---|
Set[StorageUnit]
|
Set[StorageUnit]: Set of binary storage units. |
get_decimal_units() -> Set[StorageUnit]
classmethod
¶
Get a set of decimal storage units (powers of 1000).
Returns:
Type | Description |
---|---|
Set[StorageUnit]
|
Set[StorageUnit]: Set of decimal storage units. |
get_bit_units() -> Set[StorageUnit]
classmethod
¶
Get a set of bit-based storage units.
Returns:
Type | Description |
---|---|
Set[StorageUnit]
|
Set[StorageUnit]: Set of bit storage units. |
get_special_units() -> Set[StorageUnit]
classmethod
¶
Get a set of special storage units (e.g., AUTO).
Returns:
Type | Description |
---|---|
Set[StorageUnit]
|
Set[StorageUnit]: Set of special storage units. |
is_binary() -> bool
¶
Check if this unit is a binary unit (power of 1024).
Returns:
Name | Type | Description |
---|---|---|
bool |
bool
|
True if this is a binary unit, False otherwise. |
is_decimal() -> bool
¶
Check if this unit is a decimal unit (power of 1000).
Returns:
Name | Type | Description |
---|---|---|
bool |
bool
|
True if this is a decimal unit, False otherwise. |
is_bit_unit() -> bool
¶
Check if this unit is a bit-based unit.
Returns:
Name | Type | Description |
---|---|---|
bool |
bool
|
True if this is a bit unit, False otherwise. |