MCPcopy Create free account
hub / github.com/Slicer/Slicer / humanFormatSize

Method humanFormatSize

Modules/Scripted/SampleData/SampleData.py:1100–1106  ·  view source on GitHub ↗

from https://stackoverflow.com/questions/1094841/reusable-library-to-get-human-readable-version-of-file-size

(self, size)

Source from the content-addressed store, hash-verified

1098 return self.downloadSamples("MRUSProstate")
1099
1100 def humanFormatSize(self, size):
1101 """from https://stackoverflow.com/questions/1094841/reusable-library-to-get-human-readable-version-of-file-size"""
1102 for x in ["bytes", "KB", "MB", "GB"]:
1103 if size < 1024.0 and size > -1024.0:
1104 return f"{size:3.1f} {x}"
1105 size /= 1024.0
1106 return "{:3.1f} {}".format(size, "TB")
1107
1108 def reportHook(self, blocksSoFar, blockSize, totalSize):
1109 # we clamp to 100% because the blockSize might be larger than the file itself

Callers 1

reportHookMethod · 0.95

Calls 1

formatMethod · 0.45

Tested by

no test coverage detected