Compare commits
10 Commits
switch-ui-
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
| b17adb1257 | |||
| c2b10ac856 | |||
| d3960cdbf7 | |||
|
|
a9c31148e0 | ||
| e4cdb540e9 | |||
| fb9295ce65 | |||
| 1d18dbd7c4 | |||
|
|
b013181d35 | ||
|
|
94791dcd67 | ||
| 1cad94b8d5 |
@@ -39,10 +39,12 @@ To put a self-contained app on other PCs (build **on Windows**):
|
|||||||
|
|
||||||
| Step | Action |
|
| Step | Action |
|
||||||
|------|--------|
|
|------|--------|
|
||||||
| 1 | Find the latest matching workbook in the product folder |
|
| 1 | Resolve `[YEAR]` and find the latest matching workbook (template) in that product folder |
|
||||||
| 2 | Clear configured cells / blank notes |
|
| 2 | Clear configured cells / blank notes |
|
||||||
| 3 | Write the batch serial |
|
| 3 | Write the batch serial |
|
||||||
| 4 | Save as a new file using the `[SERIAL]` name pattern |
|
| 4 | Save under the largest existing year folder using the `[SERIAL]` name pattern |
|
||||||
|
|
||||||
|
Year folders in `file_data.csv` use a `[YEAR]` placeholder. The template is read from the largest digit-named year directory that already contains matching sheets for that ink. The new workbook is written into the largest digit-named year directory under the same QC parent (existence only; the ink folder is created if missing).
|
||||||
|
|
||||||
### Excel backends
|
### Excel backends
|
||||||
|
|
||||||
@@ -133,7 +135,7 @@ Windows CLI helper: `src\xlsx_clean\new_xslx.bat`
|
|||||||
| File | Purpose |
|
| File | Purpose |
|
||||||
|------|---------|
|
|------|---------|
|
||||||
| `config.toml` | Backend choice and root directory path for each set (auto-generated in `~/.xlsx-clean/` on first run) |
|
| `config.toml` | Backend choice and root directory path for each set (auto-generated in `~/.xlsx-clean/` on first run) |
|
||||||
| `src/xlsx_clean/file_data.csv` | Relative product folders, filename patterns, cells to clear/set |
|
| `src/xlsx_clean/file_data.csv` | Relative product folders (`[YEAR]` placeholder), filename patterns, cells to clear/set |
|
||||||
| `src/xlsx_clean/strings.txt` | UI prompts + Windows Excel add-in paths (`com` only) |
|
| `src/xlsx_clean/strings.txt` | UI prompts + Windows Excel add-in paths (`com` only) |
|
||||||
|
|
||||||
## Project layout (launchers)
|
## Project layout (launchers)
|
||||||
|
|||||||
@@ -1,157 +0,0 @@
|
|||||||
<!DOCTYPE html>
|
|
||||||
<html lang="en">
|
|
||||||
<head>
|
|
||||||
<meta charset="utf-8" />
|
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
|
||||||
<title>New QC Sheet · 0.2.0</title>
|
|
||||||
<!--
|
|
||||||
Static UI mock of src/xlsx_clean/web_app.py (_build_page).
|
|
||||||
Demo only — no create-datasheet behavior.
|
|
||||||
-->
|
|
||||||
<script src="https://cdn.tailwindcss.com"></script>
|
|
||||||
<script>
|
|
||||||
tailwind.config = {
|
|
||||||
theme: {
|
|
||||||
extend: {
|
|
||||||
colors: {
|
|
||||||
primary: "#0f766e",
|
|
||||||
secondary: "#115e59",
|
|
||||||
accent: "#14b8a6",
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
};
|
|
||||||
</script>
|
|
||||||
<style>
|
|
||||||
body {
|
|
||||||
font-family: Roboto, "Helvetica Neue", Helvetica, Arial, sans-serif;
|
|
||||||
background: #f8fafc;
|
|
||||||
min-height: 100vh;
|
|
||||||
}
|
|
||||||
.field {
|
|
||||||
position: relative;
|
|
||||||
width: 100%;
|
|
||||||
}
|
|
||||||
.field label {
|
|
||||||
position: absolute;
|
|
||||||
top: -0.55rem;
|
|
||||||
left: 0.75rem;
|
|
||||||
padding: 0 0.25rem;
|
|
||||||
font-size: 0.75rem;
|
|
||||||
line-height: 1;
|
|
||||||
color: #0f766e;
|
|
||||||
background: #fff;
|
|
||||||
z-index: 1;
|
|
||||||
}
|
|
||||||
.field select,
|
|
||||||
.field input {
|
|
||||||
width: 100%;
|
|
||||||
appearance: none;
|
|
||||||
border: 1px solid #cbd5e1;
|
|
||||||
border-radius: 0.25rem;
|
|
||||||
background: #fff;
|
|
||||||
padding: 0.85rem 2.25rem 0.85rem 0.85rem;
|
|
||||||
font-size: 1rem;
|
|
||||||
color: #0f172a;
|
|
||||||
outline: none;
|
|
||||||
}
|
|
||||||
.field select:focus,
|
|
||||||
.field input:focus {
|
|
||||||
border-color: #0f766e;
|
|
||||||
box-shadow: inset 0 0 0 1px #0f766e;
|
|
||||||
}
|
|
||||||
.field .chevron {
|
|
||||||
pointer-events: none;
|
|
||||||
position: absolute;
|
|
||||||
right: 0.85rem;
|
|
||||||
top: 50%;
|
|
||||||
transform: translateY(-50%);
|
|
||||||
color: #64748b;
|
|
||||||
font-size: 0.75rem;
|
|
||||||
}
|
|
||||||
.btn-primary {
|
|
||||||
width: 100%;
|
|
||||||
border: none;
|
|
||||||
border-radius: 0.25rem;
|
|
||||||
background: #0f766e;
|
|
||||||
color: #fff;
|
|
||||||
font-size: 0.95rem;
|
|
||||||
font-weight: 500;
|
|
||||||
letter-spacing: 0.02em;
|
|
||||||
text-transform: uppercase;
|
|
||||||
padding: 0.7rem 1rem;
|
|
||||||
cursor: default;
|
|
||||||
}
|
|
||||||
.btn-primary:hover {
|
|
||||||
background: #115e59;
|
|
||||||
}
|
|
||||||
</style>
|
|
||||||
</head>
|
|
||||||
<body>
|
|
||||||
<main class="w-full max-w-xl mx-auto p-6 flex flex-col gap-4">
|
|
||||||
<h1 class="text-3xl font-bold text-teal-800 m-0">New QC Sheet</h1>
|
|
||||||
<p class="text-gray-600 m-0">
|
|
||||||
Create a new QC datasheet from the latest matching workbook.
|
|
||||||
</p>
|
|
||||||
|
|
||||||
<div class="field">
|
|
||||||
<label>Select Set</label>
|
|
||||||
<select aria-label="Select Set" tabindex="-1">
|
|
||||||
<option selected>Kimia Razi</option>
|
|
||||||
<option>inco</option>
|
|
||||||
</select>
|
|
||||||
<span class="chevron" aria-hidden="true">▾</span>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="field">
|
|
||||||
<label>Select Ink Color</label>
|
|
||||||
<select aria-label="Select Ink Color" tabindex="-1">
|
|
||||||
<option selected>KRCY1100T Blue</option>
|
|
||||||
<option>KRBK1300T Black</option>
|
|
||||||
<option>KRBK1314T Black</option>
|
|
||||||
<option>KRBR1200T Brown</option>
|
|
||||||
<option>KRBG1600T Beige</option>
|
|
||||||
<option>KRHN1700T Honey</option>
|
|
||||||
<option>KRPK1500T Pink</option>
|
|
||||||
</select>
|
|
||||||
<span class="chevron" aria-hidden="true">▾</span>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="field">
|
|
||||||
<label>Serial:</label>
|
|
||||||
<input
|
|
||||||
type="text"
|
|
||||||
placeholder="e.g. 1234/A"
|
|
||||||
value=""
|
|
||||||
aria-label="Serial"
|
|
||||||
tabindex="-1"
|
|
||||||
readonly
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="field">
|
|
||||||
<label>Backend</label>
|
|
||||||
<select aria-label="Backend" tabindex="-1">
|
|
||||||
<option selected>ooxml</option>
|
|
||||||
<option>com</option>
|
|
||||||
</select>
|
|
||||||
<span class="chevron" aria-hidden="true">▾</span>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<p class="text-sm text-amber-700 m-0">
|
|
||||||
COM backend requires Windows with Microsoft Excel; use ooxml here.
|
|
||||||
</p>
|
|
||||||
|
|
||||||
<div class="w-full p-3 rounded bg-gray-50 text-slate-700">
|
|
||||||
Ready.
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<button type="button" class="btn-primary" tabindex="-1">
|
|
||||||
Create datasheet
|
|
||||||
</button>
|
|
||||||
|
|
||||||
<p class="w-full text-right text-xs text-gray-400 m-0">v0.2.0</p>
|
|
||||||
</main>
|
|
||||||
</body>
|
|
||||||
</html>
|
|
||||||
|
|
||||||
@@ -5,6 +5,8 @@ set -euo pipefail
|
|||||||
ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
|
ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
|
||||||
cd "$ROOT"
|
cd "$ROOT"
|
||||||
|
|
||||||
|
SYS_PY=/usr/bin/python3
|
||||||
|
|
||||||
if ! command -v uv >/dev/null 2>&1; then
|
if ! command -v uv >/dev/null 2>&1; then
|
||||||
echo "uv not found on PATH. Install uv first: https://docs.astral.sh/uv/" >&2
|
echo "uv not found on PATH. Install uv first: https://docs.astral.sh/uv/" >&2
|
||||||
exit 1
|
exit 1
|
||||||
@@ -16,6 +18,11 @@ if ! command -v apt-get >/dev/null 2>&1; then
|
|||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
if [[ ! -x "$SYS_PY" ]]; then
|
||||||
|
echo "System Python not found at $SYS_PY" >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
packages=(python3-gi gir1.2-gtk-3.0)
|
packages=(python3-gi gir1.2-gtk-3.0)
|
||||||
if apt-cache show gir1.2-webkit2-4.1 >/dev/null 2>&1; then
|
if apt-cache show gir1.2-webkit2-4.1 >/dev/null 2>&1; then
|
||||||
packages+=(gir1.2-webkit2-4.1)
|
packages+=(gir1.2-webkit2-4.1)
|
||||||
@@ -41,6 +48,23 @@ else
|
|||||||
echo "GTK/WebKitGTK requirements already installed."
|
echo "GTK/WebKitGTK requirements already installed."
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
if ! "$SYS_PY" -c 'import gi' >/dev/null 2>&1; then
|
||||||
|
echo "System $SYS_PY cannot import gi. Install python3-gi." >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
enable_system_site_packages() {
|
||||||
|
local cfg=.venv/pyvenv.cfg
|
||||||
|
if [[ ! -f "$cfg" ]]; then
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
if grep -q '^include-system-site-packages' "$cfg"; then
|
||||||
|
sed -i 's/^include-system-site-packages = .*/include-system-site-packages = true/' "$cfg"
|
||||||
|
else
|
||||||
|
printf '\ninclude-system-site-packages = true\n' >> "$cfg"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
if [[ ! -x .venv/bin/python ]] || ! .venv/bin/python -c 'import gi' >/dev/null 2>&1; then
|
if [[ ! -x .venv/bin/python ]] || ! .venv/bin/python -c 'import gi' >/dev/null 2>&1; then
|
||||||
echo "Creating venv with the system Python and system site packages..."
|
echo "Creating venv with the system Python and system site packages..."
|
||||||
rm -rf .venv
|
rm -rf .venv
|
||||||
@@ -48,7 +72,22 @@ if [[ ! -x .venv/bin/python ]] || ! .venv/bin/python -c 'import gi' >/dev/null 2
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
echo "Syncing dependencies..."
|
echo "Syncing dependencies..."
|
||||||
uv sync --active
|
# Pin the same interpreter so uv does not honor .python-version (3.12) and
|
||||||
|
# recreate a managed venv without apt gi (python3-gi).
|
||||||
|
uv sync --python /usr/bin/python3 --no-managed-python
|
||||||
|
|
||||||
|
if ! .venv/bin/python -c 'import gi' >/dev/null 2>&1; then
|
||||||
|
echo "Restoring system site packages on .venv so apt gi is importable..."
|
||||||
|
enable_system_site_packages
|
||||||
|
fi
|
||||||
|
|
||||||
|
venv_ver="$(.venv/bin/python -c 'import sys; print("%d.%d" % sys.version_info[:2])')"
|
||||||
|
sys_ver="$("$SYS_PY" -c 'import sys; print("%d.%d" % sys.version_info[:2])')"
|
||||||
|
if [[ "$venv_ver" != "$sys_ver" ]]; then
|
||||||
|
echo "venv Python $venv_ver does not match system Python $sys_ver at $SYS_PY." >&2
|
||||||
|
echo "uv likely honored .python-version instead of the system interpreter." >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
echo "Verifying GTK and WebKit2 bindings..."
|
echo "Verifying GTK and WebKit2 bindings..."
|
||||||
.venv/bin/python -c '
|
.venv/bin/python -c '
|
||||||
|
|||||||
@@ -2,17 +2,78 @@
|
|||||||
|
|
||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
|
import logging
|
||||||
|
import shutil
|
||||||
|
import sys
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
|
||||||
|
# Excel xlMaximized — avoid win32.constants when gen_py early-binding cache is corrupt.
|
||||||
|
_XL_MAXIMIZED = -4137
|
||||||
|
|
||||||
|
_log = logging.getLogger("xlsx_clean.create")
|
||||||
|
|
||||||
|
|
||||||
|
def _is_gen_py_cache_error(exc: BaseException) -> bool:
|
||||||
|
"""True for the known corrupt gen_py AttributeError (CLSIDTo*Map missing)."""
|
||||||
|
if not isinstance(exc, AttributeError):
|
||||||
|
return False
|
||||||
|
msg = str(exc)
|
||||||
|
return "CLSIDToClassMap" in msg or "CLSIDToPackageMap" in msg
|
||||||
|
|
||||||
|
|
||||||
|
def _clear_gen_py_cache() -> Path | None:
|
||||||
|
"""Remove win32com's generated typelib cache and drop it from sys.modules."""
|
||||||
|
import win32com
|
||||||
|
|
||||||
|
gen_path = Path(win32com.__gen_path__)
|
||||||
|
for name in [m for m in sys.modules if m.startswith("win32com.gen_py")]:
|
||||||
|
del sys.modules[name]
|
||||||
|
if gen_path.is_dir():
|
||||||
|
shutil.rmtree(gen_path, ignore_errors=True)
|
||||||
|
return gen_path
|
||||||
|
return None
|
||||||
|
|
||||||
|
|
||||||
|
def _excel_application():
|
||||||
|
"""Return Excel.Application, recovering from a corrupt win32com gen_py cache.
|
||||||
|
|
||||||
|
``gencache.EnsureDispatch`` writes early-binding wrappers under ``%TEMP%\\gen_py``.
|
||||||
|
Interrupted or partial writes leave modules without ``CLSIDToClassMap`` /
|
||||||
|
``CLSIDToPackageMap``; deleting that folder and retrying fixes it (same as the
|
||||||
|
manual workaround). Falls back to late-bound ``Dispatch`` if rebuild still fails.
|
||||||
|
"""
|
||||||
|
import win32com.client as win32
|
||||||
|
|
||||||
|
try:
|
||||||
|
return win32.gencache.EnsureDispatch("Excel.Application")
|
||||||
|
except AttributeError as exc:
|
||||||
|
if not _is_gen_py_cache_error(exc):
|
||||||
|
raise
|
||||||
|
cleared = _clear_gen_py_cache()
|
||||||
|
_log.warning(
|
||||||
|
"Corrupt win32com gen_py cache (%s); cleared %s and retrying",
|
||||||
|
exc,
|
||||||
|
cleared or "(missing)",
|
||||||
|
)
|
||||||
|
try:
|
||||||
|
return win32.gencache.EnsureDispatch("Excel.Application")
|
||||||
|
except AttributeError as retry_exc:
|
||||||
|
if not _is_gen_py_cache_error(retry_exc):
|
||||||
|
raise
|
||||||
|
_log.warning(
|
||||||
|
"EnsureDispatch still failing after cache clear (%s); using late-bound Dispatch",
|
||||||
|
retry_exc,
|
||||||
|
)
|
||||||
|
return win32.Dispatch("Excel.Application")
|
||||||
|
|
||||||
|
|
||||||
def _bring_excel_to_front(excel, workbook) -> None:
|
def _bring_excel_to_front(excel, workbook) -> None:
|
||||||
"""Maximize and force Excel ahead of other windows (e.g. NiceGUI)."""
|
"""Maximize and force Excel ahead of other windows (e.g. NiceGUI)."""
|
||||||
import win32com.client as win32
|
|
||||||
import win32con
|
import win32con
|
||||||
import win32gui
|
import win32gui
|
||||||
|
|
||||||
excel.Visible = True
|
excel.Visible = True
|
||||||
excel.WindowState = win32.constants.xlMaximized
|
excel.WindowState = _XL_MAXIMIZED
|
||||||
try:
|
try:
|
||||||
workbook.Activate()
|
workbook.Activate()
|
||||||
except Exception:
|
except Exception:
|
||||||
@@ -57,16 +118,12 @@ def clean_workbook_com(
|
|||||||
maximize: bool = True,
|
maximize: bool = True,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Clear/set cells via Excel COM, SaveAs destination, leave Excel open."""
|
"""Clear/set cells via Excel COM, SaveAs destination, leave Excel open."""
|
||||||
# Lazy import so Linux never loads pywin32.
|
# Lazy import so Linux never loads pywin32 (only needed if callers import helpers).
|
||||||
import win32com.client as win32
|
|
||||||
|
|
||||||
source = Path(source)
|
source = Path(source)
|
||||||
destination = Path(destination)
|
destination = Path(destination)
|
||||||
destination.parent.mkdir(parents=True, exist_ok=True)
|
destination.parent.mkdir(parents=True, exist_ok=True)
|
||||||
|
|
||||||
# AttributeError: ... has no attribute 'CLSIDToClassMap'
|
excel = _excel_application()
|
||||||
# https://stackoverflow.com/questions/52889704
|
|
||||||
excel = win32.gencache.EnsureDispatch("Excel.Application")
|
|
||||||
excel.Visible = visible
|
excel.Visible = visible
|
||||||
|
|
||||||
workbook = excel.Workbooks.Open(str(source.resolve()))
|
workbook = excel.Workbooks.Open(str(source.resolve()))
|
||||||
|
|||||||
@@ -6,7 +6,6 @@ import csv
|
|||||||
import shutil
|
import shutil
|
||||||
import tempfile
|
import tempfile
|
||||||
from dataclasses import dataclass
|
from dataclasses import dataclass
|
||||||
from datetime import datetime
|
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
|
||||||
import tomllib
|
import tomllib
|
||||||
@@ -33,6 +32,7 @@ backend = "com"
|
|||||||
|
|
||||||
|
|
||||||
NEW_VALUE = ""
|
NEW_VALUE = ""
|
||||||
|
YEAR_TOKEN = "[YEAR]"
|
||||||
|
|
||||||
|
|
||||||
@dataclass(frozen=True)
|
@dataclass(frozen=True)
|
||||||
@@ -49,15 +49,61 @@ def find_last_workbook(files: list[str]) -> str:
|
|||||||
return sorted(files)[-1]
|
return sorted(files)[-1]
|
||||||
|
|
||||||
|
|
||||||
|
def _split_year_placeholder(dir_with_placeholder: Path) -> tuple[Path, tuple[str, ...]] | None:
|
||||||
|
parts = dir_with_placeholder.parts
|
||||||
|
if YEAR_TOKEN not in parts:
|
||||||
|
return None
|
||||||
|
idx = parts.index(YEAR_TOKEN)
|
||||||
|
return Path(*parts[:idx]), parts[idx + 1 :]
|
||||||
|
|
||||||
|
|
||||||
|
def _digit_year_dirs(base: Path) -> list[Path]:
|
||||||
|
if not base.is_dir():
|
||||||
|
return []
|
||||||
|
return [c for c in base.iterdir() if c.is_dir() and c.name.isdigit()]
|
||||||
|
|
||||||
|
|
||||||
|
def resolve_year_dir(dir_with_placeholder: Path, pattern: str) -> Path:
|
||||||
|
"""Largest digit year dir that has matching template sheets for this ink."""
|
||||||
|
split = _split_year_placeholder(dir_with_placeholder)
|
||||||
|
if split is None:
|
||||||
|
return dir_with_placeholder
|
||||||
|
base, suffix = split
|
||||||
|
search_pattern = pattern.replace("[SERIAL]", "*")
|
||||||
|
years: list[int] = []
|
||||||
|
for child in _digit_year_dirs(base):
|
||||||
|
ink_dir = child.joinpath(*suffix) if suffix else child
|
||||||
|
if any(p.is_file() for p in ink_dir.glob(search_pattern)):
|
||||||
|
years.append(int(child.name))
|
||||||
|
if not years:
|
||||||
|
raise FileNotFoundError(
|
||||||
|
f"No year directory under {base} with workbooks matching {search_pattern!r}"
|
||||||
|
)
|
||||||
|
resolved = base / str(max(years))
|
||||||
|
return resolved.joinpath(*suffix) if suffix else resolved
|
||||||
|
|
||||||
|
|
||||||
|
def resolve_write_year_dir(dir_with_placeholder: Path) -> Path:
|
||||||
|
"""Largest digit year dir under the QC parent (existence only, no sheet check)."""
|
||||||
|
split = _split_year_placeholder(dir_with_placeholder)
|
||||||
|
if split is None:
|
||||||
|
return dir_with_placeholder
|
||||||
|
base, suffix = split
|
||||||
|
years = [int(c.name) for c in _digit_year_dirs(base)]
|
||||||
|
if not years:
|
||||||
|
raise FileNotFoundError(f"No year directory under {base}")
|
||||||
|
resolved = base / str(max(years))
|
||||||
|
return resolved.joinpath(*suffix) if suffix else resolved
|
||||||
|
|
||||||
|
|
||||||
def get_workbook_names(
|
def get_workbook_names(
|
||||||
files: list[str],
|
files: list[str],
|
||||||
batch_serial: str,
|
batch_serial: str,
|
||||||
source_dir: Path,
|
dest_dir: Path,
|
||||||
pattern: str,
|
pattern: str,
|
||||||
) -> tuple[str, Path]:
|
) -> tuple[str, Path]:
|
||||||
last_workbook = find_last_workbook(files)
|
last_workbook = find_last_workbook(files)
|
||||||
path_of_the_year = Path(str(source_dir).replace("2025", str(datetime.now().year)))
|
return last_workbook, dest_dir / pattern.replace(
|
||||||
return last_workbook, path_of_the_year / pattern.replace(
|
|
||||||
"[SERIAL]", batch_serial.split("/")[0]
|
"[SERIAL]", batch_serial.split("/")[0]
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -159,13 +205,20 @@ def create_datasheet(
|
|||||||
return CreateResult(ok=False, message=message)
|
return CreateResult(ok=False, message=message)
|
||||||
|
|
||||||
row = matches[0]
|
row = matches[0]
|
||||||
path_ = Path(row["dir"])
|
|
||||||
pattern = row["pattern"]
|
pattern = row["pattern"]
|
||||||
|
placeholder_dir = Path(row["dir"])
|
||||||
|
try:
|
||||||
|
read_dir = resolve_year_dir(placeholder_dir, pattern)
|
||||||
|
write_dir = resolve_write_year_dir(placeholder_dir)
|
||||||
|
except FileNotFoundError as exc:
|
||||||
|
message = str(exc)
|
||||||
|
log.error("Create failed: %s (%s)", message, ctx)
|
||||||
|
return CreateResult(ok=False, message=message, backend=resolved_backend)
|
||||||
search_pattern = pattern.replace("[SERIAL]", "*")
|
search_pattern = pattern.replace("[SERIAL]", "*")
|
||||||
files = [str(x) for x in path_.glob(search_pattern) if x.is_file()]
|
files = [str(x) for x in read_dir.glob(search_pattern) if x.is_file()]
|
||||||
|
|
||||||
if not files:
|
if not files:
|
||||||
message = f"No workbooks matching {search_pattern!r} in {path_}"
|
message = f"No workbooks matching {search_pattern!r} in {read_dir}"
|
||||||
log.error("Create failed: %s (%s)", message, ctx)
|
log.error("Create failed: %s (%s)", message, ctx)
|
||||||
return CreateResult(
|
return CreateResult(
|
||||||
ok=False,
|
ok=False,
|
||||||
@@ -174,7 +227,7 @@ def create_datasheet(
|
|||||||
)
|
)
|
||||||
|
|
||||||
ref_workbook_name, new_workbook_name = get_workbook_names(
|
ref_workbook_name, new_workbook_name = get_workbook_names(
|
||||||
files, batch_serial, path_, pattern
|
files, batch_serial, write_dir, pattern
|
||||||
)
|
)
|
||||||
template = Path(ref_workbook_name)
|
template = Path(ref_workbook_name)
|
||||||
|
|
||||||
|
|||||||
@@ -1,25 +1,25 @@
|
|||||||
dir,pattern,set_name,cells_to_clear,serial_cell,notes_cell
|
dir,pattern,set_name,cells_to_clear,serial_cell,notes_cell
|
||||||
Production\QC Datasheet\1403\KRCY1100T Blue,KRCY1100T Blue [SERIAL].xlsx,Kimia Razi,"Batch!F2:F3,Batch!E12:G12,Batch!O9:Q10,Batch!O12:Q12,Batch!N10,Batch!N13,Batch!D19:J22,'KW'!C3:C4,Milling!G5:K8,Milling!G11:K11,Milling!D7:D8,Milling!D11",Batch!D3,Batch!D25
|
Production\QC Datasheet\[YEAR]\KRCY1100T Blue,KRCY1100T Blue [SERIAL].xlsx,Kimia Razi,"Batch!F2:F3,Batch!E12:G12,Batch!O9:Q10,Batch!O12:Q12,Batch!N10,Batch!N13,Batch!D19:J22,'KW'!C3:C4,Milling!G5:K8,Milling!G11:K11,Milling!D7:D8,Milling!D11",Batch!D3,Batch!D25
|
||||||
Production\QC Datasheet\1403\KRBK1300T Black,KRBK1300T Black [SERIAL].xlsx,Kimia Razi,"Batch!F2:F3,Batch!E12:G12,Batch!O9:Q10,Batch!O12:Q12,Batch!N10,Batch!N13,Batch!D19:J22,'KW'!C3:C4,Milling!G5:K8,Milling!G11:K11,Milling!D7:D8,Milling!D11",Batch!D3,Batch!D25
|
Production\QC Datasheet\[YEAR]\KRBK1300T Black,KRBK1300T Black [SERIAL].xlsx,Kimia Razi,"Batch!F2:F3,Batch!E12:G12,Batch!O9:Q10,Batch!O12:Q12,Batch!N10,Batch!N13,Batch!D19:J22,'KW'!C3:C4,Milling!G5:K8,Milling!G11:K11,Milling!D7:D8,Milling!D11",Batch!D3,Batch!D25
|
||||||
Production\QC Datasheet\1403\KRBK1314T Black,KRBK1314T Black [SERIAL].xlsx,Kimia Razi,"Batch!F2:F3,Batch!G12:I12,Batch!O9:Q10,Batch!O12:Q12,Batch!N10,Batch!N13,Batch!D20:J23,'KW'!C3:C4,Milling!G5:K8,Milling!G11:K11,Milling!D7:D8,Milling!D11",Batch!D3,Batch!D25
|
Production\QC Datasheet\[YEAR]\KRBK1314T Black,KRBK1314T Black [SERIAL].xlsx,Kimia Razi,"Batch!F2:F3,Batch!G12:I12,Batch!O9:Q10,Batch!O12:Q12,Batch!N10,Batch!N13,Batch!D20:J23,'KW'!C3:C4,Milling!G5:K8,Milling!G11:K11,Milling!D7:D8,Milling!D11",Batch!D3,Batch!D25
|
||||||
Production\QC Datasheet\1403\KRBR1200T Brown,KRBR1200T Brown [SERIAL].xlsx,Kimia Razi,"Batch!F2:F3,Batch!E12:G12,Batch!O9:Q10,Batch!O12:Q12,Batch!N10,Batch!N13,Batch!D20:J23,'KW'!C3:C4,Milling!G5:K8,Milling!G11:K11,Milling!D6:D8,Milling!D11",Batch!D3,Batch!D25
|
Production\QC Datasheet\[YEAR]\KRBR1200T Brown,KRBR1200T Brown [SERIAL].xlsx,Kimia Razi,"Batch!F2:F3,Batch!E12:G12,Batch!O9:Q10,Batch!O12:Q12,Batch!N10,Batch!N13,Batch!D20:J23,'KW'!C3:C4,Milling!G5:K8,Milling!G11:K11,Milling!D6:D8,Milling!D11",Batch!D3,Batch!D25
|
||||||
Production\QC Datasheet\1403\KRBR1201T Brown,KRBR1201T Brown [SERIAL].xlsx,Kimia Razi,"Batch!F2:F3,Batch!E12:G12,Batch!O9:Q10,Batch!O12:Q12,Batch!N10,Batch!N13,Batch!D20:J23,'KW'!C3:C4,Milling!G5:K8,Milling!G11:K11,Milling!D6:D8,Milling!D11",Batch!D3,Batch!D25
|
Production\QC Datasheet\[YEAR]\KRBR1201T Brown,KRBR1201T Brown [SERIAL].xlsx,Kimia Razi,"Batch!F2:F3,Batch!E12:G12,Batch!O9:Q10,Batch!O12:Q12,Batch!N10,Batch!N13,Batch!D20:J23,'KW'!C3:C4,Milling!G5:K8,Milling!G11:K11,Milling!D6:D8,Milling!D11",Batch!D3,Batch!D25
|
||||||
Production\QC Datasheet\1403\KRYL1400T Yellow,KRYL1400T Yellow [SERIAL].xlsx,Kimia Razi,"Batch!F2:F3,Batch!G12,Batch!O9:Q10,Batch!O12:Q12,Batch!N10,Batch!N13,Batch!D19:J22,'KW'!C3:C4,Milling!G5:K8,Milling!G11:K11,Milling!D7:D8,Milling!D11",Batch!D3,Batch!D25
|
Production\QC Datasheet\[YEAR]\KRYL1400T Yellow,KRYL1400T Yellow [SERIAL].xlsx,Kimia Razi,"Batch!F2:F3,Batch!G12,Batch!O9:Q10,Batch!O12:Q12,Batch!N10,Batch!N13,Batch!D19:J22,'KW'!C3:C4,Milling!G5:K8,Milling!G11:K11,Milling!D7:D8,Milling!D11",Batch!D3,Batch!D25
|
||||||
Production\QC Datasheet\1403\KRYL1401T Yellow,KRYL1401T Yellow [SERIAL].xlsx,Kimia Razi,"Batch!F2:F3,Batch!E12:G12,Batch!O9:Q10,Batch!O12:Q12,Batch!N10,Batch!N13,Batch!D20:J23,'KW'!C3:C4,Milling!G5:K8,Milling!G11:K11,Milling!D6:D8,Milling!D11",Batch!D3,Batch!D25
|
Production\QC Datasheet\[YEAR]\KRYL1401T Yellow,KRYL1401T Yellow [SERIAL].xlsx,Kimia Razi,"Batch!F2:F3,Batch!E12:G12,Batch!O9:Q10,Batch!O12:Q12,Batch!N10,Batch!N13,Batch!D20:J23,'KW'!C3:C4,Milling!G5:K8,Milling!G11:K11,Milling!D6:D8,Milling!D11",Batch!D3,Batch!D25
|
||||||
Production\QC Datasheet\1403\KRBG1600T Beige,KRBG1600T Beige [SERIAL].xlsx,Kimia Razi,"Batch!F2:F3,Batch!F12,Batch!O9:Q10,Batch!O12:Q12,Batch!N10,Batch!N13,Batch!D19:J22,'KW'!C3:C4,Milling!G5:K8,Milling!G11:K11,Milling!D7:D8,Milling!D11",Batch!D3,Batch!D25
|
Production\QC Datasheet\[YEAR]\KRBG1600T Beige,KRBG1600T Beige [SERIAL].xlsx,Kimia Razi,"Batch!F2:F3,Batch!F12,Batch!O9:Q10,Batch!O12:Q12,Batch!N10,Batch!N13,Batch!D19:J22,'KW'!C3:C4,Milling!G5:K8,Milling!G11:K11,Milling!D7:D8,Milling!D11",Batch!D3,Batch!D25
|
||||||
Production\QC Datasheet\1403\KRPK1500T Pink,KRPK1500T Pink [SERIAL].xlsx,Kimia Razi,"Batch!F2:F3,Batch!G12,Batch!O9:Q10,Batch!O12:Q12,Batch!N10,Batch!N13,Batch!D19:J22,'KW'!C3:C4,Milling!G5:K8,Milling!G11:K11,Milling!D7:D8,Milling!D11",Batch!D3,Batch!D25
|
Production\QC Datasheet\[YEAR]\KRPK1500T Pink,KRPK1500T Pink [SERIAL].xlsx,Kimia Razi,"Batch!F2:F3,Batch!G12,Batch!O9:Q10,Batch!O12:Q12,Batch!N10,Batch!N13,Batch!D19:J22,'KW'!C3:C4,Milling!G5:K8,Milling!G11:K11,Milling!D7:D8,Milling!D11",Batch!D3,Batch!D25
|
||||||
Production\QC Datasheet\1403\KRHN1700T Honey,KRHN1700T Honey [SERIAL].xlsx,Kimia Razi,"Batch!F2:F3,Batch!G12,Batch!O9:Q10,Batch!O12:Q12,Batch!N10,Batch!N13,Batch!D19:J22,'KW'!C3:C4,Milling!G5:K8,Milling!G11:K11,Milling!D7:D8,Milling!D11",Batch!D3,Batch!D25
|
Production\QC Datasheet\[YEAR]\KRHN1700T Honey,KRHN1700T Honey [SERIAL].xlsx,Kimia Razi,"Batch!F2:F3,Batch!G12,Batch!O9:Q10,Batch!O12:Q12,Batch!N10,Batch!N13,Batch!D19:J22,'KW'!C3:C4,Milling!G5:K8,Milling!G11:K11,Milling!D7:D8,Milling!D11",Batch!D3,Batch!D25
|
||||||
Quality control data sheet\2025\ICJ108 Beige,ICJ_108 op. [SERIAL].xlsx,inco,"Batch!F2:F3,Batch!E12:F12,Batch!O9:Q10,Batch!O12:Q12,Batch!N10,Batch!N13,Batch!D20:J23,'KW'!C3:C4,Milling!G5:K8,Milling!G11:K11,Milling!D6:D8,Milling!D11,Mix!B3:D11",Batch!D3,Batch!D25
|
Quality control data sheet\[YEAR]\ICJ108 Beige,ICJ_108 op. [SERIAL].xlsx,inco,"Batch!F2:F3,Batch!E12:F12,Batch!O9:Q10,Batch!O12:Q12,Batch!N10,Batch!N13,Batch!D20:J23,'KW'!C3:C4,Milling!G5:K8,Milling!G11:K11,Milling!D6:D8,Milling!D11,Mix!B3:D11",Batch!D3,Batch!D25
|
||||||
Quality control data sheet\2026\ICJ610 Black,ICJ_610 op. [SERIAL].xlsx,inco,"Batch!F2:F3,Batch!E12:F12,Batch!O9:Q10,Batch!O12:Q12,Batch!N10,Batch!N13,Batch!D20:J23,'KW'!C3:C4,Milling!G5:K8,Milling!G11:K11,Milling!D6:D8,Milling!D11,Mix!B3:D11",Batch!D3,Batch!D25
|
Quality control data sheet\[YEAR]\ICJ610 Black,ICJ_610 op. [SERIAL].xlsx,inco,"Batch!F2:F3,Batch!E12:F12,Batch!O9:Q10,Batch!O12:Q12,Batch!N10,Batch!N13,Batch!D20:J23,'KW'!C3:C4,Milling!G5:K8,Milling!G11:K11,Milling!D6:D8,Milling!D11,Mix!B3:D11",Batch!D3,Batch!D25
|
||||||
Quality control data sheet\2026\ICJ308 Blue,ICJ_308 op. [SERIAL].xlsx,inco,"Batch!F2:F3,Batch!E12:F12,Batch!O9:Q10,Batch!O12:Q12,Batch!N10,Batch!N13,Batch!D20:J23,'KW'!C3:C4,Milling!G5:K8,Milling!G11:K11,Milling!D6:D8,Milling!D11,Mix!B3:D11",Batch!D3,Batch!D25
|
Quality control data sheet\[YEAR]\ICJ308 Blue,ICJ_308 op. [SERIAL].xlsx,inco,"Batch!F2:F3,Batch!E12:F12,Batch!O9:Q10,Batch!O12:Q12,Batch!N10,Batch!N13,Batch!D20:J23,'KW'!C3:C4,Milling!G5:K8,Milling!G11:K11,Milling!D6:D8,Milling!D11,Mix!B3:D11",Batch!D3,Batch!D25
|
||||||
Quality control data sheet\2026\ICJEH680 Black,ICJ_EH680 op. [SERIAL].xlsx,inco,"Batch!F2:F3,Batch!I12,Batch!O9:Q10,Batch!O12:Q12,Batch!N10,Batch!N13,Batch!D20:J23,'KW'!C3:C4,Milling!G5:K8,Milling!G11:K11,Milling!D6:D8,Milling!D11,Mix!B3:D11",Batch!D3,Batch!D25
|
Quality control data sheet\[YEAR]\ICJEH680 Black,ICJ_EH680 op. [SERIAL].xlsx,inco,"Batch!F2:F3,Batch!I12,Batch!O9:Q10,Batch!O12:Q12,Batch!N10,Batch!N13,Batch!D20:J23,'KW'!C3:C4,Milling!G5:K8,Milling!G11:K11,Milling!D6:D8,Milling!D11,Mix!B3:D11",Batch!D3,Batch!D25
|
||||||
Quality control data sheet\2026\ICJEH630 Black,ICJ_EH630 op. [SERIAL].xlsx,inco,"Batch!F2:F3,Batch!I12,Batch!O9:Q10,Batch!O12:Q12,Batch!N10,Batch!N13,Batch!D20:J23,'KW'!C3:C4,Milling!G5:K8,Milling!G11:K11,Milling!D6:D8,Milling!D11,Mix!B3:D11",Batch!D3,Batch!D25
|
Quality control data sheet\[YEAR]\ICJEH630 Black,ICJ_EH630 op. [SERIAL].xlsx,inco,"Batch!F2:F3,Batch!I12,Batch!O9:Q10,Batch!O12:Q12,Batch!N10,Batch!N13,Batch!D20:J23,'KW'!C3:C4,Milling!G5:K8,Milling!G11:K11,Milling!D6:D8,Milling!D11,Mix!B3:D11",Batch!D3,Batch!D25
|
||||||
Quality control data sheet\2025\ICJEH600 Black,ICJ_EH600 op. [SERIAL].xlsx,inco,"Batch!F2:F3,Batch!I12,Batch!O9:Q10,Batch!O12:Q12,Batch!N10,Batch!N13,Batch!D20:J23,'KW'!C3:C4,Milling!G5:K8,Milling!G11:K11,Milling!D6:D8,Milling!D11,Mix!B3:D11",Batch!D3,Batch!D25
|
Quality control data sheet\[YEAR]\ICJEH600 Black,ICJ_EH600 op. [SERIAL].xlsx,inco,"Batch!F2:F3,Batch!I12,Batch!O9:Q10,Batch!O12:Q12,Batch!N10,Batch!N13,Batch!D20:J23,'KW'!C3:C4,Milling!G5:K8,Milling!G11:K11,Milling!D6:D8,Milling!D11,Mix!B3:D11",Batch!D3,Batch!D25
|
||||||
Quality control data sheet\2025\ICJ407 Brown,ICJ_407 op. [SERIAL].xlsx,inco,"Batch!F2:F3,Batch!E12:F12,Batch!O9:Q10,Batch!O12:Q12,Batch!N10,Batch!N13,Batch!D19:J22,'KW'!C3:C4,Milling!G5:K8,Milling!G11:K11,Milling!D6:D8,Milling!D11,Mix!B3:D11",Batch!D3,Batch!D24
|
Quality control data sheet\[YEAR]\ICJ407 Brown,ICJ_407 op. [SERIAL].xlsx,inco,"Batch!F2:F3,Batch!E12:F12,Batch!O9:Q10,Batch!O12:Q12,Batch!N10,Batch!N13,Batch!D19:J22,'KW'!C3:C4,Milling!G5:K8,Milling!G11:K11,Milling!D6:D8,Milling!D11,Mix!B3:D11",Batch!D3,Batch!D24
|
||||||
Quality control data sheet\2025\ICJ408 Brown,ICJ_408 op. [SERIAL].xlsx,inco,"Batch!F2:F3,Batch!E12:F12,Batch!O9:Q10,Batch!O12:Q12,Batch!N10,Batch!N13,Batch!D19:J22,'KW'!C3:C4,Milling!G5:K8,Milling!G11:K11,Milling!D6:D8,Milling!D11,Mix!B3:D11",Batch!D3,Batch!D24
|
Quality control data sheet\[YEAR]\ICJ408 Brown,ICJ_408 op. [SERIAL].xlsx,inco,"Batch!F2:F3,Batch!E12:F12,Batch!O9:Q10,Batch!O12:Q12,Batch!N10,Batch!N13,Batch!D19:J22,'KW'!C3:C4,Milling!G5:K8,Milling!G11:K11,Milling!D6:D8,Milling!D11,Mix!B3:D11",Batch!D3,Batch!D24
|
||||||
Quality control data sheet\2026\ICJ435 Beige,ICJ_435 op. [SERIAL].xlsx,inco,"Batch!F2:F3,Batch!E12:F12,Batch!O9:Q10,Batch!O12:Q12,Batch!N10,Batch!N13,Batch!D19:J22,'KW'!C3:C4,Milling!G5:K8,Milling!G11:K11,Milling!D6:D8,Milling!D11,Mix!B3:D11",Batch!D3,Batch!D24
|
Quality control data sheet\[YEAR]\ICJ435 Beige,ICJ_435 op. [SERIAL].xlsx,inco,"Batch!F2:F3,Batch!E12:F12,Batch!O9:Q10,Batch!O12:Q12,Batch!N10,Batch!N13,Batch!D19:J22,'KW'!C3:C4,Milling!G5:K8,Milling!G11:K11,Milling!D6:D8,Milling!D11,Mix!B3:D11",Batch!D3,Batch!D24
|
||||||
Quality control data sheet\2025\ICJ107 Yellow,ICJ_107 yellow op. [SERIAL].xlsx,inco,"Batch!F2:F3,Batch!E12:F12,Batch!O9:Q10,Batch!O12:Q12,Batch!N10,Batch!N13,Batch!D19:J22,'KW'!C3:C4,Milling!G5:K8,Milling!G11:K11,Milling!D6:D8,Milling!D11,Mix!B3:D11",Batch!D3,Batch!D25
|
Quality control data sheet\[YEAR]\ICJ107 Yellow,ICJ_107 yellow op. [SERIAL].xlsx,inco,"Batch!F2:F3,Batch!E12:F12,Batch!O9:Q10,Batch!O12:Q12,Batch!N10,Batch!N13,Batch!D19:J22,'KW'!C3:C4,Milling!G5:K8,Milling!G11:K11,Milling!D6:D8,Milling!D11,Mix!B3:D11",Batch!D3,Batch!D25
|
||||||
Quality control data sheet\2025\ICJ703 Pink,ICJ_703 op. [SERIAL].xlsx,inco,"Batch!F2:F3,Batch!E12:F12,Batch!O9:Q10,Batch!O12:Q12,Batch!N10,Batch!N13,Batch!D20:J23,'KW'!C3:C4,Milling!G5:K8,Milling!G11:K11,Milling!D6:D8,Milling!D11,Mix!B3:D11",Batch!D3,Batch!D25
|
Quality control data sheet\[YEAR]\ICJ703 Pink,ICJ_703 op. [SERIAL].xlsx,inco,"Batch!F2:F3,Batch!E12:F12,Batch!O9:Q10,Batch!O12:Q12,Batch!N10,Batch!N13,Batch!D20:J23,'KW'!C3:C4,Milling!G5:K8,Milling!G11:K11,Milling!D6:D8,Milling!D11,Mix!B3:D11",Batch!D3,Batch!D25
|
||||||
Quality control data sheet\2024\ICJ309 Cyan,ICJ_309 cyan op. [SERIAL].xlsx,inco,"Batch!F2:F3,Batch!E12:F12,Batch!O9:Q10,Batch!O12:Q12,Batch!N10,Batch!N13,Batch!D19:J22,'KW'!C3:C4,Milling!G5:K8,Milling!G11:K11,Milling!D6:D8,Milling!D11,Mix!B3:D11",Batch!D3,Batch!D25
|
Quality control data sheet\[YEAR]\ICJ309 Cyan,ICJ_309 cyan op. [SERIAL].xlsx,inco,"Batch!F2:F3,Batch!E12:F12,Batch!O9:Q10,Batch!O12:Q12,Batch!N10,Batch!N13,Batch!D19:J22,'KW'!C3:C4,Milling!G5:K8,Milling!G11:K11,Milling!D6:D8,Milling!D11,Mix!B3:D11",Batch!D3,Batch!D25
|
||||||
Quality control data sheet\2025\ICJ109 Golden Yellow,ICJ_109 op. [SERIAL].xlsx,inco,"Batch!F2:F3,Batch!E12:F12,Batch!O9:Q10,Batch!O12:Q12,Batch!N10,Batch!N13,Batch!D20:J23,'KW'!C3:C4,Milling!G5:K8,Milling!G11:K11,Milling!D6:D8,Milling!D11,Mix!B3:D11",Batch!D3,Batch!D25
|
Quality control data sheet\[YEAR]\ICJ109 Golden Yellow,ICJ_109 op. [SERIAL].xlsx,inco,"Batch!F2:F3,Batch!E12:F12,Batch!O9:Q10,Batch!O12:Q12,Batch!N10,Batch!N13,Batch!D20:J23,'KW'!C3:C4,Milling!G5:K8,Milling!G11:K11,Milling!D6:D8,Milling!D11,Mix!B3:D11",Batch!D3,Batch!D25
|
||||||
Quality control data sheet\2026\ICJ152 Yellow,ICJ_152 yellow op. [SERIAL].xlsx,inco,"Batch!F2:F3,Batch!I12,Batch!O9:Q10,Batch!O12:Q12,Batch!N10,Batch!N13,Batch!D20:J23,'KW'!C3:C4,Milling!G5:K8,Milling!G11:K11,Milling!D6:D8,Milling!D11,Mix!B3:D11",Batch!D3,Batch!D25
|
Quality control data sheet\[YEAR]\ICJ152 Yellow,ICJ_152 yellow op. [SERIAL].xlsx,inco,"Batch!F2:F3,Batch!I12,Batch!O9:Q10,Batch!O12:Q12,Batch!N10,Batch!N13,Batch!D20:J23,'KW'!C3:C4,Milling!G5:K8,Milling!G11:K11,Milling!D6:D8,Milling!D11,Mix!B3:D11",Batch!D3,Batch!D25
|
||||||
|
|||||||
|
@@ -130,7 +130,7 @@ def main(argv: list[str] | None = None) -> None:
|
|||||||
width=args.width,
|
width=args.width,
|
||||||
height=args.height,
|
height=args.height,
|
||||||
min_size=(450, 400),
|
min_size=(450, 400),
|
||||||
background_color="#f8fafc",
|
background_color="#0b0e14",
|
||||||
)
|
)
|
||||||
webview.start()
|
webview.start()
|
||||||
|
|
||||||
|
|||||||
@@ -4,6 +4,15 @@
|
|||||||
<meta charset="utf-8">
|
<meta charset="utf-8">
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||||
<title>New QC Sheet</title>
|
<title>New QC Sheet</title>
|
||||||
|
<script>
|
||||||
|
try {
|
||||||
|
if (localStorage.getItem("xlsx-clean-theme") === "light") {
|
||||||
|
document.documentElement.setAttribute("data-theme", "light");
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
/* localStorage may be unavailable in some WebView embeds */
|
||||||
|
}
|
||||||
|
</script>
|
||||||
<style>
|
<style>
|
||||||
@font-face {
|
@font-face {
|
||||||
font-family: "Inter";
|
font-family: "Inter";
|
||||||
@@ -22,17 +31,55 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
:root {
|
:root {
|
||||||
--primary: #0f766e;
|
--primary: #e54d5e;
|
||||||
--secondary: #115e59;
|
--primary-hover: #c93d4e;
|
||||||
--accent: #14b8a6;
|
--accent: #6366f1;
|
||||||
--slate-50: #f8fafc;
|
--accent-2: #8b5cf6;
|
||||||
--slate-300: #cbd5e1;
|
--accent-3: #a855f7;
|
||||||
--slate-500: #64748b;
|
--success: #22c55e;
|
||||||
--slate-700: #334155;
|
--warning: #f59e0b;
|
||||||
--status-ready: #f8fafc;
|
--error: #ef4444;
|
||||||
--status-success: #f0fdfa;
|
--bg: #0b0e14;
|
||||||
--status-skipped: #fffbeb;
|
--bg-alt: #111520;
|
||||||
--status-error: #fef2f2;
|
--surface: #161b22;
|
||||||
|
--surface-2: #1c2230;
|
||||||
|
--border: rgba(255, 255, 255, 0.08);
|
||||||
|
--border-strong: rgba(255, 255, 255, 0.14);
|
||||||
|
--grid-line: rgba(255, 255, 255, 0.06);
|
||||||
|
--grid-size: 32px;
|
||||||
|
--text: #e6e6ef;
|
||||||
|
--text-muted: #8b8b9e;
|
||||||
|
--text-dim: #5a5a6e;
|
||||||
|
--grad-brand: linear-gradient(135deg, var(--primary), var(--accent-3));
|
||||||
|
--grad-soft: linear-gradient(135deg, rgba(229, 77, 94, 0.12), rgba(168, 85, 247, 0.12));
|
||||||
|
--font-sans: "Inter", ui-sans-serif, system-ui, sans-serif;
|
||||||
|
--font-mono: ui-monospace, "JetBrains Mono", "Fira Code", "SF Mono", monospace;
|
||||||
|
--radius: 14px;
|
||||||
|
--radius-sm: 9px;
|
||||||
|
--ease: cubic-bezier(0.22, 1, 0.36, 1);
|
||||||
|
--status-ready: transparent;
|
||||||
|
--status-success: rgba(34, 197, 94, 0.12);
|
||||||
|
--status-skipped: rgba(245, 158, 11, 0.12);
|
||||||
|
--status-error: rgba(239, 68, 68, 0.12);
|
||||||
|
--label-bg: rgba(11, 14, 20, 0.5);
|
||||||
|
}
|
||||||
|
|
||||||
|
html[data-theme="light"] {
|
||||||
|
--bg: #f9f9fb;
|
||||||
|
--bg-alt: #f0f0f5;
|
||||||
|
--surface: #ffffff;
|
||||||
|
--surface-2: #f5f5fa;
|
||||||
|
--border: rgba(0, 0, 0, 0.08);
|
||||||
|
--border-strong: rgba(0, 0, 0, 0.14);
|
||||||
|
--grid-line: rgba(0, 0, 0, 0.07);
|
||||||
|
--text: #1a1a2e;
|
||||||
|
--text-muted: #71717a;
|
||||||
|
--text-dim: #9a9aa5;
|
||||||
|
--grad-soft: linear-gradient(135deg, rgba(229, 77, 94, 0.08), rgba(168, 85, 247, 0.08));
|
||||||
|
--status-success: rgba(34, 197, 94, 0.1);
|
||||||
|
--status-skipped: rgba(245, 158, 11, 0.12);
|
||||||
|
--status-error: rgba(239, 68, 68, 0.1);
|
||||||
|
--label-bg: rgba(249, 249, 251, 0.5);
|
||||||
}
|
}
|
||||||
|
|
||||||
* { box-sizing: border-box; }
|
* { box-sizing: border-box; }
|
||||||
@@ -40,10 +87,24 @@
|
|||||||
body {
|
body {
|
||||||
min-height: 100vh;
|
min-height: 100vh;
|
||||||
margin: 0;
|
margin: 0;
|
||||||
background: var(--slate-50);
|
background: var(--bg);
|
||||||
color: var(--slate-700);
|
color: var(--text);
|
||||||
font-family: "Inter", sans-serif;
|
font-family: var(--font-sans);
|
||||||
font-size: 15px;
|
font-size: 15px;
|
||||||
|
line-height: 1.5;
|
||||||
|
-webkit-font-smoothing: antialiased;
|
||||||
|
}
|
||||||
|
|
||||||
|
body::before {
|
||||||
|
content: "";
|
||||||
|
position: fixed;
|
||||||
|
inset: 0;
|
||||||
|
z-index: -1;
|
||||||
|
pointer-events: none;
|
||||||
|
background-image:
|
||||||
|
linear-gradient(to right, var(--grid-line) 1px, transparent 1px),
|
||||||
|
linear-gradient(to bottom, var(--grid-line) 1px, transparent 1px);
|
||||||
|
background-size: var(--grid-size) var(--grid-size);
|
||||||
}
|
}
|
||||||
|
|
||||||
.page {
|
.page {
|
||||||
@@ -54,23 +115,72 @@
|
|||||||
|
|
||||||
.panel {
|
.panel {
|
||||||
display: flex;
|
display: flex;
|
||||||
flex: 1;
|
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
width: min(100%, 36rem);
|
width: min(100%, 36rem);
|
||||||
margin: auto;
|
margin: auto;
|
||||||
|
background: transparent;
|
||||||
|
}
|
||||||
|
|
||||||
|
.heading-row {
|
||||||
|
display: flex;
|
||||||
|
align-items: flex-start;
|
||||||
|
justify-content: space-between;
|
||||||
|
gap: 12px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.theme-toggle {
|
||||||
|
display: inline-flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
flex-shrink: 0;
|
||||||
|
min-width: 52px;
|
||||||
|
height: 28px;
|
||||||
|
margin-top: 2px;
|
||||||
|
padding: 0 8px;
|
||||||
|
border: 1px solid var(--border);
|
||||||
|
border-radius: var(--radius-sm);
|
||||||
|
background: var(--surface-2);
|
||||||
|
color: var(--text);
|
||||||
|
cursor: pointer;
|
||||||
|
font: inherit;
|
||||||
|
font-size: 0.7rem;
|
||||||
|
font-weight: 700;
|
||||||
|
letter-spacing: 0.04em;
|
||||||
|
text-transform: uppercase;
|
||||||
|
line-height: 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
.theme-toggle:hover {
|
||||||
|
background: var(--bg-alt);
|
||||||
|
border-color: var(--border-strong);
|
||||||
|
}
|
||||||
|
|
||||||
|
.theme-toggle:focus-visible {
|
||||||
|
outline: 2px solid var(--accent-3);
|
||||||
|
outline-offset: 2px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.eyebrow {
|
||||||
|
margin: 0 0 8px;
|
||||||
|
color: var(--primary);
|
||||||
|
font-size: 0.75rem;
|
||||||
|
font-weight: 700;
|
||||||
|
letter-spacing: 0.08em;
|
||||||
|
text-transform: uppercase;
|
||||||
}
|
}
|
||||||
|
|
||||||
h1 {
|
h1 {
|
||||||
margin: 0;
|
margin: 0;
|
||||||
color: var(--secondary);
|
color: var(--text);
|
||||||
font-size: 1.875rem;
|
font-size: 1.875rem;
|
||||||
font-weight: 700;
|
font-weight: 700;
|
||||||
line-height: 2.25rem;
|
line-height: 1.15;
|
||||||
|
letter-spacing: -0.02em;
|
||||||
}
|
}
|
||||||
|
|
||||||
.subtitle {
|
.subtitle {
|
||||||
margin: 8px 0 24px;
|
margin: 8px 0 22px;
|
||||||
color: #475569;
|
color: var(--text-muted);
|
||||||
line-height: 1.5;
|
line-height: 1.5;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -78,34 +188,35 @@
|
|||||||
|
|
||||||
.field {
|
.field {
|
||||||
position: relative;
|
position: relative;
|
||||||
display: block;
|
display: flex;
|
||||||
padding-top: 8px;
|
flex-direction: column;
|
||||||
|
align-items: flex-start;
|
||||||
|
gap: 6px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.field-label {
|
.field-label {
|
||||||
position: absolute;
|
|
||||||
z-index: 1;
|
z-index: 1;
|
||||||
top: 0;
|
margin-left: 4px;
|
||||||
left: 11px;
|
|
||||||
padding: 0 4px;
|
padding: 0 4px;
|
||||||
background: var(--slate-50);
|
background: var(--label-bg);
|
||||||
color: var(--primary);
|
color: var(--primary);
|
||||||
font-size: 0.75rem;
|
font-size: 0.75rem;
|
||||||
line-height: 1rem;
|
line-height: 1.2;
|
||||||
pointer-events: none;
|
pointer-events: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
select, input {
|
select, input {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
|
align-self: stretch;
|
||||||
min-height: 54px;
|
min-height: 54px;
|
||||||
padding: 16px 12px 6px;
|
padding: 16px 12px;
|
||||||
border: 1px solid var(--slate-300);
|
border: 1px solid var(--border-strong);
|
||||||
border-radius: 4px;
|
border-radius: var(--radius-sm);
|
||||||
outline: none;
|
outline: none;
|
||||||
background: #fff;
|
background: var(--surface-2);
|
||||||
color: #0f172a;
|
color: var(--text);
|
||||||
font: inherit;
|
font: inherit;
|
||||||
transition: border-color 150ms ease, box-shadow 150ms ease;
|
transition: border-color 150ms var(--ease), box-shadow 150ms var(--ease);
|
||||||
}
|
}
|
||||||
|
|
||||||
.combobox-input {
|
.combobox-input {
|
||||||
@@ -130,12 +241,12 @@
|
|||||||
|
|
||||||
.combobox-caret {
|
.combobox-caret {
|
||||||
position: absolute;
|
position: absolute;
|
||||||
top: 0;
|
|
||||||
right: 12px;
|
right: 12px;
|
||||||
bottom: 0;
|
bottom: 0;
|
||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
color: var(--slate-500);
|
height: 54px;
|
||||||
|
color: var(--text-muted);
|
||||||
pointer-events: none;
|
pointer-events: none;
|
||||||
font-size: 0.75rem;
|
font-size: 0.75rem;
|
||||||
}
|
}
|
||||||
@@ -149,10 +260,10 @@
|
|||||||
max-height: 220px;
|
max-height: 220px;
|
||||||
overflow-y: auto;
|
overflow-y: auto;
|
||||||
padding: 4px 0;
|
padding: 4px 0;
|
||||||
background: #fff;
|
background: var(--surface-2);
|
||||||
border: 1px solid var(--slate-300);
|
border: 1px solid var(--border-strong);
|
||||||
border-radius: 4px;
|
border-radius: var(--radius-sm);
|
||||||
box-shadow: 0 4px 12px rgb(15 23 42 / 12%);
|
box-shadow: 0 12px 32px rgb(0 0 0 / 35%);
|
||||||
}
|
}
|
||||||
|
|
||||||
.combobox-panel[hidden] { display: none; }
|
.combobox-panel[hidden] { display: none; }
|
||||||
@@ -160,49 +271,49 @@
|
|||||||
.combobox-option {
|
.combobox-option {
|
||||||
padding: 8px 12px;
|
padding: 8px 12px;
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
color: var(--slate-700);
|
color: var(--text);
|
||||||
line-height: 1.25;
|
line-height: 1.25;
|
||||||
}
|
}
|
||||||
|
|
||||||
.combobox-option[aria-selected="true"],
|
.combobox-option[aria-selected="true"],
|
||||||
.combobox-option:hover {
|
.combobox-option:hover {
|
||||||
background: var(--status-success);
|
background: var(--grad-soft);
|
||||||
color: var(--secondary);
|
color: var(--text);
|
||||||
}
|
}
|
||||||
|
|
||||||
.combobox-option[hidden] { display: none; }
|
.combobox-option[hidden] { display: none; }
|
||||||
|
|
||||||
.combobox-empty {
|
.combobox-empty {
|
||||||
padding: 8px 12px;
|
padding: 8px 12px;
|
||||||
color: var(--slate-500);
|
color: var(--text-muted);
|
||||||
font-style: italic;
|
font-style: italic;
|
||||||
}
|
}
|
||||||
|
|
||||||
select:focus, input:focus,
|
select:focus, input:focus,
|
||||||
.combobox-input:focus {
|
.combobox-input:focus {
|
||||||
border-color: var(--primary);
|
border-color: var(--accent);
|
||||||
box-shadow: 0 0 0 2px rgb(20 184 166 / 25%);
|
box-shadow: 0 0 0 3px rgb(99 102 241 / 28%);
|
||||||
}
|
}
|
||||||
|
|
||||||
select:disabled, input:disabled,
|
select:disabled, input:disabled,
|
||||||
.combobox-input:disabled {
|
.combobox-input:disabled {
|
||||||
cursor: not-allowed;
|
cursor: not-allowed;
|
||||||
background: #f1f5f9;
|
background: var(--bg-alt);
|
||||||
color: var(--slate-500);
|
color: var(--text-dim);
|
||||||
}
|
}
|
||||||
|
|
||||||
.divider {
|
.divider {
|
||||||
height: 1px;
|
height: 1px;
|
||||||
margin: 24px 0;
|
margin: 22px 0;
|
||||||
background: var(--slate-300);
|
background: var(--border);
|
||||||
}
|
}
|
||||||
|
|
||||||
button {
|
#create-button {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
min-height: 42px;
|
min-height: 44px;
|
||||||
border: 0;
|
border: 0;
|
||||||
border-radius: 4px;
|
border-radius: var(--radius-sm);
|
||||||
background: var(--primary);
|
background: var(--grad-brand);
|
||||||
color: #fff;
|
color: #fff;
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
font: inherit;
|
font: inherit;
|
||||||
@@ -210,46 +321,56 @@
|
|||||||
font-weight: 700;
|
font-weight: 700;
|
||||||
letter-spacing: 0.04em;
|
letter-spacing: 0.04em;
|
||||||
text-transform: uppercase;
|
text-transform: uppercase;
|
||||||
transition: background-color 150ms ease, box-shadow 150ms ease;
|
box-shadow: 0 8px 22px -10px var(--primary);
|
||||||
|
transition: transform 150ms var(--ease), box-shadow 150ms var(--ease), filter 150ms var(--ease);
|
||||||
}
|
}
|
||||||
|
|
||||||
button:hover:not(:disabled) {
|
#create-button:hover:not(:disabled) {
|
||||||
background: var(--secondary);
|
filter: brightness(1.06);
|
||||||
box-shadow: 0 2px 5px rgb(15 118 110 / 25%);
|
box-shadow: 0 10px 26px -8px var(--primary);
|
||||||
}
|
}
|
||||||
|
|
||||||
button:focus-visible {
|
#create-button:focus-visible {
|
||||||
outline: 2px solid var(--accent);
|
outline: 2px solid var(--accent-3);
|
||||||
outline-offset: 2px;
|
outline-offset: 2px;
|
||||||
}
|
}
|
||||||
|
|
||||||
button:disabled { cursor: not-allowed; opacity: 0.65; }
|
#create-button:disabled { cursor: not-allowed; opacity: 0.65; }
|
||||||
|
|
||||||
.status {
|
.status {
|
||||||
min-height: 48px;
|
min-height: 48px;
|
||||||
margin-top: 16px;
|
margin-top: 16px;
|
||||||
padding: 12px;
|
padding: 12px;
|
||||||
border-radius: 4px;
|
border: 1px solid var(--border);
|
||||||
color: var(--slate-700);
|
border-radius: var(--radius-sm);
|
||||||
|
color: var(--text-muted);
|
||||||
|
font-family: var(--font-mono);
|
||||||
|
font-size: 0.8rem;
|
||||||
line-height: 1.45;
|
line-height: 1.45;
|
||||||
white-space: pre-wrap;
|
white-space: pre-wrap;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.status::before {
|
||||||
|
content: "$ ";
|
||||||
|
color: var(--primary);
|
||||||
|
font-weight: 700;
|
||||||
|
}
|
||||||
|
|
||||||
.status-ready { background: var(--status-ready); }
|
.status-ready { background: var(--status-ready); }
|
||||||
.status-success { background: var(--status-success); color: #115e59; }
|
.status-success { background: var(--status-success); color: var(--success); }
|
||||||
.status-skipped { background: var(--status-skipped); color: #92400e; }
|
.status-skipped { background: var(--status-skipped); color: var(--warning); }
|
||||||
.status-error { background: var(--status-error); color: #b91c1c; }
|
.status-error { background: var(--status-error); color: var(--error); }
|
||||||
|
|
||||||
.version {
|
.version {
|
||||||
margin: auto 0 0;
|
margin-top: 16px;
|
||||||
padding-top: 24px;
|
color: var(--text-dim);
|
||||||
color: #94a3b8;
|
font-family: var(--font-mono);
|
||||||
font-size: 0.75rem;
|
font-size: 0.75rem;
|
||||||
text-align: right;
|
text-align: right;
|
||||||
}
|
}
|
||||||
|
|
||||||
@media (max-width: 480px) {
|
@media (max-width: 480px) {
|
||||||
.page { padding: 18px; }
|
.page { padding: 14px; }
|
||||||
h1 { font-size: 1.5rem; }
|
h1 { font-size: 1.5rem; }
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
@@ -257,54 +378,69 @@
|
|||||||
<body>
|
<body>
|
||||||
<main class="page">
|
<main class="page">
|
||||||
<section class="panel" aria-labelledby="heading">
|
<section class="panel" aria-labelledby="heading">
|
||||||
<h1 id="heading">New QC Sheet</h1>
|
<div class="heading-row">
|
||||||
|
<div>
|
||||||
|
<p class="eyebrow">QC datasheet</p>
|
||||||
|
<h1 id="heading">New QC Sheet</h1>
|
||||||
|
</div>
|
||||||
|
<button
|
||||||
|
id="theme-toggle"
|
||||||
|
class="theme-toggle"
|
||||||
|
type="button"
|
||||||
|
aria-label="Switch to light theme"
|
||||||
|
title="Switch theme">
|
||||||
|
Aa
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
<p class="subtitle">Create a new QC datasheet from the latest matching workbook.</p>
|
<p class="subtitle">Create a new QC datasheet from the latest matching workbook.</p>
|
||||||
|
|
||||||
<div class="fields">
|
<form id="create-form">
|
||||||
<label class="field combobox" for="set-dropdown-input">
|
<div class="fields">
|
||||||
<span id="set-label" class="field-label">Select Set</span>
|
<label class="field combobox" for="set-dropdown-input">
|
||||||
<input
|
<span id="set-label" class="field-label">Select Set</span>
|
||||||
id="set-dropdown-input"
|
<input
|
||||||
class="combobox-input"
|
id="set-dropdown-input"
|
||||||
type="text"
|
class="combobox-input"
|
||||||
autocomplete="off"
|
type="text"
|
||||||
spellcheck="false"
|
autocomplete="off"
|
||||||
role="combobox"
|
spellcheck="false"
|
||||||
aria-expanded="false"
|
role="combobox"
|
||||||
aria-controls="set-dropdown-panel"
|
aria-expanded="false"
|
||||||
aria-autocomplete="list"
|
aria-controls="set-dropdown-panel"
|
||||||
aria-labelledby="set-label"
|
aria-autocomplete="list"
|
||||||
placeholder=" ">
|
aria-labelledby="set-label"
|
||||||
<select id="set-dropdown" aria-labelledby="set-label" tabindex="-1"></select>
|
placeholder=" ">
|
||||||
<span class="combobox-caret" aria-hidden="true">▾</span>
|
<select id="set-dropdown" aria-labelledby="set-label" tabindex="-1"></select>
|
||||||
<div id="set-dropdown-panel" class="combobox-panel" role="listbox" aria-labelledby="set-label" hidden></div>
|
<span class="combobox-caret" aria-hidden="true">▾</span>
|
||||||
</label>
|
<div id="set-dropdown-panel" class="combobox-panel" role="listbox" aria-labelledby="set-label" hidden></div>
|
||||||
<label class="field combobox" for="ink-dropdown-input">
|
</label>
|
||||||
<span id="ink-label" class="field-label">Select Ink Color</span>
|
<label class="field combobox" for="ink-dropdown-input">
|
||||||
<input
|
<span id="ink-label" class="field-label">Select Ink Color</span>
|
||||||
id="ink-dropdown-input"
|
<input
|
||||||
class="combobox-input"
|
id="ink-dropdown-input"
|
||||||
type="text"
|
class="combobox-input"
|
||||||
autocomplete="off"
|
type="text"
|
||||||
spellcheck="false"
|
autocomplete="off"
|
||||||
role="combobox"
|
spellcheck="false"
|
||||||
aria-expanded="false"
|
role="combobox"
|
||||||
aria-controls="ink-dropdown-panel"
|
aria-expanded="false"
|
||||||
aria-autocomplete="list"
|
aria-controls="ink-dropdown-panel"
|
||||||
aria-labelledby="ink-label"
|
aria-autocomplete="list"
|
||||||
placeholder=" ">
|
aria-labelledby="ink-label"
|
||||||
<select id="ink-dropdown" aria-labelledby="ink-label" tabindex="-1"></select>
|
placeholder=" ">
|
||||||
<span class="combobox-caret" aria-hidden="true">▾</span>
|
<select id="ink-dropdown" aria-labelledby="ink-label" tabindex="-1"></select>
|
||||||
<div id="ink-dropdown-panel" class="combobox-panel" role="listbox" aria-labelledby="ink-label" hidden></div>
|
<span class="combobox-caret" aria-hidden="true">▾</span>
|
||||||
</label>
|
<div id="ink-dropdown-panel" class="combobox-panel" role="listbox" aria-labelledby="ink-label" hidden></div>
|
||||||
<label class="field" for="serial-input">
|
</label>
|
||||||
<span id="serial-label" class="field-label">Serial:</span>
|
<label class="field" for="serial-input">
|
||||||
<input id="serial-input" type="text" placeholder="e.g. 1234/A" aria-labelledby="serial-label">
|
<span id="serial-label" class="field-label">Serial:</span>
|
||||||
</label>
|
<input id="serial-input" type="text" placeholder="e.g. 1234/A" aria-labelledby="serial-label">
|
||||||
</div>
|
</label>
|
||||||
|
</div>
|
||||||
|
|
||||||
<div class="divider"></div>
|
<div class="divider"></div>
|
||||||
<button id="create-button" type="button">Create datasheet</button>
|
<button id="create-button" type="submit">Create datasheet</button>
|
||||||
|
</form>
|
||||||
<div id="status" class="status status-ready" role="status">Loading configuration...</div>
|
<div id="status" class="status status-ready" role="status">Loading configuration...</div>
|
||||||
<p id="version" class="version"></p>
|
<p id="version" class="version"></p>
|
||||||
</section>
|
</section>
|
||||||
@@ -318,8 +454,42 @@
|
|||||||
const setPanel = document.getElementById("set-dropdown-panel");
|
const setPanel = document.getElementById("set-dropdown-panel");
|
||||||
const inkPanel = document.getElementById("ink-dropdown-panel");
|
const inkPanel = document.getElementById("ink-dropdown-panel");
|
||||||
const serialInput = document.getElementById("serial-input");
|
const serialInput = document.getElementById("serial-input");
|
||||||
|
const createForm = document.getElementById("create-form");
|
||||||
const createBtn = document.getElementById("create-button");
|
const createBtn = document.getElementById("create-button");
|
||||||
const status = document.getElementById("status");
|
const status = document.getElementById("status");
|
||||||
|
const themeToggle = document.getElementById("theme-toggle");
|
||||||
|
|
||||||
|
function isLightTheme() {
|
||||||
|
return document.documentElement.getAttribute("data-theme") === "light";
|
||||||
|
}
|
||||||
|
|
||||||
|
function syncThemeToggle() {
|
||||||
|
const light = isLightTheme();
|
||||||
|
themeToggle.setAttribute(
|
||||||
|
"aria-label",
|
||||||
|
light ? "Switch to dark theme" : "Switch to light theme"
|
||||||
|
);
|
||||||
|
themeToggle.textContent = light ? "Dark" : "Light";
|
||||||
|
}
|
||||||
|
|
||||||
|
function applyTheme(theme) {
|
||||||
|
if (theme === "light") {
|
||||||
|
document.documentElement.setAttribute("data-theme", "light");
|
||||||
|
} else {
|
||||||
|
document.documentElement.removeAttribute("data-theme");
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
localStorage.setItem("xlsx-clean-theme", theme);
|
||||||
|
} catch (error) {
|
||||||
|
/* ignore quota / privacy mode */
|
||||||
|
}
|
||||||
|
syncThemeToggle();
|
||||||
|
}
|
||||||
|
|
||||||
|
themeToggle.addEventListener("click", () => {
|
||||||
|
applyTheme(isLightTheme() ? "dark" : "light");
|
||||||
|
});
|
||||||
|
syncThemeToggle();
|
||||||
|
|
||||||
// Builds a searchable combobox. The underlying <select> stays as the
|
// Builds a searchable combobox. The underlying <select> stays as the
|
||||||
// semantic source of truth; the visible widget is a text <input> plus a
|
// semantic source of truth; the visible widget is a text <input> plus a
|
||||||
@@ -424,14 +594,15 @@
|
|||||||
empty.textContent = "No matches";
|
empty.textContent = "No matches";
|
||||||
empty.hidden = true;
|
empty.hidden = true;
|
||||||
panelEl.append(empty);
|
panelEl.append(empty);
|
||||||
if (selectEl.value && !inputEl.value) {
|
inputEl.value = selectEl.value || "";
|
||||||
inputEl.value = selectEl.value;
|
|
||||||
}
|
|
||||||
inputDirty = false;
|
inputDirty = false;
|
||||||
syncDisabled();
|
syncDisabled();
|
||||||
};
|
};
|
||||||
|
|
||||||
inputEl.addEventListener("focus", open);
|
inputEl.addEventListener("focus", open);
|
||||||
|
inputEl.addEventListener("mousedown", () => {
|
||||||
|
open();
|
||||||
|
});
|
||||||
inputEl.addEventListener("input", () => {
|
inputEl.addEventListener("input", () => {
|
||||||
inputDirty = true;
|
inputDirty = true;
|
||||||
if (!openState) open();
|
if (!openState) open();
|
||||||
@@ -570,7 +741,7 @@
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
createBtn.addEventListener("click", async () => {
|
async function createDatasheet() {
|
||||||
createBtn.disabled = true;
|
createBtn.disabled = true;
|
||||||
try {
|
try {
|
||||||
const result = await window.pywebview.api.create(
|
const result = await window.pywebview.api.create(
|
||||||
@@ -582,6 +753,11 @@
|
|||||||
} finally {
|
} finally {
|
||||||
createBtn.disabled = false;
|
createBtn.disabled = false;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
createForm.addEventListener("submit", async (event) => {
|
||||||
|
event.preventDefault();
|
||||||
|
await createDatasheet();
|
||||||
});
|
});
|
||||||
|
|
||||||
window.addEventListener("pywebviewready", initialize);
|
window.addEventListener("pywebviewready", initialize);
|
||||||
|
|||||||
105
tests/test_com_backend.py
Normal file
105
tests/test_com_backend.py
Normal file
@@ -0,0 +1,105 @@
|
|||||||
|
"""Tests for win32com gen_py cache recovery (no real Excel required)."""
|
||||||
|
|
||||||
|
from __future__ import annotations
|
||||||
|
|
||||||
|
import sys
|
||||||
|
from types import ModuleType, SimpleNamespace
|
||||||
|
from unittest.mock import MagicMock, patch
|
||||||
|
|
||||||
|
import pytest
|
||||||
|
|
||||||
|
from xlsx_clean.com_backend import (
|
||||||
|
_clear_gen_py_cache,
|
||||||
|
_excel_application,
|
||||||
|
_is_gen_py_cache_error,
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
def _install_fake_win32com(*, ensure, dispatch=None, gen_path="/tmp/gen_py"):
|
||||||
|
"""Put fake win32com + win32com.client modules into sys.modules."""
|
||||||
|
win32com = ModuleType("win32com")
|
||||||
|
win32com.__gen_path__ = gen_path
|
||||||
|
client = ModuleType("win32com.client")
|
||||||
|
client.gencache = SimpleNamespace(EnsureDispatch=ensure)
|
||||||
|
client.Dispatch = dispatch if dispatch is not None else MagicMock()
|
||||||
|
return patch.dict(sys.modules, {"win32com": win32com, "win32com.client": client})
|
||||||
|
|
||||||
|
|
||||||
|
def test_is_gen_py_cache_error_matches_known_messages():
|
||||||
|
assert _is_gen_py_cache_error(
|
||||||
|
AttributeError(
|
||||||
|
"module 'win32com.gen_py.00020813-0000-0000-C000-000000000046x0x1x9' "
|
||||||
|
"has no attribute 'CLSIDToPackageMap'"
|
||||||
|
)
|
||||||
|
)
|
||||||
|
assert _is_gen_py_cache_error(
|
||||||
|
AttributeError("... has no attribute 'CLSIDToClassMap'")
|
||||||
|
)
|
||||||
|
assert not _is_gen_py_cache_error(AttributeError("something else"))
|
||||||
|
assert not _is_gen_py_cache_error(RuntimeError("CLSIDToPackageMap"))
|
||||||
|
|
||||||
|
|
||||||
|
def test_clear_gen_py_cache_removes_modules_and_directory(tmp_path):
|
||||||
|
gen_root = tmp_path / "gen_py"
|
||||||
|
bad = gen_root / "00020813-0000-0000-C000-000000000046x0x1x9"
|
||||||
|
bad.mkdir(parents=True)
|
||||||
|
(bad / "__init__.py").write_text("# corrupt", encoding="utf-8")
|
||||||
|
|
||||||
|
mod_name = "win32com.gen_py.00020813-0000-0000-C000-000000000046x0x1x9"
|
||||||
|
fake_mod = ModuleType(mod_name)
|
||||||
|
fake_win32com = ModuleType("win32com")
|
||||||
|
fake_win32com.__gen_path__ = str(gen_root)
|
||||||
|
|
||||||
|
with patch.dict(sys.modules, {"win32com": fake_win32com, mod_name: fake_mod}):
|
||||||
|
cleared = _clear_gen_py_cache()
|
||||||
|
assert cleared == gen_root
|
||||||
|
assert not gen_root.exists()
|
||||||
|
assert mod_name not in sys.modules
|
||||||
|
|
||||||
|
|
||||||
|
def test_excel_application_clears_cache_and_retries_ensure_dispatch():
|
||||||
|
excel = object()
|
||||||
|
ensure = MagicMock(
|
||||||
|
side_effect=[
|
||||||
|
AttributeError(
|
||||||
|
"module 'win32com.gen_py.00020813x0x1x9' has no attribute 'CLSIDToPackageMap'"
|
||||||
|
),
|
||||||
|
excel,
|
||||||
|
]
|
||||||
|
)
|
||||||
|
|
||||||
|
with (
|
||||||
|
_install_fake_win32com(ensure=ensure),
|
||||||
|
patch("xlsx_clean.com_backend._clear_gen_py_cache", return_value=None) as clear,
|
||||||
|
):
|
||||||
|
result = _excel_application()
|
||||||
|
|
||||||
|
assert result is excel
|
||||||
|
assert ensure.call_count == 2
|
||||||
|
clear.assert_called_once_with()
|
||||||
|
|
||||||
|
|
||||||
|
def test_excel_application_falls_back_to_dispatch_after_second_failure():
|
||||||
|
excel = object()
|
||||||
|
err = AttributeError("has no attribute 'CLSIDToClassMap'")
|
||||||
|
ensure = MagicMock(side_effect=[err, err])
|
||||||
|
dispatch = MagicMock(return_value=excel)
|
||||||
|
|
||||||
|
with (
|
||||||
|
_install_fake_win32com(ensure=ensure, dispatch=dispatch),
|
||||||
|
patch("xlsx_clean.com_backend._clear_gen_py_cache", return_value=None),
|
||||||
|
):
|
||||||
|
result = _excel_application()
|
||||||
|
|
||||||
|
assert result is excel
|
||||||
|
dispatch.assert_called_once_with("Excel.Application")
|
||||||
|
|
||||||
|
|
||||||
|
def test_excel_application_rethrows_unrelated_attribute_error():
|
||||||
|
ensure = MagicMock(side_effect=AttributeError("unrelated"))
|
||||||
|
|
||||||
|
with (
|
||||||
|
_install_fake_win32com(ensure=ensure),
|
||||||
|
pytest.raises(AttributeError, match="unrelated"),
|
||||||
|
):
|
||||||
|
_excel_application()
|
||||||
79
tests/test_core.py
Normal file
79
tests/test_core.py
Normal file
@@ -0,0 +1,79 @@
|
|||||||
|
from pathlib import Path
|
||||||
|
|
||||||
|
import pytest
|
||||||
|
|
||||||
|
from xlsx_clean.core import resolve_write_year_dir, resolve_year_dir
|
||||||
|
|
||||||
|
|
||||||
|
def _touch(path: Path) -> None:
|
||||||
|
path.parent.mkdir(parents=True, exist_ok=True)
|
||||||
|
path.write_bytes(b"")
|
||||||
|
|
||||||
|
|
||||||
|
def test_resolve_year_picks_largest_dir_with_matching_sheet(tmp_path: Path):
|
||||||
|
pattern = "ICJ_108 op. [SERIAL].xlsx"
|
||||||
|
_touch(tmp_path / "2025" / "ICJ108 Beige" / "ICJ_108 op. 1.xlsx")
|
||||||
|
_touch(tmp_path / "2026" / "ICJ108 Beige" / "ICJ_108 op. 2.xlsx")
|
||||||
|
placeholder = tmp_path / "[YEAR]" / "ICJ108 Beige"
|
||||||
|
assert resolve_year_dir(placeholder, pattern) == tmp_path / "2026" / "ICJ108 Beige"
|
||||||
|
|
||||||
|
|
||||||
|
def test_resolve_year_ignores_larger_empty_year(tmp_path: Path):
|
||||||
|
pattern = "ICJ_108 op. [SERIAL].xlsx"
|
||||||
|
_touch(tmp_path / "2025" / "ICJ108 Beige" / "ICJ_108 op. 1.xlsx")
|
||||||
|
(tmp_path / "2026" / "ICJ108 Beige").mkdir(parents=True)
|
||||||
|
placeholder = tmp_path / "[YEAR]" / "ICJ108 Beige"
|
||||||
|
assert resolve_year_dir(placeholder, pattern) == tmp_path / "2025" / "ICJ108 Beige"
|
||||||
|
|
||||||
|
|
||||||
|
def test_resolve_year_jalali_style(tmp_path: Path):
|
||||||
|
pattern = "KRCY1100T Blue [SERIAL].xlsx"
|
||||||
|
_touch(tmp_path / "1402" / "KRCY1100T Blue" / "KRCY1100T Blue 1.xlsx")
|
||||||
|
_touch(tmp_path / "1403" / "KRCY1100T Blue" / "KRCY1100T Blue 2.xlsx")
|
||||||
|
placeholder = tmp_path / "[YEAR]" / "KRCY1100T Blue"
|
||||||
|
assert resolve_year_dir(placeholder, pattern) == tmp_path / "1403" / "KRCY1100T Blue"
|
||||||
|
|
||||||
|
|
||||||
|
def test_resolve_year_passthrough_without_token(tmp_path: Path):
|
||||||
|
path = tmp_path / "2025" / "ICJ108 Beige"
|
||||||
|
assert resolve_year_dir(path, "x [SERIAL].xlsx") == path
|
||||||
|
|
||||||
|
|
||||||
|
def test_resolve_year_fails_when_no_sheets(tmp_path: Path):
|
||||||
|
(tmp_path / "2026" / "ICJ108 Beige").mkdir(parents=True)
|
||||||
|
with pytest.raises(FileNotFoundError, match="No year directory"):
|
||||||
|
resolve_year_dir(tmp_path / "[YEAR]" / "ICJ108 Beige", "ICJ_108 op. [SERIAL].xlsx")
|
||||||
|
|
||||||
|
|
||||||
|
def test_resolve_write_year_picks_largest_even_if_empty(tmp_path: Path):
|
||||||
|
_touch(tmp_path / "2025" / "ICJ108 Beige" / "ICJ_108 op. 1.xlsx")
|
||||||
|
(tmp_path / "2026").mkdir()
|
||||||
|
placeholder = tmp_path / "[YEAR]" / "ICJ108 Beige"
|
||||||
|
assert resolve_write_year_dir(placeholder) == tmp_path / "2026" / "ICJ108 Beige"
|
||||||
|
|
||||||
|
|
||||||
|
def test_resolve_write_year_jalali_style(tmp_path: Path):
|
||||||
|
(tmp_path / "1402").mkdir()
|
||||||
|
(tmp_path / "1403").mkdir()
|
||||||
|
placeholder = tmp_path / "[YEAR]" / "KRCY1100T Blue"
|
||||||
|
assert resolve_write_year_dir(placeholder) == tmp_path / "1403" / "KRCY1100T Blue"
|
||||||
|
|
||||||
|
|
||||||
|
def test_resolve_write_year_passthrough_without_token(tmp_path: Path):
|
||||||
|
path = tmp_path / "2025" / "ICJ108 Beige"
|
||||||
|
assert resolve_write_year_dir(path) == path
|
||||||
|
|
||||||
|
|
||||||
|
def test_resolve_write_year_fails_when_no_digit_dirs(tmp_path: Path):
|
||||||
|
(tmp_path / "notes").mkdir()
|
||||||
|
with pytest.raises(FileNotFoundError, match="No year directory"):
|
||||||
|
resolve_write_year_dir(tmp_path / "[YEAR]" / "ICJ108 Beige")
|
||||||
|
|
||||||
|
|
||||||
|
def test_read_and_write_year_differ_when_sheets_only_in_older(tmp_path: Path):
|
||||||
|
pattern = "ICJ_108 op. [SERIAL].xlsx"
|
||||||
|
_touch(tmp_path / "2025" / "ICJ108 Beige" / "ICJ_108 op. 1.xlsx")
|
||||||
|
(tmp_path / "2026").mkdir()
|
||||||
|
placeholder = tmp_path / "[YEAR]" / "ICJ108 Beige"
|
||||||
|
assert resolve_year_dir(placeholder, pattern) == tmp_path / "2025" / "ICJ108 Beige"
|
||||||
|
assert resolve_write_year_dir(placeholder) == tmp_path / "2026" / "ICJ108 Beige"
|
||||||
@@ -37,7 +37,7 @@ def test_main_initializes_api_before_opening_window():
|
|||||||
"width": 900,
|
"width": 900,
|
||||||
"height": 700,
|
"height": 700,
|
||||||
"min_size": (450, 400),
|
"min_size": (450, 400),
|
||||||
"background_color": "#f8fafc",
|
"background_color": "#0b0e14",
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
("start",),
|
("start",),
|
||||||
|
|||||||
19
tests/test_setup_linux.py
Normal file
19
tests/test_setup_linux.py
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
from pathlib import Path
|
||||||
|
|
||||||
|
|
||||||
|
def test_setup_linux_pins_system_python_for_uv_sync():
|
||||||
|
script = Path("desktop/setup_linux.sh").read_text(encoding="utf-8")
|
||||||
|
|
||||||
|
assert "uv venv --python /usr/bin/python3 --no-managed-python --system-site-packages" in script
|
||||||
|
|
||||||
|
sync_lines = [
|
||||||
|
line.strip()
|
||||||
|
for line in script.splitlines()
|
||||||
|
if line.strip().startswith("uv sync")
|
||||||
|
]
|
||||||
|
assert sync_lines == [
|
||||||
|
"uv sync --python /usr/bin/python3 --no-managed-python"
|
||||||
|
]
|
||||||
|
assert "--python-preference" not in script
|
||||||
|
assert "uv sync --active" not in script
|
||||||
|
assert "include-system-site-packages = true" in script
|
||||||
@@ -1,5 +1,6 @@
|
|||||||
import re
|
import re
|
||||||
from html.parser import HTMLParser
|
from html.parser import HTMLParser
|
||||||
|
from pathlib import Path
|
||||||
|
|
||||||
from xlsx_clean.paths import package_file
|
from xlsx_clean.paths import package_file
|
||||||
|
|
||||||
@@ -20,6 +21,8 @@ def test_ui_asset_exists_and_has_required_bridge_content():
|
|||||||
'id="set-label"',
|
'id="set-label"',
|
||||||
'id="ink-label"',
|
'id="ink-label"',
|
||||||
'id="serial-label"',
|
'id="serial-label"',
|
||||||
|
'id="create-form"',
|
||||||
|
'id="create-button" type="submit"',
|
||||||
"Create datasheet",
|
"Create datasheet",
|
||||||
"status-ready",
|
"status-ready",
|
||||||
"status-success",
|
"status-success",
|
||||||
@@ -30,7 +33,10 @@ def test_ui_asset_exists_and_has_required_bridge_content():
|
|||||||
"get_initial_data()",
|
"get_initial_data()",
|
||||||
"get_inks(setDropdown.value)",
|
"get_inks(setDropdown.value)",
|
||||||
"api.create(",
|
"api.create(",
|
||||||
|
'createForm.addEventListener("submit"',
|
||||||
"finally",
|
"finally",
|
||||||
|
'inputEl.value = selectEl.value || ""',
|
||||||
|
'inputEl.addEventListener("mousedown", () => {\n open();\n });',
|
||||||
):
|
):
|
||||||
assert expected in content
|
assert expected in content
|
||||||
|
|
||||||
@@ -38,6 +44,12 @@ def test_ui_asset_exists_and_has_required_bridge_content():
|
|||||||
assert "quasar" not in content.lower()
|
assert "quasar" not in content.lower()
|
||||||
assert "cdn" not in content.lower()
|
assert "cdn" not in content.lower()
|
||||||
assert not re.search(r"https?://", content)
|
assert not re.search(r"https?://", content)
|
||||||
|
assert "#0b0e14" in content
|
||||||
|
assert "#e54d5e" in content
|
||||||
|
assert "background-size: var(--grid-size) var(--grid-size)" in content
|
||||||
|
assert "background: transparent" in content
|
||||||
|
assert "tl-red" not in content
|
||||||
|
assert 'class="chrome"' not in content
|
||||||
StrictHtmlParser().feed(content)
|
StrictHtmlParser().feed(content)
|
||||||
|
|
||||||
|
|
||||||
@@ -48,3 +60,7 @@ def test_ui_font_sources_are_bundled_locally():
|
|||||||
assert font_urls == ["../fonts/Inter-Regular.ttf", "../fonts/Inter-Bold.ttf"]
|
assert font_urls == ["../fonts/Inter-Regular.ttf", "../fonts/Inter-Bold.ttf"]
|
||||||
for font_url in font_urls:
|
for font_url in font_urls:
|
||||||
assert (package_file("ui") / font_url).resolve().is_file()
|
assert (package_file("ui") / font_url).resolve().is_file()
|
||||||
|
|
||||||
|
|
||||||
|
def test_demo_html_is_not_shipped():
|
||||||
|
assert not Path("desktop/demo.html").exists()
|
||||||
|
|||||||
Reference in New Issue
Block a user