Add GUI refactor, modern theme, and configuration improvements
Some checks failed
Mirror to Gitea / mirror (push) Has been cancelled

This commit is contained in:
2026-08-10 14:28:49 +03:30
parent a39cccb0dc
commit 95e0acbe71
17 changed files with 692 additions and 2650 deletions

View File

@@ -19,52 +19,29 @@ def _package_dir() -> Path:
PACKAGE_DIR = _package_dir()
# Historical Windows root used in file_data.csv
DEFAULT_OPENCLOUD_ROOT = Path(r"D:\OpenCloud")
OPENCLOUD_MARKER = "OpenCloud"
def package_file(name: str) -> Path:
return PACKAGE_DIR / name
def get_opencloud_root() -> Path:
"""Workbook tree root from XLSX_CLEAN_ROOT, else D:\\OpenCloud on Windows."""
env = os.environ.get("XLSX_CLEAN_ROOT")
if env:
return Path(env)
return DEFAULT_OPENCLOUD_ROOT
def remap_opencloud_path(path_str: str, root: Path | None = None) -> Path:
"""Map a CSV path under OpenCloud onto the configured root.
Examples:
D:\\OpenCloud\\inco\\... + root=/data -> /data/inco/...
Relative paths without OpenCloud are returned as-is (Path).
"""
if root is None:
root = get_opencloud_root()
normalized = path_str.replace("\\", "/")
# Case-insensitive marker search
lower = normalized.lower()
marker = f"{OPENCLOUD_MARKER.lower()}/"
idx = lower.find(marker)
if idx != -1:
rel = normalized[idx + len(marker) :]
return root / rel
# Already relative to root-style path without drive
return Path(path_str)
def default_config_path() -> Path:
"""Resolve the default location for the TOML configuration file."""
if getattr(sys, "frozen", False):
return Path(sys.executable).resolve().parent / "config.toml"
return Path.home() / ".xlsx-clean" / "config.toml"
def default_backend() -> str:
return "com" if sys.platform == "win32" else "ooxml"
def resolve_backend(requested: str | None) -> str:
backend = (requested or default_backend()).lower()
def resolve_backend(requested: str | None, config_backend: str | None = None) -> str:
"""Resolve backend using explicitly requested, config file, or system default."""
if requested:
backend = requested.lower()
elif config_backend:
backend = config_backend.lower()
else:
backend = default_backend().lower()
if backend not in {"com", "ooxml"}:
raise ValueError(f"Unknown backend {backend!r}; use 'com' or 'ooxml'")
if backend == "com" and sys.platform != "win32":