(num_bytes: int)
| 170 | UNITS = ("B", "KB", "MB", "GB", "TB", "PB") |
| 171 | |
| 172 | def format_size(num_bytes: int) -> str: |
| 173 | s = float(max(0, num_bytes)) |
| 174 | unit = 0 |
| 175 | while s >= 1024.0 and unit < len(UNITS) - 1: |
| 176 | s /= 1024.0 |
| 177 | unit += 1 |
| 178 | return f"{s:.2f} {UNITS[unit]}" |
| 179 | |
| 180 | def safe_lstat(path: Path) -> Optional[os.stat_result]: |
| 181 | try: |
no outgoing calls
no test coverage detected