MCPcopy
hub / github.com/alexta69/metube / load

Method load

app/state_store.py:79–94  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

77 return payload
78
79 def load(self) -> Optional[dict[str, Any]]:
80 if not os.path.exists(self.path):
81 return None
82 try:
83 with open(self.path, encoding="utf-8") as f:
84 payload = json.load(f)
85 if not isinstance(payload, dict):
86 raise ValueError("State file must contain a JSON object")
87 if payload.get("kind") != self.kind:
88 raise ValueError(
89 f"State file kind mismatch: expected {self.kind}, got {payload.get('kind')}"
90 )
91 return payload
92 except Exception as exc:
93 self.quarantine_invalid_file(exc)
94 return None
95
96 def save(self, data: dict[str, Any]) -> None:
97 self._ensure_parent()

Calls 3

existsMethod · 0.80
getMethod · 0.45