MCPcopy
hub / github.com/blackboxo/CleanMyWechat / format_size

Function format_size

main.py:141–153  ·  view source on GitHub ↗
(size)

Source from the content-addressed store, hash-verified

139
140
141def format_size(size):
142 try:
143 size = float(size)
144 except Exception:
145 return "0 B"
146 units = ["B", "KB", "MB", "GB", "TB"]
147 index = 0
148 while size >= 1024 and index < len(units) - 1:
149 size = size / 1024
150 index += 1
151 if index == 0:
152 return f"{int(size)} {units[index]}"
153 return f"{size:.2f} {units[index]}"
154
155
156def normalize_ext(ext):

Callers 4

add_file_if_matchMethod · 0.85
build_preview_textMethod · 0.85
show_preview_dialogMethod · 0.85
callbackMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected