move registry into own files
This commit is contained in:
+5
-10
@@ -19,6 +19,7 @@ from pathlib import Path
|
||||
from typing import Any
|
||||
|
||||
from browser_cli.platform import endpoint_for_alias, is_windows, registry_path
|
||||
from browser_cli.registry import load_registry
|
||||
|
||||
REGISTRY_PATH = registry_path()
|
||||
REMOTE_REGISTRY_PATH = Path(os.environ.get("XDG_CONFIG_HOME", Path.home() / ".config")) / "browser-cli" / "remotes.json"
|
||||
@@ -118,10 +119,7 @@ def _remote_browser_targets() -> list[BrowserTarget]:
|
||||
def active_browser_targets(*, include_remotes: bool = True) -> list[BrowserTarget]:
|
||||
targets: list[BrowserTarget] = []
|
||||
if REGISTRY_PATH.exists():
|
||||
try:
|
||||
reg = json.loads(REGISTRY_PATH.read_text())
|
||||
except Exception:
|
||||
reg = {}
|
||||
reg = load_registry(REGISTRY_PATH)
|
||||
targets.extend(
|
||||
BrowserTarget(profile=profile, display_name=display_browser_name(profile, sock_path), socket_path=sock_path)
|
||||
for profile, sock_path in _active_endpoints(reg).items()
|
||||
@@ -137,12 +135,9 @@ def _resolve_socket(profile: str | None = None) -> str:
|
||||
|
||||
if target:
|
||||
if REGISTRY_PATH.exists():
|
||||
try:
|
||||
reg = json.loads(REGISTRY_PATH.read_text())
|
||||
if target in reg:
|
||||
return reg[target]
|
||||
except Exception:
|
||||
pass
|
||||
reg = load_registry(REGISTRY_PATH)
|
||||
if target in reg:
|
||||
return reg[target]
|
||||
return endpoint_for_alias(target)
|
||||
|
||||
# Auto-detect: error when multiple browser instances are active
|
||||
|
||||
Reference in New Issue
Block a user