(self, include_unit: bool = True)
| 411 | return f'{target_size.value}' |
| 412 | |
| 413 | def binary_unit_highest(self, include_unit: bool = True) -> str: |
| 414 | binary_units = Unit.get_binary_units() |
| 415 | |
| 416 | size = float(self._normalize()) |
| 417 | unit = Unit.KiB |
| 418 | base_value = unit.value |
| 419 | |
| 420 | for binary_unit in binary_units: |
| 421 | unit = binary_unit |
| 422 | if size < base_value: |
| 423 | break |
| 424 | size /= base_value |
| 425 | |
| 426 | formatted_size = f'{size:.1f}' |
| 427 | |
| 428 | if formatted_size.endswith('.0'): |
| 429 | formatted_size = formatted_size[:-2] |
| 430 | |
| 431 | if not include_unit: |
| 432 | return formatted_size |
| 433 | |
| 434 | return f'{formatted_size} {unit.name}' |
| 435 | |
| 436 | def si_unit_highest(self, include_unit: bool = True) -> str: |
| 437 | si_units = Unit.get_si_units() |
no test coverage detected