Files
2026-06-21 13:23:06 +03:00

27 lines
787 B
Python

# config/__init__.py
import json, os, platform
from pathlib import Path
_CONFIG_PATH = Path(__file__).parent / "api_keys.json"
def _platform_os() -> str:
"""Auto-detect OS when config file is absent."""
return {"Windows": "windows", "Darwin": "mac", "Linux": "linux"}.get(
platform.system(), "linux"
)
def get_config() -> dict:
try:
with open(_CONFIG_PATH, "r", encoding="utf-8") as f:
return json.load(f)
except Exception:
return {}
def get_os() -> str:
"""Returns: 'windows' | 'mac' | 'linux'"""
return get_config().get("os_system", _platform_os()).lower()
def is_windows() -> bool: return get_os() == "windows"
def is_mac() -> bool: return get_os() == "mac"
def is_linux() -> bool: return get_os() == "linux"