Skip to content

Commit 2a9f3d6

Browse files
committed
Suppress output when generating schema
1 parent 00e15e3 commit 2a9f3d6

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

python/coglet/schema.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,16 @@ def main():
1010
print(f'Usage {os.path.basename(sys.argv[0])} <MODULE> <CLASS>')
1111
sys.exit(1)
1212

13+
# Some libraries print progress upon import and mess up schema JSON
14+
_stdout_write = sys.stdout.write
15+
_stderr_write = sys.stderr.write
16+
sys.stdout.write = lambda out: len(out)
17+
sys.stderr.write = lambda out: len(out)
1318
p = inspector.create_predictor(sys.argv[1], sys.argv[2])
1419
s = schemas.to_json_schema(p)
20+
sys.stdout.write = _stdout_write
21+
sys.stderr.write = _stderr_write
22+
1523
print(json.dumps(s, indent=2))
1624

1725

0 commit comments

Comments
 (0)