MCPcopy Create free account
hub / github.com/FastLED/FastLED / _load

Method _load

ci/util/version_lockfile.py:42–69  ·  view source on GitHub ↗

Load lockfile data from disk.

(self)

Source from the content-addressed store, hash-verified

40 self._data: Optional[dict[str, Any]] = None
41
42 def _load(self) -> dict[str, Any]:
43 """Load lockfile data from disk."""
44 if self._data is not None:
45 return self._data
46
47 if not self.lockfile_path.exists():
48 self._data = {
49 "version": "1.0",
50 "created_at": datetime.now().isoformat(),
51 "packages": {},
52 }
53 return self._data
54
55 try:
56 with open(self.lockfile_path, "r") as f:
57 data = json.load(f)
58 assert isinstance(data, dict), "Lockfile must contain a JSON object"
59 self._data = cast(dict[str, Any], data)
60 return self._data
61 except (json.JSONDecodeError, OSError) as e:
62 logger.warning(f"Failed to load lockfile {self.lockfile_path}: {e}")
63 logger.warning("Creating new lockfile")
64 self._data = {
65 "version": "1.0",
66 "created_at": datetime.now().isoformat(),
67 "packages": {},
68 }
69 return self._data
70
71 def _save(self) -> bool:
72 """Save lockfile data to disk with locking."""

Callers 5

get_pinned_versionMethod · 0.95
pin_versionMethod · 0.95
clear_pinsMethod · 0.95
upgrade_packageMethod · 0.95
list_pinsMethod · 0.95

Calls 3

warningMethod · 0.80
nowMethod · 0.45
loadMethod · 0.45

Tested by

no test coverage detected