MCPcopy Create free account
hub / github.com/SecurityInnovation/PGPy / Mebibyte

Class Mebibyte

test_load_asc_bench.py:25–43  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

23 sys.stderr.write("Error: {} does not exist\n".write())
24
25class Mebibyte(int):
26 iec = {1: 'B',
27 1024: 'KiB',
28 1024**2: 'MiB',
29 1024**3: 'GiB',
30 1024**4: 'TiB',
31 1024**5: 'PiB',
32 1024**6: 'EiB',
33 1024**7: 'ZiB',
34 1024**8: 'YiB'}
35 iecl = [1, 1024, 1024**2, 1024**3, 1024**4, 1024**5, 1024**6, 1024**7, 1024**8]
36
37 # custom format class for human readable IEC byte formatting
38 def __format__(self, spec):
39 # automatically format based on size
40
41 iiec = max(0, min(bisect.bisect_right(self.iecl, int(self)), len(self.iecl)))
42 ieck = self.iecl[iiec - 1]
43 return '{:,.2f} {:s}'.format(int(self) / ieck, self.iec[ieck])
44
45
46@asyncio.coroutine

Callers 2

updateMethod · 0.85

Calls

no outgoing calls

Tested by 1

updateMethod · 0.68

Used in the wild real call sites across dependent graphs

searching dependent graphs…