Debian Codegraph @

DisplayCAL/jsondict.py

raw
1 """Provides JSONDict, a lazy-loading JSON dictionary.
2
3 It allows efficient parsing and manipulation of JSON files by loading data only
4 when accessed.
5 """
6
7 from typing import TextIO
8
9 import demjson_compat
10
11 from DisplayCAL.lazydict import LazyDict
12
13
14 class JSONDict(LazyDict):
15 """JSON lazy dictionary."""
16
17 def parse(self, fileobj: TextIO) -> None:
18 """Parse the JSON data from the given file object.
19
20 Args:
21 fileobj (TextIO): A file-like object containing JSON
22 data.
23 """
24 dict.update(self, demjson_compat.decode(fileobj.read()))