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

Method reportHook

Modules/Scripted/SampleData/SampleData.py:1108–1117  ·  view source on GitHub ↗
(self, blocksSoFar, blockSize, totalSize)

Source from the content-addressed store, hash-verified

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
1110 percent = min(int((100.0 * blocksSoFar * blockSize) / totalSize), 100)
1111 if percent == 100 or (percent - self.downloadPercent >= 10):
1112 # we clamp to totalSize when blockSize is larger than totalSize
1113 humanSizeSoFar = self.humanFormatSize(min(blocksSoFar * blockSize, totalSize))
1114 humanSizeTotal = self.humanFormatSize(totalSize)
1115 self.logMessage("<i>" + _("Downloaded {sizeCompleted} ({percentCompleted}% of {sizeTotal})...").format(
1116 sizeCompleted=humanSizeSoFar, percentCompleted=percent, sizeTotal=humanSizeTotal) + "</i>")
1117 self.downloadPercent = percent
1118
1119 @staticmethod
1120 def rewriteUrl(url):

Callers

nothing calls this directly

Calls 3

humanFormatSizeMethod · 0.95
logMessageMethod · 0.95
formatMethod · 0.45

Tested by

no test coverage detected