MCPcopy Create free account
hub / github.com/defold/defold / progress_bar

Function progress_bar

editor/scripts/bundle.py:147–161  ·  view source on GitHub ↗
(label, count, total, url, width=40)

Source from the content-addressed store, hash-verified

145 assert False, "Don't know how to extract " + file
146
147def progress_bar(label, count, total, url, width=40):
148 is_tty = sys.stdout.isatty()
149 if is_tty:
150 percent = count / total if total else 0
151 filled = int(width * percent)
152 bar = '[%s%s]' % ('#' * filled, '.' * (width - filled))
153 done = total and count >= total
154 suffix = " ✅" if done else ""
155 sys.stdout.write(f"\r{label} {bar} {percent:6.2%}{suffix}")
156 sys.stdout.flush()
157 if done:
158 sys.stdout.write("\n")
159 sys.stdout.flush()
160 else:
161 log('Downloading %s %.2f%%' % (url, 100 * count / float(total)))
162
163def download(label, url):
164 label = 'Downloading %s...' % label

Callers 1

downloadFunction · 0.85

Calls 4

logFunction · 0.70
floatFunction · 0.50
writeMethod · 0.45
flushMethod · 0.45

Tested by

no test coverage detected