17 def next_snapshot(self) -> Snapshot:
18 root_name: Optional[str] = self.peek_key()
19 snapshot: Snapshot = Snapshot.of(self.value_reader.next_value())
20 while True:
21 next_key: Optional[str] = self.value_reader.peek_key()
22 if next_key is None or next_key == "[end of file]":
23 break
24 facet_idx: int = next_key.find("[")
25 if facet_idx == -1:
26 break
27 else:
28 facet_root, facet_name = (
29 next_key[:facet_idx],
30 next_key[facet_idx + 1 : -1],
31 )
32 if facet_root == root_name:
33 facet_value = self.value_reader.next_value()
34 snapshot = snapshot.plus_facet(facet_name, facet_value)
35 else:
36 break
37 return snapshot
38