File size: 488 Bytes
065fee7
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
import json
import io
from time import time
from rich.console import Console
from rich.pretty import Pretty


console = Console(file=io.StringIO(), color_system="truecolor", width=100)

with open("cats.json") as fh:
    cats = json.load(fh)


console.begin_capture()
start = time()
pretty = Pretty(cats)
console.print(pretty, overflow="ignore", crop=False)
result = console.end_capture()
taken = (time() - start) * 1000
print(result)

print(console.file.getvalue())
print(f"{taken:.1f}")