MCPcopy Create free account
hub / github.com/codenameone/CodenameOne / _locate_firefox_profile

Function _locate_firefox_profile

scripts/website/export_storage_state.py:120–146  ·  view source on GitHub ↗
(explicit: str | None)

Source from the content-addressed store, hash-verified

118
119
120def _locate_firefox_profile(explicit: str | None) -> Path:
121 if explicit and explicit != "auto":
122 path = Path(explicit).expanduser()
123 if path.is_file():
124 return path
125 if path.is_dir():
126 candidate = path / "cookies.sqlite"
127 if candidate.is_file():
128 return candidate
129 raise RuntimeError(f"Firefox cookies.sqlite not found at {path}")
130 # Auto-detect macOS Firefox profile.
131 base = Path.home() / "Library" / "Application Support" / "Firefox" / "Profiles"
132 if not base.exists():
133 # Linux / other-OS fallbacks.
134 for guess in (Path.home() / ".mozilla" / "firefox", Path.home() / "snap" / "firefox" / "common" / ".mozilla" / "firefox"):
135 if guess.exists():
136 base = guess
137 break
138 if not base.exists():
139 raise RuntimeError("Could not locate a Firefox profiles directory.")
140 candidates = sorted(glob.glob(str(base / "*default*" / "cookies.sqlite"))) or sorted(
141 glob.glob(str(base / "*" / "cookies.sqlite"))
142 )
143 if not candidates:
144 raise RuntimeError(f"No cookies.sqlite found under {base}")
145 # Prefer the most recently modified profile.
146 return Path(max(candidates, key=lambda p: Path(p).stat().st_mtime))
147
148
149def _firefox_storage_state(cookies_db: Path, host_glob: str) -> dict:

Callers 2

mainFunction · 0.85

Calls 2

existsMethod · 0.65
PathClass · 0.50

Tested by

no test coverage detected