MCPcopy Create free account
hub / github.com/pydata/numexpr / to_friendly_bytes

Function to_friendly_bytes

numexpr3/cpuinfo.py:385–401  ·  view source on GitHub ↗
(input)

Source from the content-addressed store, hash-verified

383 return ticks
384
385def to_friendly_bytes(input):
386 if not input:
387 return input
388 input = "{0}".format(input)
389
390 formats = {
391 r"^[0-9]+B$" : 'B',
392 r"^[0-9]+K$" : 'KB',
393 r"^[0-9]+M$" : 'MB',
394 r"^[0-9]+G$" : 'GB'
395 }
396
397 for pattern, friendly_size in formats.items():
398 if re.match(pattern, input):
399 return "{0} {1}".format(input[ : -1].strip(), friendly_size)
400
401 return input
402
403def _parse_cpu_string(cpu_string):
404 # Get location of fields at end of string

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…