devdash-mac 0.1.1__tar.gz → 0.1.2__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {devdash_mac-0.1.1/src/devdash_mac.egg-info → devdash_mac-0.1.2}/PKG-INFO +1 -1
- {devdash_mac-0.1.1 → devdash_mac-0.1.2}/pyproject.toml +1 -1
- {devdash_mac-0.1.1 → devdash_mac-0.1.2}/src/devdash/__init__.py +1 -1
- {devdash_mac-0.1.1 → devdash_mac-0.1.2}/src/devdash/config.py +30 -10
- {devdash_mac-0.1.1 → devdash_mac-0.1.2/src/devdash_mac.egg-info}/PKG-INFO +1 -1
- {devdash_mac-0.1.1 → devdash_mac-0.1.2}/LICENSE +0 -0
- {devdash_mac-0.1.1 → devdash_mac-0.1.2}/README.md +0 -0
- {devdash_mac-0.1.1 → devdash_mac-0.1.2}/setup.cfg +0 -0
- {devdash_mac-0.1.1 → devdash_mac-0.1.2}/src/devdash/__main__.py +0 -0
- {devdash_mac-0.1.1 → devdash_mac-0.1.2}/src/devdash/app.py +0 -0
- {devdash_mac-0.1.1 → devdash_mac-0.1.2}/src/devdash/clipboard.py +0 -0
- {devdash_mac-0.1.1 → devdash_mac-0.1.2}/src/devdash/plugin_loader.py +0 -0
- {devdash_mac-0.1.1 → devdash_mac-0.1.2}/src/devdash/storage.py +0 -0
- {devdash_mac-0.1.1 → devdash_mac-0.1.2}/src/devdash/tools/__init__.py +0 -0
- {devdash_mac-0.1.1 → devdash_mac-0.1.2}/src/devdash/tools/base.py +0 -0
- {devdash_mac-0.1.1 → devdash_mac-0.1.2}/src/devdash/tools/base64_tool.py +0 -0
- {devdash_mac-0.1.1 → devdash_mac-0.1.2}/src/devdash/tools/color_tool.py +0 -0
- {devdash_mac-0.1.1 → devdash_mac-0.1.2}/src/devdash/tools/cron_tool.py +0 -0
- {devdash_mac-0.1.1 → devdash_mac-0.1.2}/src/devdash/tools/hash_tool.py +0 -0
- {devdash_mac-0.1.1 → devdash_mac-0.1.2}/src/devdash/tools/json_tool.py +0 -0
- {devdash_mac-0.1.1 → devdash_mac-0.1.2}/src/devdash/tools/jwt_tool.py +0 -0
- {devdash_mac-0.1.1 → devdash_mac-0.1.2}/src/devdash/tools/lorem_tool.py +0 -0
- {devdash_mac-0.1.1 → devdash_mac-0.1.2}/src/devdash/tools/password_tool.py +0 -0
- {devdash_mac-0.1.1 → devdash_mac-0.1.2}/src/devdash/tools/regex_tool.py +0 -0
- {devdash_mac-0.1.1 → devdash_mac-0.1.2}/src/devdash/tools/timestamp_tool.py +0 -0
- {devdash_mac-0.1.1 → devdash_mac-0.1.2}/src/devdash/tools/url_tool.py +0 -0
- {devdash_mac-0.1.1 → devdash_mac-0.1.2}/src/devdash/tools/uuid_tool.py +0 -0
- {devdash_mac-0.1.1 → devdash_mac-0.1.2}/src/devdash/ui/__init__.py +0 -0
- {devdash_mac-0.1.1 → devdash_mac-0.1.2}/src/devdash/ui/notifications.py +0 -0
- {devdash_mac-0.1.1 → devdash_mac-0.1.2}/src/devdash/ui/windows.py +0 -0
- {devdash_mac-0.1.1 → devdash_mac-0.1.2}/src/devdash_mac.egg-info/SOURCES.txt +0 -0
- {devdash_mac-0.1.1 → devdash_mac-0.1.2}/src/devdash_mac.egg-info/dependency_links.txt +0 -0
- {devdash_mac-0.1.1 → devdash_mac-0.1.2}/src/devdash_mac.egg-info/entry_points.txt +0 -0
- {devdash_mac-0.1.1 → devdash_mac-0.1.2}/src/devdash_mac.egg-info/requires.txt +0 -0
- {devdash_mac-0.1.1 → devdash_mac-0.1.2}/src/devdash_mac.egg-info/top_level.txt +0 -0
- {devdash_mac-0.1.1 → devdash_mac-0.1.2}/tests/test_app.py +0 -0
- {devdash_mac-0.1.1 → devdash_mac-0.1.2}/tests/test_clipboard.py +0 -0
- {devdash_mac-0.1.1 → devdash_mac-0.1.2}/tests/test_config.py +0 -0
- {devdash_mac-0.1.1 → devdash_mac-0.1.2}/tests/test_plugin_loader.py +0 -0
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
"""User preferences management with YAML config."""
|
|
2
2
|
|
|
3
|
+
import logging
|
|
3
4
|
import os
|
|
4
5
|
import threading
|
|
5
6
|
from pathlib import Path
|
|
@@ -7,8 +8,11 @@ from typing import Any
|
|
|
7
8
|
|
|
8
9
|
import yaml
|
|
9
10
|
|
|
10
|
-
|
|
11
|
-
|
|
11
|
+
logger = logging.getLogger(__name__)
|
|
12
|
+
|
|
13
|
+
# Try ~/.config/devdash first, fall back to ~/Library/Application Support/devdash
|
|
14
|
+
_PRIMARY_DIR = Path.home() / ".config" / "devdash"
|
|
15
|
+
_FALLBACK_DIR = Path.home() / "Library" / "Application Support" / "devdash"
|
|
12
16
|
|
|
13
17
|
_lock = threading.Lock()
|
|
14
18
|
|
|
@@ -22,22 +26,38 @@ DEFAULT_CONFIG: dict[str, Any] = {
|
|
|
22
26
|
}
|
|
23
27
|
|
|
24
28
|
|
|
25
|
-
def
|
|
26
|
-
"""
|
|
27
|
-
|
|
29
|
+
def _resolve_config_dir() -> Path:
|
|
30
|
+
"""Find a writable config directory."""
|
|
31
|
+
for candidate in (_PRIMARY_DIR, _FALLBACK_DIR):
|
|
32
|
+
try:
|
|
33
|
+
candidate.mkdir(parents=True, exist_ok=True)
|
|
34
|
+
return candidate
|
|
35
|
+
except PermissionError:
|
|
36
|
+
continue
|
|
37
|
+
# Last resort: use home directory directly
|
|
38
|
+
return Path.home() / ".devdash"
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
CONFIG_DIR = _resolve_config_dir()
|
|
42
|
+
CONFIG_FILE = CONFIG_DIR / "config.yaml"
|
|
28
43
|
|
|
29
44
|
|
|
30
45
|
def load_config() -> dict[str, Any]:
|
|
31
46
|
"""Load config from file, creating defaults on first run."""
|
|
32
47
|
with _lock:
|
|
33
48
|
if not CONFIG_FILE.exists():
|
|
34
|
-
|
|
49
|
+
try:
|
|
50
|
+
save_config(DEFAULT_CONFIG)
|
|
51
|
+
except PermissionError:
|
|
52
|
+
logger.warning("Cannot create config file at %s", CONFIG_FILE)
|
|
53
|
+
return dict(DEFAULT_CONFIG)
|
|
54
|
+
try:
|
|
55
|
+
with open(CONFIG_FILE) as f:
|
|
56
|
+
data = yaml.safe_load(f)
|
|
57
|
+
except (PermissionError, OSError):
|
|
35
58
|
return dict(DEFAULT_CONFIG)
|
|
36
|
-
with open(CONFIG_FILE) as f:
|
|
37
|
-
data = yaml.safe_load(f)
|
|
38
59
|
if not isinstance(data, dict):
|
|
39
60
|
return dict(DEFAULT_CONFIG)
|
|
40
|
-
# Merge with defaults for any missing keys
|
|
41
61
|
merged = dict(DEFAULT_CONFIG)
|
|
42
62
|
merged.update(data)
|
|
43
63
|
return merged
|
|
@@ -45,7 +65,7 @@ def load_config() -> dict[str, Any]:
|
|
|
45
65
|
|
|
46
66
|
def save_config(config: dict[str, Any]) -> None:
|
|
47
67
|
"""Save config to file with restricted permissions."""
|
|
48
|
-
|
|
68
|
+
CONFIG_DIR.mkdir(parents=True, exist_ok=True)
|
|
49
69
|
with open(CONFIG_FILE, "w") as f:
|
|
50
70
|
yaml.dump(config, f, default_flow_style=False)
|
|
51
71
|
os.chmod(CONFIG_FILE, 0o600)
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|