MCPcopy Create free account
hub / github.com/ActiveState/code / strfbytes

Function strfbytes

recipes/Python/576777_Simple_FTP_Mirror/recipe-576777.py:80–88  ·  view source on GitHub ↗
(value)

Source from the content-addressed store, hash-verified

78 sys.exit(1)
79
80def strfbytes(value):
81 units = ['Bytes', 'KB', 'MB', 'GB', 'TB']
82 value = float(value)
83 for unit in units:
84 if value < 1024: break
85 value = value / 1024
86 if unit == units[0]: fmt = '%.0f %s'
87 else: fmt = '%.2f %s'
88 return fmt % (value, unit)
89
90
91class localHandler:

Callers 2

mirrorFunction · 0.85
mainFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected