trimmy 0.2.0__py3-none-any.whl

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.
trimmy/__init__.py ADDED
File without changes
trimmy/__main__.py ADDED
@@ -0,0 +1,12 @@
1
+ import sys
2
+
3
+
4
+ def main():
5
+ from trimmy.main_window import run
6
+
7
+ path = sys.argv[1] if len(sys.argv) > 1 else None
8
+ run(path)
9
+
10
+
11
+ if __name__ == "__main__":
12
+ main()
trimmy/config.py ADDED
@@ -0,0 +1,45 @@
1
+ import json
2
+ import os
3
+ import sys
4
+ from pathlib import Path
5
+
6
+
7
+ def _config_dir() -> Path:
8
+ if sys.platform == "win32":
9
+ base = Path(os.environ.get("LOCALAPPDATA", Path.home() / "AppData" / "Local"))
10
+ elif sys.platform == "darwin":
11
+ base = Path.home() / "Library" / "Application Support"
12
+ else:
13
+ base = Path(os.environ.get("XDG_CONFIG_HOME", Path.home() / ".config"))
14
+ return base / "trimmy"
15
+
16
+
17
+ CONFIG_PATH = _config_dir() / "config.json"
18
+
19
+ _DEFAULTS = {
20
+ "selected_platform": "instagram",
21
+ "selected_format": "feed",
22
+ "selected_quality": "max",
23
+ "split_ratio": 0.5,
24
+ "crops": {
25
+ "top": {"x": 0.0, "y": 0.0, "w": 0.0, "h": 0.0},
26
+ "bottom": {"x": 0.0, "y": 0.0, "w": 0.0, "h": 0.0},
27
+ },
28
+ }
29
+
30
+
31
+ def load() -> dict:
32
+ if not CONFIG_PATH.exists():
33
+ return dict(_DEFAULTS)
34
+ try:
35
+ data = json.loads(CONFIG_PATH.read_text(encoding="utf-8"))
36
+ merged = dict(_DEFAULTS)
37
+ merged.update(data)
38
+ return merged
39
+ except (json.JSONDecodeError, OSError):
40
+ return dict(_DEFAULTS)
41
+
42
+
43
+ def save(state: dict):
44
+ CONFIG_PATH.parent.mkdir(parents=True, exist_ok=True)
45
+ CONFIG_PATH.write_text(json.dumps(state, indent=2), encoding="utf-8")