MCPcopy Create free account
hub / github.com/emscripten-core/emscripten / limit_size

Function limit_size

test/common.py:189–207  ·  view source on GitHub ↗
(string)

Source from the content-addressed store, hash-verified

187
188
189def limit_size(string):
190 maxbytes = 800000 * 20
191 if sys.stdout.isatty():
192 maxlines = 500
193 max_line = 500
194 else:
195 max_line = 5000
196 maxlines = 1000
197 lines = string.splitlines()
198 for i, line in enumerate(lines):
199 if len(line) > max_line:
200 lines[i] = line[:max_line] + '[..]'
201 if len(lines) > maxlines:
202 lines = lines[0:maxlines // 2] + ['[..]'] + lines[-maxlines // 2:]
203 lines.append('(not all output shown. See `limit_size`)')
204 string = '\n'.join(lines) + '\n'
205 if len(string) > maxbytes:
206 string = string[0:maxbytes // 2] + '\n[..]\n' + string[-maxbytes // 2:]
207 return string
208
209
210def create_file(name, contents, binary=False, absolute=False):

Callers 4

run_jsMethod · 0.85
assertIdenticalMethod · 0.85
assertContainedMethod · 0.85
assertNotContainedMethod · 0.85

Calls 2

appendMethod · 0.80
joinMethod · 0.45

Tested by

no test coverage detected