Compare commits
45 Commits
cursor/nic
...
bump-versi
| Author | SHA1 | Date | |
|---|---|---|---|
| 95e0acbe71 | |||
| a39cccb0dc | |||
| 5d827ae70d | |||
|
|
8ee6cebea3 | ||
| a07d3b46dc | |||
|
|
78d1a0a5fc | ||
| 89bb9689e9 | |||
|
|
86d0006291 | ||
| 8443149979 | |||
|
|
3a0e02d9e0 | ||
|
|
19b81201b8 | ||
| f1b99e5da9 | |||
|
|
7cc3a350cd | ||
| 34a68b4e22 | |||
| 61f1a737a4 | |||
| f0a004b637 | |||
| 7e305f18be | |||
| 6b2d13272f | |||
| 8f5d0d24c9 | |||
| 911e6f3612 | |||
| 0fc5eecfb4 | |||
| b389a13add | |||
| 5fb66a2794 | |||
| 9e317e41df | |||
| d5f1a563e2 | |||
| a9f1e90fc1 | |||
|
|
0bca5e551e | ||
| 7f60185536 | |||
|
|
3463fb74df | ||
| c38d9a93be | |||
|
|
0e0a2c5e62 | ||
|
|
b9ea8b2d36 | ||
| cf08d35767 | |||
|
|
ba1231c73d | ||
|
|
63bd3b0f0e | ||
|
|
a70793f61a | ||
|
|
d1e817f4ac | ||
|
|
dc097a2da4 | ||
|
|
aab7afee37 | ||
|
|
d07c4b6ca2 | ||
|
|
d46fe5b6a4 | ||
|
|
5c6451c32a | ||
|
|
71c269b9f0 | ||
|
|
ff9d35f488 | ||
|
|
afec00b50f |
75
.github/workflows/bump-version.yml
vendored
Normal file
75
.github/workflows/bump-version.yml
vendored
Normal file
@@ -0,0 +1,75 @@
|
|||||||
|
# Manually bump package version and open a PR to main.
|
||||||
|
# Actions → Bump version → Run workflow → choose patch / minor / major.
|
||||||
|
name: Bump version
|
||||||
|
|
||||||
|
on:
|
||||||
|
workflow_dispatch:
|
||||||
|
inputs:
|
||||||
|
part:
|
||||||
|
description: Version part to bump
|
||||||
|
required: true
|
||||||
|
type: choice
|
||||||
|
options:
|
||||||
|
- patch
|
||||||
|
- minor
|
||||||
|
- major
|
||||||
|
default: patch
|
||||||
|
|
||||||
|
permissions:
|
||||||
|
contents: write
|
||||||
|
pull-requests: write
|
||||||
|
|
||||||
|
concurrency:
|
||||||
|
group: bump-version
|
||||||
|
cancel-in-progress: false
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
bump:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: Checkout main
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
with:
|
||||||
|
ref: main
|
||||||
|
fetch-depth: 0
|
||||||
|
|
||||||
|
- name: Install uv
|
||||||
|
uses: astral-sh/setup-uv@v5
|
||||||
|
|
||||||
|
- name: Bump version
|
||||||
|
id: bump
|
||||||
|
run: |
|
||||||
|
set -euo pipefail
|
||||||
|
OLD=$(uvx --from bump-my-version bump-my-version show current_version)
|
||||||
|
uvx --from bump-my-version bump-my-version bump "${{ inputs.part }}" --no-commit --no-tag
|
||||||
|
NEW=$(uvx --from bump-my-version bump-my-version show current_version)
|
||||||
|
echo "old=${OLD}" >> "$GITHUB_OUTPUT"
|
||||||
|
echo "new=${NEW}" >> "$GITHUB_OUTPUT"
|
||||||
|
echo "Bumped ${OLD} → ${NEW} (${{ inputs.part }})"
|
||||||
|
|
||||||
|
- name: Create pull request
|
||||||
|
env:
|
||||||
|
GH_TOKEN: ${{ github.token }}
|
||||||
|
run: |
|
||||||
|
set -euo pipefail
|
||||||
|
OLD="${{ steps.bump.outputs.old }}"
|
||||||
|
NEW="${{ steps.bump.outputs.new }}"
|
||||||
|
BRANCH="chore/bump-version-${NEW}"
|
||||||
|
|
||||||
|
git config user.name "github-actions[bot]"
|
||||||
|
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
|
||||||
|
|
||||||
|
git checkout -b "$BRANCH"
|
||||||
|
git add pyproject.toml
|
||||||
|
git commit -m "Bump version: ${OLD} → ${NEW}"
|
||||||
|
git push -u origin "$BRANCH"
|
||||||
|
|
||||||
|
gh pr create \
|
||||||
|
--base main \
|
||||||
|
--head "$BRANCH" \
|
||||||
|
--title "Bump version to ${NEW}" \
|
||||||
|
--body "## Summary
|
||||||
|
|
||||||
|
Automated \`${{ inputs.part }}\` bump: \`${OLD}\` → \`${NEW}\`.
|
||||||
|
|
||||||
|
Source: \`[project].version\` in \`pyproject.toml\` (via bump-my-version)."
|
||||||
42
.github/workflows/mirror-to-gitea.yml
vendored
Normal file
42
.github/workflows/mirror-to-gitea.yml
vendored
Normal file
@@ -0,0 +1,42 @@
|
|||||||
|
# Mirror all branches and tags from GitHub → Gitea after every ref change.
|
||||||
|
# Requires repo secret GITEA_TOKEN (Gitea PAT with write:repository on rhino/xlsx-clean).
|
||||||
|
name: Mirror to Gitea
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
delete:
|
||||||
|
create:
|
||||||
|
workflow_dispatch:
|
||||||
|
|
||||||
|
concurrency:
|
||||||
|
group: mirror-to-gitea
|
||||||
|
cancel-in-progress: true
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
mirror:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
permissions:
|
||||||
|
contents: read
|
||||||
|
steps:
|
||||||
|
- name: Mirror repository to Gitea
|
||||||
|
env:
|
||||||
|
GITEA_TOKEN: ${{ secrets.GITEA_TOKEN }}
|
||||||
|
GH_TOKEN: ${{ github.token }}
|
||||||
|
run: |
|
||||||
|
set -euo pipefail
|
||||||
|
if [ -z "${GITEA_TOKEN:-}" ]; then
|
||||||
|
echo "Missing secret GITEA_TOKEN (Gitea PAT with write:repository)." >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
git clone --mirror \
|
||||||
|
"https://x-access-token:${GH_TOKEN}@github.com/${GITHUB_REPOSITORY}.git" \
|
||||||
|
mirror.git
|
||||||
|
cd mirror.git
|
||||||
|
|
||||||
|
# Push only branches/tags. Never push GitHub refs/pull/* — Gitea
|
||||||
|
# rejects those with "hook declined" and fails the whole mirror.
|
||||||
|
git push --prune \
|
||||||
|
"https://rhino:${GITEA_TOKEN}@git.faryad.top/rhino/xlsx-clean.git" \
|
||||||
|
"+refs/heads/*:refs/heads/*" \
|
||||||
|
"+refs/tags/*:refs/tags/*"
|
||||||
@@ -1 +1 @@
|
|||||||
3.12.2
|
3.12
|
||||||
|
|||||||
43
AGENTS.md
43
AGENTS.md
@@ -4,39 +4,47 @@
|
|||||||
configured directory, clearing/resetting specific cells. Interfaces:
|
configured directory, clearing/resetting specific cells. Interfaces:
|
||||||
|
|
||||||
- CLI: `src/xlsx_clean/clean_cells.py` (`beaupy`)
|
- CLI: `src/xlsx_clean/clean_cells.py` (`beaupy`)
|
||||||
- Web UI: `src/xlsx_clean/web_app.py` (NiceGUI at `http://127.0.0.1:8080`)
|
- GUI: `src/xlsx_clean/gui_app.py` (Dear PyGui cross-platform desktop window)
|
||||||
|
|
||||||
## Backends
|
## Backends
|
||||||
|
|
||||||
- **`com` (Windows default):** Microsoft Excel COM via `pywin32`. Loads add-ins listed
|
- **`com` (Windows default):** Microsoft Excel COM via `pywin32`. Loads add-ins listed
|
||||||
in `strings.txt`, edits cells, `SaveAs`, leaves Excel visible/maximized.
|
in `strings.txt`, edits cells, `SaveAs`, leaves Excel visible/maximized and brought
|
||||||
|
to the front.
|
||||||
- **`ooxml` (Linux/macOS default):** Surgical edit of the `.xlsx` zip (worksheet XML
|
- **`ooxml` (Linux/macOS default):** Surgical edit of the `.xlsx` zip (worksheet XML
|
||||||
only). Preserves non-worksheet parts (styles, connections/Power Query definitions,
|
only). Preserves non-worksheet parts (styles, connections/Power Query definitions,
|
||||||
drawings, etc.). Does not calculate formulas or refresh queries.
|
drawings, etc.). Does not calculate formulas or refresh queries.
|
||||||
|
|
||||||
Select with `--backend com|ooxml` (CLI) or the Backend dropdown (web UI).
|
Select with `--backend com|ooxml` (CLI) or the Backend dropdown (GUI).
|
||||||
|
|
||||||
## Cursor Cloud specific instructions
|
## Cursor Cloud specific instructions
|
||||||
|
|
||||||
### Platform notes
|
### Platform notes
|
||||||
- `pywin32` has no Linux wheels and is declared as Windows-only
|
- `pywin32` has no Linux wheels and is declared as Windows-only
|
||||||
(`pywin32>=306; sys_platform == 'win32'`). It is intentionally **not** installed here.
|
(`pywin32>=312; sys_platform == 'win32'`). It is intentionally **not** installed here.
|
||||||
- End-to-end COM automation needs Windows + desktop Excel and does not run on this VM.
|
- End-to-end COM automation needs Windows + desktop Excel and does not run on this VM.
|
||||||
- On Linux, the **ooxml** backend can clear/set cells and write a new workbook when
|
- On Linux, the **ooxml** backend can clear/set cells and write a new workbook when
|
||||||
sample files and `XLSX_CLEAN_ROOT` point at a real tree. Without those data files,
|
sample files and `XLSX_CLEAN_ROOT` point at a real tree. Without those data files,
|
||||||
interactive selection still works for config loading, but globbing finds no templates.
|
interactive selection still works for config loading, but globbing finds no templates.
|
||||||
- NiceGUI web UI runs on Linux; `show=True` may try to open a browser (harmless if headless).
|
- The Dear PyGui GUI runs cross-platform with no system dependencies beyond Python.
|
||||||
|
On headless VMs without a display server the GUI cannot open a window.
|
||||||
|
|
||||||
### Environment
|
### Environment
|
||||||
- Dependencies are installed into a `uv`-managed virtualenv at `.venv` by the startup
|
- Prefer **uv** for all installs (`uv` in `~/.local/bin`, on PATH via `~/.bashrc`).
|
||||||
update script (`uv` itself is installed via `pip install --break-system-packages uv`
|
- Rye is **not** used (`requirements.lock` removed). Use `uv.lock` + `uv sync`.
|
||||||
and lives in `~/.local/bin`, which is on PATH for interactive shells via `~/.bashrc`).
|
|
||||||
- The install uses pinned versions from `requirements.lock`, excluding the `-e file:.`
|
```bash
|
||||||
editable line and `pywin32`; the package is then installed editable with `--no-deps`.
|
# Linux desktop (deps + Desktop shortcut):
|
||||||
Also install `nicegui` (and its deps) for the web UI:
|
./desktop/setup_linux.sh
|
||||||
`uv pip install 'nicegui>=2.5.0' -p .venv/bin/python`.
|
|
||||||
|
# Deps only (any OS):
|
||||||
|
uv sync
|
||||||
|
```
|
||||||
|
|
||||||
- Run Python via the venv interpreter: `.venv/bin/python`.
|
- Run Python via the venv interpreter: `.venv/bin/python`.
|
||||||
- Optional: `XLSX_CLEAN_ROOT` remaps `D:\OpenCloud\...` paths from `file_data.csv`.
|
- Optional: `XLSX_CLEAN_ROOT` remaps `D:\OpenCloud\...` paths from `file_data.csv`.
|
||||||
|
- Note: the `uv`-created `.venv` does not include `pip`; use `uv pip ...` / `uv sync`
|
||||||
|
for package operations.
|
||||||
|
|
||||||
### Lint / test / build
|
### Lint / test / build
|
||||||
- There is **no lint config, no test suite, and no build step** in this repo (no ruff/flake8,
|
- There is **no lint config, no test suite, and no build step** in this repo (no ruff/flake8,
|
||||||
@@ -45,8 +53,11 @@ Select with `--backend com|ooxml` (CLI) or the Backend dropdown (web UI).
|
|||||||
|
|
||||||
### Running / verifying
|
### Running / verifying
|
||||||
- CLI: `.venv/bin/python -m xlsx_clean.clean_cells` (defaults to `ooxml` on Linux).
|
- CLI: `.venv/bin/python -m xlsx_clean.clean_cells` (defaults to `ooxml` on Linux).
|
||||||
- Web UI: `.venv/bin/python -m xlsx_clean.web_app --port 8080` then open
|
- GUI: `.venv/bin/python -m xlsx_clean.gui_app`.
|
||||||
`http://127.0.0.1:8080`.
|
- Linux setup: `./desktop/setup_linux.sh` (uv sync + shortcut).
|
||||||
|
- Desktop shortcut (Linux): `.venv/bin/python desktop/install_desktop_shortcut.py`
|
||||||
|
- Windows shop-floor: double-click `desktop/Setup.bat` (uv sync + shortcut), or build
|
||||||
|
an exe with `desktop/build_windows_exe.bat` **on a Windows PC** (cannot build Windows
|
||||||
|
exe here).
|
||||||
- Sanity-check imports:
|
- Sanity-check imports:
|
||||||
`.venv/bin/python -c "import pandas, beaupy, nicegui; from xlsx_clean import hello; from xlsx_clean.ooxml_backend import expand_a1_range; print(hello(), expand_a1_range('A1:B2'))"`.
|
`.venv/bin/python -c "import dearpygui, beaupy; from xlsx_clean import hello; from xlsx_clean.core import load_config, list_sets; from xlsx_clean.ooxml_backend import expand_a1_range; print(hello(), expand_a1_range('A1:B2'))"`.
|
||||||
- Note: the `uv`-created `.venv` does not include `pip`; use `uv pip ...` for package operations.
|
|
||||||
|
|||||||
144
README.md
144
README.md
@@ -1,49 +1,137 @@
|
|||||||
# xlsx-clean
|
# xlsx-clean
|
||||||
|
|
||||||
Create a new QC datasheet from the latest matching workbook: clear configured
|
Operator-facing name: **New QC Sheet**.
|
||||||
cells, blank notes, write the batch serial, and save under a new `[SERIAL]` name.
|
|
||||||
|
|
||||||
## Platforms
|
Create a new QC datasheet from the latest matching workbook: clear configured cells,
|
||||||
|
blank notes, write the batch serial, and save under a new `[SERIAL]` name.
|
||||||
|
|
||||||
| Platform | Default backend | Behavior |
|
Everyday use is a **Desktop icon** that opens a **single app window**
|
||||||
|----------|-----------------|----------|
|
(Set -> Ink -> Serial -> Create).
|
||||||
| Windows | `com` | Microsoft Excel via `pywin32`; loads add-ins from `strings.txt`; leaves Excel open |
|
No terminal commands are required for operators.
|
||||||
| Linux / macOS | `ooxml` | Surgical OOXML zip edit; preserves formulas, formatting, queries/connections on disk |
|
|
||||||
|
|
||||||
Force a backend with `--backend com` or `--backend ooxml` (CLI) or the Backend
|
## Quick start (Windows operators)
|
||||||
dropdown in the web UI.
|
|
||||||
|
|
||||||
The OOXML path does **not** refresh Power Query, evaluate formulas, or load `.xlam`/`.xla`
|
1. One-time setup (IT / first install): install [uv](https://docs.astral.sh/uv/getting-started/installation/), clone/copy this project, then double-click
|
||||||
add-ins. Open the written file in Excel for refresh/calc. Prefer `com` on Windows when
|
**`desktop\Setup.bat`**
|
||||||
|
2. Every day: double-click the **New QC Sheet** icon on the Desktop
|
||||||
|
3. In the app window: choose **Set**, **Ink color**, enter **Serial**, click **Create datasheet**
|
||||||
|
|
||||||
|
`Setup.bat` creates `.venv` with uv, installs the package, and adds the Desktop shortcut
|
||||||
|
(using the modern icon in `desktop\xlsx-clean.ico`).
|
||||||
|
The shortcut runs `desktop\XlsxClean.vbs` which launches the GUI window.
|
||||||
|
Closing that window stops the app.
|
||||||
|
|
||||||
|
When you **Create** with the **com** backend, Excel is maximized and brought to the front
|
||||||
|
after the new workbook is saved.
|
||||||
|
|
||||||
|
If something fails, use **`desktop\XlsxClean.bat`** instead - it shows a console with errors.
|
||||||
|
|
||||||
|
## Standalone Windows exe (optional)
|
||||||
|
|
||||||
|
To put a self-contained app on other PCs (build **on Windows**):
|
||||||
|
|
||||||
|
1. Install [uv](https://docs.astral.sh/uv/getting-started/installation/) if needed
|
||||||
|
2. Double-click **`desktop\build_windows_exe.bat`**
|
||||||
|
3. It creates `dist\New QC Sheet\New QC Sheet.exe` and a Desktop shortcut
|
||||||
|
4. Copy the whole **`dist\New QC Sheet\`** folder when moving to another machine (keep files together)
|
||||||
|
|
||||||
|
## What the app does
|
||||||
|
|
||||||
|
| Step | Action |
|
||||||
|
|------|--------|
|
||||||
|
| 1 | Find the latest matching workbook in the product folder |
|
||||||
|
| 2 | Clear configured cells / blank notes |
|
||||||
|
| 3 | Write the batch serial |
|
||||||
|
| 4 | Save as a new file using the `[SERIAL]` name pattern |
|
||||||
|
|
||||||
|
### Excel backends
|
||||||
|
|
||||||
|
| Platform | Default | Notes |
|
||||||
|
|----------|---------|--------|
|
||||||
|
| Windows | `com` | Uses Microsoft Excel + add-ins from `strings.txt`; leaves Excel open |
|
||||||
|
| Linux / macOS | `ooxml` | Surgical `.xlsx` edit; keeps formulas, formatting, and queries on disk |
|
||||||
|
|
||||||
|
Choose the backend in the `config.toml` file, or override with CLI `--backend com|ooxml`.
|
||||||
|
|
||||||
|
**Limits of `ooxml`:** does not refresh Power Query, calculate formulas, or load `.xlam`/`.xla`
|
||||||
|
add-ins. Open the file in Excel afterward for refresh/calc. Prefer **`com` on Windows** when
|
||||||
you need add-ins and a live Excel session.
|
you need add-ins and a live Excel session.
|
||||||
|
|
||||||
## Interfaces
|
## First-time install (admins)
|
||||||
|
|
||||||
### Web UI (NiceGUI)
|
Uses **uv** only (no pip / no rye). Install uv once:
|
||||||
|
https://docs.astral.sh/uv/getting-started/installation/
|
||||||
|
|
||||||
Modern browser form for Set → Ink color → Serial:
|
**Windows (recommended):** double-click **`desktop\Setup.bat`**
|
||||||
|
|
||||||
|
**Linux (recommended):** from the project root:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
xlsx-clean-web
|
chmod +x desktop/setup_linux.sh
|
||||||
# or
|
./desktop/setup_linux.sh
|
||||||
python -m xlsx_clean.web_app
|
|
||||||
```
|
```
|
||||||
|
|
||||||
Opens `http://127.0.0.1:8080` (bind address/port: `--host`, `--port`).
|
That runs `uv sync` and creates a Desktop shortcut.
|
||||||
|
|
||||||
### CLI
|
**Manual / macOS:**
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
xlsx-clean
|
uv sync
|
||||||
# or
|
|
||||||
python -m xlsx_clean.clean_cells --backend ooxml
|
|
||||||
```
|
```
|
||||||
|
|
||||||
On Windows, `src/xlsx_clean/new_xslx.bat` runs the CLI module entry point.
|
That creates `.venv` and installs locked deps from `uv.lock`.
|
||||||
|
|
||||||
## Config
|
Before building the standalone exe:
|
||||||
|
|
||||||
- `src/xlsx_clean/file_data.csv` — product dirs, filename patterns, cells to clear/set
|
```bash
|
||||||
- `src/xlsx_clean/strings.txt` — prompts + Windows add-in paths (COM only)
|
uv sync --extra desktop
|
||||||
- `XLSX_CLEAN_ROOT` — optional root that replaces `D:\OpenCloud` in CSV paths
|
```
|
||||||
(example: `export XLSX_CLEAN_ROOT=/mnt/opencloud`)
|
|
||||||
|
Then create the Desktop shortcut (if you did not use `Setup.bat`):
|
||||||
|
|
||||||
|
- **Windows:** double-click `desktop\Install-DesktopShortcut.bat`
|
||||||
|
- **Linux:** `./desktop/setup_linux.sh` (preferred), or
|
||||||
|
`.venv/bin/python desktop/install_desktop_shortcut.py`
|
||||||
|
|
||||||
|
Optional: Edit `~/.xlsx-clean/config.toml` (created automatically on first run) if workbooks are not under the default `D:\\OpenCloud` paths.
|
||||||
|
|
||||||
|
## Developer interfaces
|
||||||
|
|
||||||
|
These are optional; operators should use the Desktop icon.
|
||||||
|
|
||||||
|
**GUI (desktop window)**
|
||||||
|
|
||||||
|
```bash
|
||||||
|
.venv/bin/python -m xlsx_clean.gui_app
|
||||||
|
# Windows: .venv\Scripts\python.exe -m xlsx_clean.gui_app
|
||||||
|
```
|
||||||
|
|
||||||
|
**CLI**
|
||||||
|
|
||||||
|
```bash
|
||||||
|
.venv/bin/python -m xlsx_clean.clean_cells --backend ooxml
|
||||||
|
```
|
||||||
|
|
||||||
|
Windows CLI helper: `src\xlsx_clean\new_xslx.bat`
|
||||||
|
|
||||||
|
## Config files
|
||||||
|
|
||||||
|
| File | Purpose |
|
||||||
|
|------|---------|
|
||||||
|
| `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/strings.txt` | UI prompts + Windows Excel add-in paths (`com` only) |
|
||||||
|
|
||||||
|
## Project layout (launchers)
|
||||||
|
|
||||||
|
| Path | Purpose |
|
||||||
|
|------|---------|
|
||||||
|
| `desktop/xlsx-clean.ico` | Modern Windows Desktop / exe icon |
|
||||||
|
| `desktop/Setup.bat` | Windows one-time setup via uv + Desktop shortcut |
|
||||||
|
| `desktop/setup_linux.sh` | Linux one-time setup (uv sync + shortcut) |
|
||||||
|
| `desktop/Install-DesktopShortcut.bat` | Create Desktop icon only (Windows) |
|
||||||
|
| `desktop/XlsxClean.vbs` | Silent double-click launcher |
|
||||||
|
| `desktop/XlsxClean.bat` | Launcher with visible console |
|
||||||
|
| `desktop/build_windows_exe.bat` | Build standalone `New QC Sheet.exe` with uv |
|
||||||
|
| `desktop/install_desktop_shortcut.py` | Create Desktop shortcut (Linux) |
|
||||||
|
| `packaging/xlsx_clean.spec` | PyInstaller spec |
|
||||||
|
|||||||
13
desktop/Install-DesktopShortcut.bat
Normal file
13
desktop/Install-DesktopShortcut.bat
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
@echo off
|
||||||
|
REM Create a Desktop shortcut that points at desktop\XlsxClean.vbs
|
||||||
|
setlocal
|
||||||
|
cd /d "%~dp0\.."
|
||||||
|
|
||||||
|
powershell -NoProfile -ExecutionPolicy Bypass -File "%~dp0Install-DesktopShortcut.ps1"
|
||||||
|
if errorlevel 1 (
|
||||||
|
echo Failed to create desktop shortcut.
|
||||||
|
pause
|
||||||
|
exit /b 1
|
||||||
|
)
|
||||||
|
echo Desktop shortcut created: New QC Sheet
|
||||||
|
pause
|
||||||
29
desktop/Install-DesktopShortcut.ps1
Normal file
29
desktop/Install-DesktopShortcut.ps1
Normal file
@@ -0,0 +1,29 @@
|
|||||||
|
# Creates %USERPROFILE%\Desktop\New QC Sheet.lnk -> desktop\XlsxClean.vbs
|
||||||
|
$ErrorActionPreference = "Stop"
|
||||||
|
$repoRoot = Split-Path -Parent $PSScriptRoot
|
||||||
|
$target = Join-Path $PSScriptRoot "XlsxClean.vbs"
|
||||||
|
$desktop = [Environment]::GetFolderPath("Desktop")
|
||||||
|
$shortcutPath = Join-Path $desktop "New QC Sheet.lnk"
|
||||||
|
|
||||||
|
if (-not (Test-Path $target)) {
|
||||||
|
throw "Launcher not found: $target"
|
||||||
|
}
|
||||||
|
|
||||||
|
# Remove older shortcut name if present
|
||||||
|
$legacy = Join-Path $desktop "XlsxClean.lnk"
|
||||||
|
if (Test-Path $legacy) {
|
||||||
|
Remove-Item $legacy -Force
|
||||||
|
}
|
||||||
|
|
||||||
|
$wsh = New-Object -ComObject WScript.Shell
|
||||||
|
$shortcut = $wsh.CreateShortcut($shortcutPath)
|
||||||
|
$shortcut.TargetPath = $target
|
||||||
|
$shortcut.WorkingDirectory = $repoRoot
|
||||||
|
$shortcut.WindowStyle = 7
|
||||||
|
$shortcut.Description = "Open New QC Sheet"
|
||||||
|
$iconCandidate = Join-Path $PSScriptRoot "xlsx-clean.ico"
|
||||||
|
if (Test-Path $iconCandidate) {
|
||||||
|
$shortcut.IconLocation = "$iconCandidate,0"
|
||||||
|
}
|
||||||
|
$shortcut.Save()
|
||||||
|
Write-Host "Created $shortcutPath"
|
||||||
33
desktop/Setup.bat
Normal file
33
desktop/Setup.bat
Normal file
@@ -0,0 +1,33 @@
|
|||||||
|
@echo off
|
||||||
|
REM One-time Windows setup with uv: sync deps from uv.lock, Desktop shortcut.
|
||||||
|
setlocal
|
||||||
|
cd /d "%~dp0\.."
|
||||||
|
|
||||||
|
where uv >nul 2>&1
|
||||||
|
if errorlevel 1 (
|
||||||
|
echo uv was not found on PATH.
|
||||||
|
echo Install uv from https://docs.astral.sh/uv/getting-started/installation/
|
||||||
|
echo then re-run this script.
|
||||||
|
pause
|
||||||
|
exit /b 1
|
||||||
|
)
|
||||||
|
|
||||||
|
echo Syncing project with uv (creates .venv if needed)...
|
||||||
|
uv sync
|
||||||
|
if errorlevel 1 (
|
||||||
|
echo uv sync failed.
|
||||||
|
pause
|
||||||
|
exit /b 1
|
||||||
|
)
|
||||||
|
|
||||||
|
echo Creating Desktop shortcut...
|
||||||
|
powershell -NoProfile -ExecutionPolicy Bypass -File "%~dp0Install-DesktopShortcut.ps1"
|
||||||
|
if errorlevel 1 (
|
||||||
|
echo Desktop shortcut step failed.
|
||||||
|
pause
|
||||||
|
exit /b 1
|
||||||
|
)
|
||||||
|
|
||||||
|
echo.
|
||||||
|
echo Setup complete. Double-click the New QC Sheet icon on your Desktop.
|
||||||
|
pause
|
||||||
10
desktop/XlsxClean.bat
Normal file
10
desktop/XlsxClean.bat
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
@echo off
|
||||||
|
REM Double-click launcher with visible console (useful for troubleshooting).
|
||||||
|
setlocal
|
||||||
|
cd /d "%~dp0\.."
|
||||||
|
|
||||||
|
if exist ".venv\Scripts\python.exe" (
|
||||||
|
".venv\Scripts\python.exe" -m xlsx_clean.gui_app %*
|
||||||
|
) else (
|
||||||
|
py -3 -m xlsx_clean.gui_app %*
|
||||||
|
)
|
||||||
28
desktop/XlsxClean.vbs
Normal file
28
desktop/XlsxClean.vbs
Normal file
@@ -0,0 +1,28 @@
|
|||||||
|
' XlsxClean.vbs - double-click launcher (no console window)
|
||||||
|
' Resolves repo root from this script's folder (desktop\ -> repo root).
|
||||||
|
Option Explicit
|
||||||
|
|
||||||
|
Dim fso, sh, scriptDir, root, pythonExe, cmd
|
||||||
|
Set fso = CreateObject("Scripting.FileSystemObject")
|
||||||
|
Set sh = CreateObject("WScript.Shell")
|
||||||
|
|
||||||
|
scriptDir = fso.GetParentFolderName(WScript.ScriptFullName)
|
||||||
|
root = fso.GetParentFolderName(scriptDir)
|
||||||
|
|
||||||
|
' Prefer project venv, then py launcher, then python on PATH.
|
||||||
|
pythonExe = root & "\.venv\Scripts\pythonw.exe"
|
||||||
|
If Not fso.FileExists(pythonExe) Then
|
||||||
|
pythonExe = root & "\.venv\Scripts\python.exe"
|
||||||
|
End If
|
||||||
|
If Not fso.FileExists(pythonExe) Then
|
||||||
|
pythonExe = "py"
|
||||||
|
End If
|
||||||
|
|
||||||
|
sh.CurrentDirectory = root
|
||||||
|
' Window style 0 = hidden.
|
||||||
|
cmd = """" & pythonExe & """ -m xlsx_clean.gui_app"
|
||||||
|
If pythonExe = "py" Then
|
||||||
|
cmd = "py -3 -m xlsx_clean.gui_app"
|
||||||
|
End If
|
||||||
|
|
||||||
|
sh.Run cmd, 0, False
|
||||||
56
desktop/build_windows_exe.bat
Normal file
56
desktop/build_windows_exe.bat
Normal file
@@ -0,0 +1,56 @@
|
|||||||
|
@echo off
|
||||||
|
REM Build dist\New QC Sheet\New QC Sheet.exe on Windows with uv, then Desktop shortcut.
|
||||||
|
setlocal
|
||||||
|
cd /d "%~dp0\.."
|
||||||
|
|
||||||
|
where uv >nul 2>&1
|
||||||
|
if errorlevel 1 (
|
||||||
|
echo uv was not found on PATH.
|
||||||
|
echo Install uv from https://docs.astral.sh/uv/getting-started/installation/
|
||||||
|
pause
|
||||||
|
exit /b 1
|
||||||
|
)
|
||||||
|
|
||||||
|
echo Syncing project + desktop extras with uv...
|
||||||
|
uv sync --extra desktop
|
||||||
|
if errorlevel 1 (
|
||||||
|
echo uv sync failed.
|
||||||
|
pause
|
||||||
|
exit /b 1
|
||||||
|
)
|
||||||
|
|
||||||
|
echo Building executable with PyInstaller...
|
||||||
|
uv run pyinstaller --noconfirm packaging\xlsx_clean.spec
|
||||||
|
if errorlevel 1 (
|
||||||
|
echo PyInstaller build failed.
|
||||||
|
pause
|
||||||
|
exit /b 1
|
||||||
|
)
|
||||||
|
|
||||||
|
set EXE=%CD%\dist\New QC Sheet\New QC Sheet.exe
|
||||||
|
if not exist "%EXE%" (
|
||||||
|
echo Expected exe not found: %EXE%
|
||||||
|
pause
|
||||||
|
exit /b 1
|
||||||
|
)
|
||||||
|
|
||||||
|
echo Creating Desktop shortcut to the exe...
|
||||||
|
powershell -NoProfile -ExecutionPolicy Bypass -Command ^
|
||||||
|
"$desk=[Environment]::GetFolderPath('Desktop');" ^
|
||||||
|
"$lnk=Join-Path $desk 'New QC Sheet.lnk';" ^
|
||||||
|
"$legacy=Join-Path $desk 'XlsxClean.lnk';" ^
|
||||||
|
"if (Test-Path $legacy) { Remove-Item $legacy -Force };" ^
|
||||||
|
"$ico=Join-Path '%CD%' 'desktop\xlsx-clean.ico';" ^
|
||||||
|
"$w=New-Object -ComObject WScript.Shell;" ^
|
||||||
|
"$s=$w.CreateShortcut($lnk);" ^
|
||||||
|
"$s.TargetPath='%EXE%';" ^
|
||||||
|
"$s.WorkingDirectory='%~dp0..\dist\New QC Sheet';" ^
|
||||||
|
"$s.Description='Open New QC Sheet';" ^
|
||||||
|
"if (Test-Path $ico) { $s.IconLocation = $ico };" ^
|
||||||
|
"$s.Save();" ^
|
||||||
|
"Write-Host Created $lnk"
|
||||||
|
|
||||||
|
echo.
|
||||||
|
echo Done. Double-click the New QC Sheet icon on your Desktop.
|
||||||
|
echo Exe folder: dist\New QC Sheet\
|
||||||
|
pause
|
||||||
80
desktop/install_desktop_shortcut.py
Normal file
80
desktop/install_desktop_shortcut.py
Normal file
@@ -0,0 +1,80 @@
|
|||||||
|
"""Install a Desktop shortcut that launches New QC Sheet."""
|
||||||
|
|
||||||
|
from __future__ import annotations
|
||||||
|
|
||||||
|
import os
|
||||||
|
import subprocess
|
||||||
|
import sys
|
||||||
|
from pathlib import Path
|
||||||
|
|
||||||
|
REPO_ROOT = Path(__file__).resolve().parents[1]
|
||||||
|
DESKTOP_DIR = Path(__file__).resolve().parent
|
||||||
|
APP_DISPLAY_NAME = "New QC Sheet"
|
||||||
|
|
||||||
|
|
||||||
|
def _user_desktop() -> Path:
|
||||||
|
if sys.platform == "win32":
|
||||||
|
return Path(os.environ.get("USERPROFILE", str(Path.home()))) / "Desktop"
|
||||||
|
# Linux / macOS
|
||||||
|
xdg = os.environ.get("XDG_DESKTOP_DIR")
|
||||||
|
if xdg:
|
||||||
|
return Path(xdg)
|
||||||
|
return Path.home() / "Desktop"
|
||||||
|
|
||||||
|
|
||||||
|
def install_windows() -> Path:
|
||||||
|
ps1 = DESKTOP_DIR / "Install-DesktopShortcut.ps1"
|
||||||
|
subprocess.run(
|
||||||
|
[
|
||||||
|
"powershell",
|
||||||
|
"-NoProfile",
|
||||||
|
"-ExecutionPolicy",
|
||||||
|
"Bypass",
|
||||||
|
"-File",
|
||||||
|
str(ps1),
|
||||||
|
],
|
||||||
|
check=True,
|
||||||
|
)
|
||||||
|
return _user_desktop() / f"{APP_DISPLAY_NAME}.lnk"
|
||||||
|
|
||||||
|
|
||||||
|
def install_linux() -> Path:
|
||||||
|
desktop = _user_desktop()
|
||||||
|
desktop.mkdir(parents=True, exist_ok=True)
|
||||||
|
python = REPO_ROOT / ".venv" / "bin" / "python"
|
||||||
|
if not python.is_file():
|
||||||
|
python = Path(sys.executable)
|
||||||
|
out = desktop / f"{APP_DISPLAY_NAME}.desktop"
|
||||||
|
legacy = desktop / "XlsxClean.desktop"
|
||||||
|
if legacy.is_file():
|
||||||
|
legacy.unlink()
|
||||||
|
exec_line = f"{python} -m xlsx_clean.gui_app"
|
||||||
|
icon_png = DESKTOP_DIR / "xlsx-clean.png"
|
||||||
|
icon_line = str(icon_png) if icon_png.is_file() else "applications-office"
|
||||||
|
content = f"""[Desktop Entry]
|
||||||
|
Type=Application
|
||||||
|
Version=1.0
|
||||||
|
Name={APP_DISPLAY_NAME}
|
||||||
|
Comment=Create a new QC datasheet
|
||||||
|
Exec={exec_line}
|
||||||
|
Path={REPO_ROOT}
|
||||||
|
Icon={icon_line}
|
||||||
|
Terminal=false
|
||||||
|
Categories=Office;
|
||||||
|
StartupNotify=true
|
||||||
|
"""
|
||||||
|
out.write_text(content, encoding="utf-8")
|
||||||
|
out.chmod(out.stat().st_mode | 0o111)
|
||||||
|
return out
|
||||||
|
|
||||||
|
|
||||||
|
def main() -> None:
|
||||||
|
if sys.platform == "win32":
|
||||||
|
path = install_windows()
|
||||||
|
else:
|
||||||
|
path = install_linux()
|
||||||
|
print(f"Desktop shortcut created: {path}")
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
main()
|
||||||
23
desktop/setup_linux.sh
Executable file
23
desktop/setup_linux.sh
Executable file
@@ -0,0 +1,23 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
# Operator setup for New QC Sheet on Linux desktops.
|
||||||
|
# Installs deps with uv and creates a Desktop shortcut.
|
||||||
|
set -euo pipefail
|
||||||
|
|
||||||
|
ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
|
||||||
|
cd "$ROOT"
|
||||||
|
|
||||||
|
if ! command -v uv >/dev/null 2>&1; then
|
||||||
|
echo "uv not found on PATH. Install uv first: https://docs.astral.sh/uv/" >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "Syncing dependencies..."
|
||||||
|
uv sync
|
||||||
|
|
||||||
|
echo "Installing Desktop shortcut..."
|
||||||
|
.venv/bin/python desktop/install_desktop_shortcut.py
|
||||||
|
|
||||||
|
echo
|
||||||
|
echo "Done. Launch with:"
|
||||||
|
echo " .venv/bin/python -m xlsx_clean.gui_app"
|
||||||
|
echo "or use the Desktop shortcut."
|
||||||
12
desktop/xlsx-clean.desktop
Normal file
12
desktop/xlsx-clean.desktop
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
[Desktop Entry]
|
||||||
|
Type=Application
|
||||||
|
Version=1.0
|
||||||
|
Name=New QC Sheet
|
||||||
|
Comment=Create a new QC datasheet
|
||||||
|
# Exec is filled by install_desktop_shortcut.py; placeholder for manual edits:
|
||||||
|
Exec=bash -lc 'cd "$(dirname "%k")/.." && .venv/bin/python -m xlsx_clean.gui_app'
|
||||||
|
Path=
|
||||||
|
Icon=applications-office
|
||||||
|
Terminal=false
|
||||||
|
Categories=Office;
|
||||||
|
StartupNotify=true
|
||||||
BIN
desktop/xlsx-clean.ico
Normal file
BIN
desktop/xlsx-clean.ico
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 4.3 KiB |
BIN
desktop/xlsx-clean.png
Normal file
BIN
desktop/xlsx-clean.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 1.8 KiB |
82
packaging/xlsx_clean.spec
Normal file
82
packaging/xlsx_clean.spec
Normal file
@@ -0,0 +1,82 @@
|
|||||||
|
# -*- mode: python ; coding: utf-8 -*-
|
||||||
|
"""PyInstaller spec for a double-clickable New QC Sheet executable.
|
||||||
|
|
||||||
|
Build on Windows (recommended for shop-floor PCs):
|
||||||
|
desktop\\build_windows_exe.bat
|
||||||
|
|
||||||
|
Or manually:
|
||||||
|
pyinstaller packaging/xlsx_clean.spec
|
||||||
|
"""
|
||||||
|
|
||||||
|
from PyInstaller.utils.hooks import collect_all
|
||||||
|
|
||||||
|
block_cipher = None
|
||||||
|
|
||||||
|
datas = [
|
||||||
|
("src/xlsx_clean/file_data.csv", "xlsx_clean"),
|
||||||
|
("src/xlsx_clean/strings.txt", "xlsx_clean"),
|
||||||
|
("src/xlsx_clean/fonts", "xlsx_clean/fonts"),
|
||||||
|
]
|
||||||
|
binaries = []
|
||||||
|
hiddenimports = [
|
||||||
|
"xlsx_clean",
|
||||||
|
"xlsx_clean.core",
|
||||||
|
"xlsx_clean.gui_app",
|
||||||
|
"xlsx_clean.clean_cells",
|
||||||
|
"xlsx_clean.ooxml_backend",
|
||||||
|
"xlsx_clean.com_backend",
|
||||||
|
"xlsx_clean.paths",
|
||||||
|
]
|
||||||
|
|
||||||
|
tmp_ret = collect_all("dearpygui")
|
||||||
|
datas += tmp_ret[0]
|
||||||
|
binaries += tmp_ret[1]
|
||||||
|
hiddenimports += tmp_ret[2]
|
||||||
|
|
||||||
|
a = Analysis(
|
||||||
|
["src/xlsx_clean/gui_app.py"],
|
||||||
|
pathex=["."],
|
||||||
|
binaries=binaries,
|
||||||
|
datas=datas,
|
||||||
|
hiddenimports=hiddenimports,
|
||||||
|
hookspath=[],
|
||||||
|
hooksconfig={},
|
||||||
|
runtime_hooks=[],
|
||||||
|
excludes=[],
|
||||||
|
win_no_prefer_redirects=False,
|
||||||
|
win_private_assemblies=False,
|
||||||
|
cipher=block_cipher,
|
||||||
|
noarchive=False,
|
||||||
|
)
|
||||||
|
|
||||||
|
pyz = PYZ(a.pure, a.zipped_data, cipher=block_cipher)
|
||||||
|
|
||||||
|
exe = EXE(
|
||||||
|
pyz,
|
||||||
|
a.scripts,
|
||||||
|
[],
|
||||||
|
exclude_binaries=True,
|
||||||
|
name="New QC Sheet",
|
||||||
|
debug=False,
|
||||||
|
bootloader_ignore_signals=False,
|
||||||
|
strip=False,
|
||||||
|
upx=True,
|
||||||
|
console=False,
|
||||||
|
disable_windowed_traceback=False,
|
||||||
|
argv_emulation=False,
|
||||||
|
target_arch=None,
|
||||||
|
codesign_identity=None,
|
||||||
|
entitlements_file=None,
|
||||||
|
icon="desktop/xlsx-clean.ico",
|
||||||
|
)
|
||||||
|
|
||||||
|
coll = COLLECT(
|
||||||
|
exe,
|
||||||
|
a.binaries,
|
||||||
|
a.zipfiles,
|
||||||
|
a.datas,
|
||||||
|
strip=False,
|
||||||
|
upx=True,
|
||||||
|
upx_exclude=[],
|
||||||
|
name="New QC Sheet",
|
||||||
|
)
|
||||||
@@ -1,33 +1,58 @@
|
|||||||
[project]
|
[project]
|
||||||
name = "xlsx-clean"
|
name = "xlsx-clean"
|
||||||
version = "0.1.0"
|
version = "1.0.0"
|
||||||
description = "Add your description here"
|
description = "Create a new QC datasheet from the latest matching workbook"
|
||||||
authors = [
|
authors = [
|
||||||
{ name = "Diaco Soltanpour", email = "dyaco8464@yahoo.com" }
|
{ name = "Diaco Soltanpour", email = "dyaco8464@yahoo.com" }
|
||||||
]
|
]
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"beaupy>=3.8.2",
|
"beaupy>=3.12.0",
|
||||||
"nicegui>=2.5.0",
|
"dearpygui>=2.0.0",
|
||||||
"pandas>=2.2.2",
|
"pywin32>=312; sys_platform == 'win32'",
|
||||||
"pywin32>=306; sys_platform == 'win32'",
|
|
||||||
]
|
]
|
||||||
readme = "README.md"
|
readme = "README.md"
|
||||||
requires-python = ">=3.12"
|
requires-python = ">=3.12"
|
||||||
|
|
||||||
[project.scripts]
|
[project.scripts]
|
||||||
xlsx-clean = "xlsx_clean.clean_cells:main"
|
xlsx-clean = "xlsx_clean.clean_cells:main"
|
||||||
xlsx-clean-web = "xlsx_clean.web_app:main"
|
xlsx-clean-gui = "xlsx_clean.gui_app:main"
|
||||||
|
|
||||||
|
[project.optional-dependencies]
|
||||||
|
desktop = [
|
||||||
|
"pyinstaller>=6.21.0",
|
||||||
|
]
|
||||||
|
|
||||||
[build-system]
|
[build-system]
|
||||||
requires = ["hatchling"]
|
requires = ["hatchling"]
|
||||||
build-backend = "hatchling.build"
|
build-backend = "hatchling.build"
|
||||||
|
|
||||||
[tool.rye]
|
|
||||||
managed = true
|
|
||||||
dev-dependencies = []
|
|
||||||
|
|
||||||
[tool.hatch.metadata]
|
[tool.hatch.metadata]
|
||||||
allow-direct-references = true
|
allow-direct-references = true
|
||||||
|
|
||||||
[tool.hatch.build.targets.wheel]
|
[tool.hatch.build.targets.wheel]
|
||||||
packages = ["src/xlsx_clean"]
|
packages = ["src/xlsx_clean"]
|
||||||
|
|
||||||
|
[tool.hatch.build.targets.wheel.force-include]
|
||||||
|
"src/xlsx_clean/file_data.csv" = "xlsx_clean/file_data.csv"
|
||||||
|
"src/xlsx_clean/strings.txt" = "xlsx_clean/strings.txt"
|
||||||
|
"src/xlsx_clean/new_xslx.bat" = "xlsx_clean/new_xslx.bat"
|
||||||
|
"src/xlsx_clean/fonts" = "xlsx_clean/fonts"
|
||||||
|
|
||||||
|
[tool.uv]
|
||||||
|
package = true
|
||||||
|
|
||||||
|
# Version bumps: `uvx bump-my-version bump patch|minor|major`
|
||||||
|
# current_version falls back to [project].version above.
|
||||||
|
[tool.bumpversion]
|
||||||
|
commit = false
|
||||||
|
tag = false
|
||||||
|
parse = "(?P<major>\\d+)\\.(?P<minor>\\d+)\\.(?P<patch>\\d+)"
|
||||||
|
serialize = ["{major}.{minor}.{patch}"]
|
||||||
|
message = "Bump version: {current_version} → {new_version}"
|
||||||
|
tag_name = "v{new_version}"
|
||||||
|
tag_message = "Bump version: {current_version} → {new_version}"
|
||||||
|
|
||||||
|
[[tool.bumpversion.files]]
|
||||||
|
filename = "pyproject.toml"
|
||||||
|
search = 'version = "{current_version}"'
|
||||||
|
replace = 'version = "{new_version}"'
|
||||||
|
|||||||
@@ -1,44 +0,0 @@
|
|||||||
# generated by rye
|
|
||||||
# use `rye lock` or `rye sync` to update this lockfile
|
|
||||||
#
|
|
||||||
# last locked with the following flags:
|
|
||||||
# pre: false
|
|
||||||
# features: []
|
|
||||||
# all-features: false
|
|
||||||
# with-sources: false
|
|
||||||
|
|
||||||
-e file:.
|
|
||||||
beaupy==3.8.2
|
|
||||||
# via xlsx-clean
|
|
||||||
emoji==2.11.0
|
|
||||||
# via beaupy
|
|
||||||
markdown-it-py==3.0.0
|
|
||||||
# via rich
|
|
||||||
mdurl==0.1.2
|
|
||||||
# via markdown-it-py
|
|
||||||
numpy==1.26.4
|
|
||||||
# via pandas
|
|
||||||
pandas==2.2.2
|
|
||||||
# via xlsx-clean
|
|
||||||
nicegui==3.14.0
|
|
||||||
# via xlsx-clean
|
|
||||||
pygments==2.17.2
|
|
||||||
# via rich
|
|
||||||
python-dateutil==2.9.0.post0
|
|
||||||
# via pandas
|
|
||||||
python-yakh==0.3.2
|
|
||||||
# via beaupy
|
|
||||||
# via questo
|
|
||||||
pytz==2024.1
|
|
||||||
# via pandas
|
|
||||||
pywin32==306
|
|
||||||
# via xlsx-clean; Windows-only (sys_platform == 'win32')
|
|
||||||
questo==0.2.3
|
|
||||||
# via beaupy
|
|
||||||
rich==13.7.1
|
|
||||||
# via beaupy
|
|
||||||
# via questo
|
|
||||||
six==1.16.0
|
|
||||||
# via python-dateutil
|
|
||||||
tzdata==2024.1
|
|
||||||
# via pandas
|
|
||||||
@@ -1,44 +0,0 @@
|
|||||||
# generated by rye
|
|
||||||
# use `rye lock` or `rye sync` to update this lockfile
|
|
||||||
#
|
|
||||||
# last locked with the following flags:
|
|
||||||
# pre: false
|
|
||||||
# features: []
|
|
||||||
# all-features: false
|
|
||||||
# with-sources: false
|
|
||||||
|
|
||||||
-e file:.
|
|
||||||
beaupy==3.8.2
|
|
||||||
# via xlsx-clean
|
|
||||||
emoji==2.11.0
|
|
||||||
# via beaupy
|
|
||||||
markdown-it-py==3.0.0
|
|
||||||
# via rich
|
|
||||||
mdurl==0.1.2
|
|
||||||
# via markdown-it-py
|
|
||||||
numpy==1.26.4
|
|
||||||
# via pandas
|
|
||||||
pandas==2.2.2
|
|
||||||
# via xlsx-clean
|
|
||||||
nicegui==3.14.0
|
|
||||||
# via xlsx-clean
|
|
||||||
pygments==2.17.2
|
|
||||||
# via rich
|
|
||||||
python-dateutil==2.9.0.post0
|
|
||||||
# via pandas
|
|
||||||
python-yakh==0.3.2
|
|
||||||
# via beaupy
|
|
||||||
# via questo
|
|
||||||
pytz==2024.1
|
|
||||||
# via pandas
|
|
||||||
pywin32==306
|
|
||||||
# via xlsx-clean; Windows-only (sys_platform == 'win32')
|
|
||||||
questo==0.2.3
|
|
||||||
# via beaupy
|
|
||||||
rich==13.7.1
|
|
||||||
# via beaupy
|
|
||||||
# via questo
|
|
||||||
six==1.16.0
|
|
||||||
# via python-dateutil
|
|
||||||
tzdata==2024.1
|
|
||||||
# via pandas
|
|
||||||
50
src/xlsx_clean/app_logging.py
Normal file
50
src/xlsx_clean/app_logging.py
Normal file
@@ -0,0 +1,50 @@
|
|||||||
|
"""Append-only file logging for QC datasheet creation."""
|
||||||
|
|
||||||
|
from __future__ import annotations
|
||||||
|
|
||||||
|
import logging
|
||||||
|
import os
|
||||||
|
import sys
|
||||||
|
from pathlib import Path
|
||||||
|
|
||||||
|
_LOGGER_NAME = "xlsx_clean.create"
|
||||||
|
_configured = False
|
||||||
|
|
||||||
|
|
||||||
|
def default_log_path() -> Path:
|
||||||
|
"""Resolve the log file path.
|
||||||
|
|
||||||
|
Order:
|
||||||
|
1. ``XLSX_CLEAN_LOG`` env var (file path)
|
||||||
|
2. Next to the frozen executable (PyInstaller)
|
||||||
|
3. ``~/.xlsx-clean/xlsx-clean.log``
|
||||||
|
"""
|
||||||
|
env = os.environ.get("XLSX_CLEAN_LOG")
|
||||||
|
if env:
|
||||||
|
return Path(env)
|
||||||
|
|
||||||
|
if getattr(sys, "frozen", False):
|
||||||
|
return Path(sys.executable).resolve().parent / "xlsx-clean.log"
|
||||||
|
|
||||||
|
return Path.home() / ".xlsx-clean" / "xlsx-clean.log"
|
||||||
|
|
||||||
|
|
||||||
|
def get_logger() -> logging.Logger:
|
||||||
|
"""Return a logger that appends timestamped lines to the log file."""
|
||||||
|
global _configured
|
||||||
|
logger = logging.getLogger(_LOGGER_NAME)
|
||||||
|
if not _configured:
|
||||||
|
log_path = default_log_path()
|
||||||
|
log_path.parent.mkdir(parents=True, exist_ok=True)
|
||||||
|
handler = logging.FileHandler(log_path, encoding="utf-8")
|
||||||
|
handler.setFormatter(
|
||||||
|
logging.Formatter(
|
||||||
|
fmt="%(asctime)s %(levelname)s %(message)s",
|
||||||
|
datefmt="%Y-%m-%d %H:%M:%S",
|
||||||
|
)
|
||||||
|
)
|
||||||
|
logger.addHandler(handler)
|
||||||
|
logger.setLevel(logging.INFO)
|
||||||
|
logger.propagate = False
|
||||||
|
_configured = True
|
||||||
|
return logger
|
||||||
@@ -1,200 +1,19 @@
|
|||||||
"""Interactive CLI: copy latest QC workbook, clear cells, stamp serial."""
|
"""Interactive CLI: select set/ink/serial, create a cleaned QC workbook."""
|
||||||
|
|
||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
import argparse
|
import argparse
|
||||||
import shutil
|
|
||||||
import tempfile
|
|
||||||
from dataclasses import dataclass
|
|
||||||
from datetime import datetime
|
|
||||||
from pathlib import Path
|
|
||||||
|
|
||||||
import pandas
|
|
||||||
from beaupy import prompt, select
|
from beaupy import prompt, select
|
||||||
from rich.console import Console
|
from rich.console import Console
|
||||||
|
|
||||||
from xlsx_clean.paths import (
|
from xlsx_clean.core import (
|
||||||
default_backend,
|
create_datasheet,
|
||||||
get_opencloud_root,
|
list_ink_colors,
|
||||||
package_file,
|
list_sets,
|
||||||
remap_opencloud_path,
|
load_config,
|
||||||
resolve_backend,
|
|
||||||
)
|
|
||||||
|
|
||||||
NEW_VALUE = ""
|
|
||||||
|
|
||||||
|
|
||||||
@dataclass(frozen=True)
|
|
||||||
class CreateResult:
|
|
||||||
ok: bool
|
|
||||||
message: str
|
|
||||||
template: Path | None = None
|
|
||||||
destination: Path | None = None
|
|
||||||
backend: str | None = None
|
|
||||||
skipped: bool = False
|
|
||||||
|
|
||||||
|
|
||||||
def find_last_workbook(files: list[str]) -> str:
|
|
||||||
return sorted(files)[-1]
|
|
||||||
|
|
||||||
|
|
||||||
def get_workbook_names(
|
|
||||||
files: list[str],
|
|
||||||
batch_serial: str,
|
|
||||||
source_dir: Path,
|
|
||||||
pattern: str,
|
|
||||||
) -> tuple[str, Path]:
|
|
||||||
last_workbook = find_last_workbook(files)
|
|
||||||
path_of_the_year = Path(str(source_dir).replace("2025", str(datetime.now().year)))
|
|
||||||
return last_workbook, path_of_the_year / pattern.replace(
|
|
||||||
"[SERIAL]", batch_serial.split("/")[0]
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
def load_config() -> tuple[list[str], pandas.DataFrame]:
|
|
||||||
strings_path = package_file("strings.txt")
|
|
||||||
with open(strings_path, encoding="utf-8") as f:
|
|
||||||
content = [line.strip() for line in f.readlines()]
|
|
||||||
|
|
||||||
path_df = pandas.read_csv(package_file("file_data.csv"))
|
|
||||||
root = get_opencloud_root()
|
|
||||||
path_df["dir"] = [
|
|
||||||
str(remap_opencloud_path(path, root)) for path in path_df["dir"]
|
|
||||||
]
|
|
||||||
return content, path_df
|
|
||||||
|
|
||||||
|
|
||||||
def list_sets(path_df: pandas.DataFrame) -> list[str]:
|
|
||||||
return list(
|
|
||||||
path_df.drop_duplicates(subset=["set_name"], keep="first")["set_name"]
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
def list_ink_colors(path_df: pandas.DataFrame, selected_set: str) -> list[str]:
|
|
||||||
return [
|
|
||||||
Path(path).stem
|
|
||||||
for path in list(path_df[path_df["set_name"] == selected_set]["dir"])
|
|
||||||
]
|
|
||||||
|
|
||||||
|
|
||||||
def create_datasheet(
|
|
||||||
selected_set: str,
|
|
||||||
selected_dir: str,
|
|
||||||
batch_serial: str,
|
|
||||||
backend: str | None = None,
|
|
||||||
path_df: pandas.DataFrame | None = None,
|
|
||||||
addin_paths: list[str] | None = None,
|
|
||||||
) -> CreateResult:
|
|
||||||
"""Create a cleaned QC workbook for the given selection.
|
|
||||||
|
|
||||||
Shared by the CLI and the NiceGUI web UI.
|
|
||||||
"""
|
|
||||||
if not selected_set:
|
|
||||||
return CreateResult(ok=False, message="Select a set.")
|
|
||||||
if not selected_dir:
|
|
||||||
return CreateResult(ok=False, message="Select an ink color.")
|
|
||||||
if not batch_serial or not str(batch_serial).strip():
|
|
||||||
return CreateResult(ok=False, message="Enter a serial.")
|
|
||||||
|
|
||||||
batch_serial = str(batch_serial).strip()
|
|
||||||
try:
|
|
||||||
resolved_backend = resolve_backend(backend)
|
|
||||||
except (ValueError, RuntimeError) as exc:
|
|
||||||
return CreateResult(ok=False, message=str(exc))
|
|
||||||
|
|
||||||
if path_df is None or addin_paths is None:
|
|
||||||
content, loaded_df = load_config()
|
|
||||||
if path_df is None:
|
|
||||||
path_df = loaded_df
|
|
||||||
if addin_paths is None:
|
|
||||||
addin_paths = content[3:5] if len(content) >= 5 else []
|
|
||||||
|
|
||||||
matches = path_df[
|
|
||||||
(path_df["set_name"] == selected_set)
|
|
||||||
& (path_df["dir"].str.endswith(selected_dir))
|
|
||||||
]
|
|
||||||
if matches.empty:
|
|
||||||
return CreateResult(
|
|
||||||
ok=False,
|
|
||||||
message=f"No config row for set={selected_set!r} ink={selected_dir!r}.",
|
|
||||||
)
|
|
||||||
|
|
||||||
row = matches.iloc[0]
|
|
||||||
path_ = Path(row["dir"])
|
|
||||||
pattern = row["pattern"]
|
|
||||||
search_pattern = pattern.replace("[SERIAL]", "*")
|
|
||||||
files = [str(x) for x in path_.glob(search_pattern) if x.is_file()]
|
|
||||||
if not files:
|
|
||||||
return CreateResult(
|
|
||||||
ok=False,
|
|
||||||
message=f"No workbooks matching {search_pattern!r} in {path_}",
|
|
||||||
backend=resolved_backend,
|
|
||||||
)
|
|
||||||
|
|
||||||
ref_workbook_name, new_workbook_name = get_workbook_names(
|
|
||||||
files, batch_serial, path_, pattern
|
|
||||||
)
|
|
||||||
template = Path(ref_workbook_name)
|
|
||||||
|
|
||||||
if new_workbook_name.is_file():
|
|
||||||
return CreateResult(
|
|
||||||
ok=True,
|
|
||||||
skipped=True,
|
|
||||||
message=f"Destination already exists, skipped: {new_workbook_name}",
|
|
||||||
template=template,
|
|
||||||
destination=new_workbook_name,
|
|
||||||
backend=resolved_backend,
|
|
||||||
)
|
|
||||||
|
|
||||||
cells_to_clear = row["cells_to_clear"]
|
|
||||||
notes_cell = row["notes_cell"]
|
|
||||||
serial_cell = row["serial_cell"]
|
|
||||||
|
|
||||||
try:
|
|
||||||
if resolved_backend == "com":
|
|
||||||
from xlsx_clean.com_backend import clean_workbook_com
|
|
||||||
|
|
||||||
with tempfile.TemporaryDirectory(prefix="xlsx_clean_") as tmp:
|
|
||||||
temp_workbook = Path(tmp) / "temp_workbook.xlsx"
|
|
||||||
shutil.copyfile(ref_workbook_name, temp_workbook)
|
|
||||||
clean_workbook_com(
|
|
||||||
source=temp_workbook,
|
|
||||||
destination=new_workbook_name,
|
|
||||||
cells_to_clear=cells_to_clear,
|
|
||||||
notes_cell=notes_cell,
|
|
||||||
serial_cell=serial_cell,
|
|
||||||
batch_serial=batch_serial,
|
|
||||||
addin_paths=addin_paths or [],
|
|
||||||
notes_value=NEW_VALUE,
|
|
||||||
)
|
|
||||||
else:
|
|
||||||
from xlsx_clean.ooxml_backend import clean_workbook_ooxml
|
|
||||||
|
|
||||||
clean_workbook_ooxml(
|
|
||||||
source=ref_workbook_name,
|
|
||||||
destination=new_workbook_name,
|
|
||||||
cells_to_clear=cells_to_clear,
|
|
||||||
notes_cell=notes_cell,
|
|
||||||
serial_cell=serial_cell,
|
|
||||||
batch_serial=batch_serial,
|
|
||||||
notes_value=NEW_VALUE,
|
|
||||||
)
|
|
||||||
except Exception as exc: # noqa: BLE001 - surface to CLI/UI
|
|
||||||
return CreateResult(
|
|
||||||
ok=False,
|
|
||||||
message=f"Failed to create workbook: {exc}",
|
|
||||||
template=template,
|
|
||||||
destination=new_workbook_name,
|
|
||||||
backend=resolved_backend,
|
|
||||||
)
|
|
||||||
|
|
||||||
return CreateResult(
|
|
||||||
ok=True,
|
|
||||||
message=f"Wrote {new_workbook_name}",
|
|
||||||
template=template,
|
|
||||||
destination=new_workbook_name,
|
|
||||||
backend=resolved_backend,
|
|
||||||
)
|
)
|
||||||
|
from xlsx_clean.paths import default_backend, resolve_backend
|
||||||
|
|
||||||
|
|
||||||
def parse_args(argv: list[str] | None = None) -> argparse.Namespace:
|
def parse_args(argv: list[str] | None = None) -> argparse.Namespace:
|
||||||
@@ -210,41 +29,58 @@ def parse_args(argv: list[str] | None = None) -> argparse.Namespace:
|
|||||||
default=None,
|
default=None,
|
||||||
help=(
|
help=(
|
||||||
"Excel edit backend: 'com' (Windows Excel + add-ins) or "
|
"Excel edit backend: 'com' (Windows Excel + add-ins) or "
|
||||||
f"'ooxml' (surgical zip edit). Default: {default_backend()}."
|
f"'ooxml' (surgical zip edit). Default: {default_backend()} (Overrides config.toml)."
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
parser.add_argument(
|
||||||
|
"--root",
|
||||||
|
type=str,
|
||||||
|
default=None,
|
||||||
|
help="Override the root directory for the selected set.",
|
||||||
|
)
|
||||||
return parser.parse_args(argv)
|
return parser.parse_args(argv)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def run(argv: list[str] | None = None) -> int:
|
def run(argv: list[str] | None = None) -> int:
|
||||||
|
from pathlib import Path
|
||||||
args = parse_args(argv)
|
args = parse_args(argv)
|
||||||
|
|
||||||
|
content, rows, config = load_config()
|
||||||
|
|
||||||
# Validate early so CLI fails fast on unsupported COM.
|
# Validate early so CLI fails fast on unsupported COM.
|
||||||
try:
|
try:
|
||||||
backend = resolve_backend(args.backend)
|
backend = resolve_backend(args.backend, config.get("backend"))
|
||||||
except (ValueError, RuntimeError) as exc:
|
except (ValueError, RuntimeError) as exc:
|
||||||
Console().print(f"[red]{exc}[/red]")
|
Console().print(f"[red]{exc}[/red]")
|
||||||
return 1
|
return 1
|
||||||
|
|
||||||
content, path_df = load_config()
|
|
||||||
q1, q2, q3 = content[0], content[1], content[2]
|
q1, q2, q3 = content[0], content[1], content[2]
|
||||||
addin_paths = content[3:5] if len(content) >= 5 else []
|
addin_paths = content[3:5] if len(content) >= 5 else []
|
||||||
|
|
||||||
console = Console()
|
console = Console()
|
||||||
console.print(q1)
|
console.print(q1)
|
||||||
selected_set = select(list_sets(path_df), cursor_style="cyan")
|
selected_set = select(list_sets(rows), cursor_style="cyan")
|
||||||
|
|
||||||
console.print(q2)
|
console.print(q2)
|
||||||
selected_dir = select(list_ink_colors(path_df, selected_set))
|
selected_dir = select(list_ink_colors(rows, selected_set))
|
||||||
console.print(f"Selected: {selected_dir}")
|
console.print(f"Selected: {selected_dir}")
|
||||||
|
|
||||||
|
if args.root:
|
||||||
|
for r in rows:
|
||||||
|
if r["set_name"] == selected_set:
|
||||||
|
r["dir"] = str(Path(args.root) / r["rel_dir"])
|
||||||
|
|
||||||
batch_serial = prompt(q3, target_type=str)
|
batch_serial = prompt(q3, target_type=str)
|
||||||
result = create_datasheet(
|
result = create_datasheet(
|
||||||
selected_set=selected_set,
|
selected_set=selected_set,
|
||||||
selected_dir=selected_dir,
|
selected_dir=selected_dir,
|
||||||
batch_serial=batch_serial,
|
batch_serial=batch_serial,
|
||||||
backend=backend,
|
backend=backend,
|
||||||
path_df=path_df,
|
rows=rows,
|
||||||
addin_paths=addin_paths,
|
addin_paths=addin_paths,
|
||||||
|
config=config,
|
||||||
)
|
)
|
||||||
|
|
||||||
if result.template is not None:
|
if result.template is not None:
|
||||||
|
|||||||
@@ -5,6 +5,45 @@ from __future__ import annotations
|
|||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
|
||||||
|
|
||||||
|
def _bring_excel_to_front(excel, workbook) -> None:
|
||||||
|
"""Maximize and force Excel ahead of other windows (e.g. NiceGUI)."""
|
||||||
|
import win32com.client as win32
|
||||||
|
import win32con
|
||||||
|
import win32gui
|
||||||
|
|
||||||
|
excel.Visible = True
|
||||||
|
excel.WindowState = win32.constants.xlMaximized
|
||||||
|
try:
|
||||||
|
workbook.Activate()
|
||||||
|
except Exception:
|
||||||
|
pass
|
||||||
|
try:
|
||||||
|
hwnd = int(excel.Hwnd)
|
||||||
|
win32gui.ShowWindow(hwnd, win32con.SW_RESTORE)
|
||||||
|
win32gui.ShowWindow(hwnd, win32con.SW_MAXIMIZE)
|
||||||
|
# Allow SetForegroundWindow to succeed when another app has focus.
|
||||||
|
try:
|
||||||
|
import win32api
|
||||||
|
import win32process
|
||||||
|
|
||||||
|
fg = win32gui.GetForegroundWindow()
|
||||||
|
fg_tid, _ = win32process.GetWindowThreadProcessId(fg)
|
||||||
|
our_tid = win32api.GetCurrentThreadId()
|
||||||
|
if fg_tid != our_tid:
|
||||||
|
win32process.AttachThreadInput(our_tid, fg_tid, True)
|
||||||
|
try:
|
||||||
|
win32gui.SetForegroundWindow(hwnd)
|
||||||
|
finally:
|
||||||
|
win32process.AttachThreadInput(our_tid, fg_tid, False)
|
||||||
|
else:
|
||||||
|
win32gui.SetForegroundWindow(hwnd)
|
||||||
|
except Exception:
|
||||||
|
win32gui.SetForegroundWindow(hwnd)
|
||||||
|
except Exception:
|
||||||
|
# Focus stealing can fail under some Windows policies; create still succeeded.
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
def clean_workbook_com(
|
def clean_workbook_com(
|
||||||
source: Path | str,
|
source: Path | str,
|
||||||
destination: Path | str,
|
destination: Path | str,
|
||||||
@@ -60,5 +99,5 @@ def clean_workbook_com(
|
|||||||
worksheet.Range(a1).Value = batch_serial
|
worksheet.Range(a1).Value = batch_serial
|
||||||
|
|
||||||
workbook.SaveAs(str(destination.resolve()))
|
workbook.SaveAs(str(destination.resolve()))
|
||||||
if maximize:
|
if maximize or visible:
|
||||||
excel.WindowState = win32.constants.xlMaximized
|
_bring_excel_to_front(excel, workbook)
|
||||||
|
|||||||
263
src/xlsx_clean/core.py
Normal file
263
src/xlsx_clean/core.py
Normal file
@@ -0,0 +1,263 @@
|
|||||||
|
"""Core business logic for xlsx_clean."""
|
||||||
|
|
||||||
|
from __future__ import annotations
|
||||||
|
|
||||||
|
import csv
|
||||||
|
import shutil
|
||||||
|
import tempfile
|
||||||
|
from dataclasses import dataclass
|
||||||
|
from datetime import datetime
|
||||||
|
from pathlib import Path
|
||||||
|
|
||||||
|
import tomllib
|
||||||
|
|
||||||
|
from xlsx_clean.app_logging import get_logger
|
||||||
|
from xlsx_clean.paths import (
|
||||||
|
default_config_path,
|
||||||
|
package_file,
|
||||||
|
resolve_backend,
|
||||||
|
)
|
||||||
|
|
||||||
|
DEFAULT_CONFIG_CONTENT = """\
|
||||||
|
# Configuration for xlsx_clean
|
||||||
|
|
||||||
|
# backend options:
|
||||||
|
# - "com": Use Microsoft Excel COM (Windows only, keeps Excel visible)
|
||||||
|
# - "ooxml": Surgical zip edit (Cross-platform, very fast, preserves non-worksheet data)
|
||||||
|
backend = "com"
|
||||||
|
|
||||||
|
[sets]
|
||||||
|
"Kimia Razi" = "D:\\\\OpenCloud\\\\Kimia Razi"
|
||||||
|
"inco" = "D:\\\\OpenCloud\\\\inco"
|
||||||
|
"""
|
||||||
|
|
||||||
|
|
||||||
|
NEW_VALUE = ""
|
||||||
|
|
||||||
|
|
||||||
|
@dataclass(frozen=True)
|
||||||
|
class CreateResult:
|
||||||
|
ok: bool
|
||||||
|
message: str
|
||||||
|
template: Path | None = None
|
||||||
|
destination: Path | None = None
|
||||||
|
backend: str | None = None
|
||||||
|
skipped: bool = False
|
||||||
|
|
||||||
|
|
||||||
|
def find_last_workbook(files: list[str]) -> str:
|
||||||
|
return sorted(files)[-1]
|
||||||
|
|
||||||
|
|
||||||
|
def get_workbook_names(
|
||||||
|
files: list[str],
|
||||||
|
batch_serial: str,
|
||||||
|
source_dir: Path,
|
||||||
|
pattern: str,
|
||||||
|
) -> tuple[str, Path]:
|
||||||
|
last_workbook = find_last_workbook(files)
|
||||||
|
path_of_the_year = Path(str(source_dir).replace("2025", str(datetime.now().year)))
|
||||||
|
return last_workbook, path_of_the_year / pattern.replace(
|
||||||
|
"[SERIAL]", batch_serial.split("/")[0]
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
def load_config() -> tuple[list[str], list[dict], dict]:
|
||||||
|
config_path = default_config_path()
|
||||||
|
if not config_path.exists():
|
||||||
|
config_path.parent.mkdir(parents=True, exist_ok=True)
|
||||||
|
config_path.write_text(DEFAULT_CONFIG_CONTENT, encoding="utf-8")
|
||||||
|
|
||||||
|
with open(config_path, "rb") as f:
|
||||||
|
config = tomllib.load(f)
|
||||||
|
|
||||||
|
strings_path = package_file("strings.txt")
|
||||||
|
with open(strings_path, encoding="utf-8") as f:
|
||||||
|
content = [line.strip() for line in f.readlines()]
|
||||||
|
|
||||||
|
csv_path = package_file("file_data.csv")
|
||||||
|
rows = []
|
||||||
|
set_roots = config.get("sets", {})
|
||||||
|
with open(csv_path, encoding="utf-8") as f:
|
||||||
|
reader = csv.DictReader(f)
|
||||||
|
for row in reader:
|
||||||
|
set_name = row["set_name"]
|
||||||
|
rel_dir = row["dir"].replace("\\", "/")
|
||||||
|
row["rel_dir"] = rel_dir
|
||||||
|
root_str = set_roots.get(set_name, "")
|
||||||
|
if root_str:
|
||||||
|
row["dir"] = str(Path(root_str) / rel_dir)
|
||||||
|
else:
|
||||||
|
row["dir"] = str(Path(rel_dir))
|
||||||
|
rows.append(row)
|
||||||
|
|
||||||
|
return content, rows, config
|
||||||
|
|
||||||
|
|
||||||
|
def list_sets(rows: list[dict]) -> list[str]:
|
||||||
|
return list(dict.fromkeys(r["set_name"] for r in rows))
|
||||||
|
|
||||||
|
|
||||||
|
import re
|
||||||
|
|
||||||
|
def _sort_key(name: str):
|
||||||
|
match = re.search(r'\d+', name)
|
||||||
|
num = int(match.group()) if match else 0
|
||||||
|
return (num, name)
|
||||||
|
|
||||||
|
def list_ink_colors(rows: list[dict], selected_set: str) -> list[str]:
|
||||||
|
inks = (Path(r["dir"]).stem for r in rows if r["set_name"] == selected_set)
|
||||||
|
return sorted(inks, key=_sort_key)
|
||||||
|
|
||||||
|
|
||||||
|
def create_datasheet(
|
||||||
|
selected_set: str,
|
||||||
|
selected_dir: str,
|
||||||
|
batch_serial: str,
|
||||||
|
backend: str | None = None,
|
||||||
|
rows: list[dict] | None = None,
|
||||||
|
addin_paths: list[str] | None = None,
|
||||||
|
config: dict | None = None,
|
||||||
|
) -> CreateResult:
|
||||||
|
log = get_logger()
|
||||||
|
ctx = f"set={selected_set!r} ink={selected_dir!r} serial={batch_serial!r}"
|
||||||
|
|
||||||
|
if not selected_set:
|
||||||
|
message = "Select a set."
|
||||||
|
log.error("Create failed: %s (%s)", message, ctx)
|
||||||
|
return CreateResult(ok=False, message=message)
|
||||||
|
if not selected_dir:
|
||||||
|
message = "Select an ink color."
|
||||||
|
log.error("Create failed: %s (%s)", message, ctx)
|
||||||
|
return CreateResult(ok=False, message=message)
|
||||||
|
if not batch_serial or not str(batch_serial).strip():
|
||||||
|
message = "Enter a serial."
|
||||||
|
log.error("Create failed: %s (%s)", message, ctx)
|
||||||
|
return CreateResult(ok=False, message=message)
|
||||||
|
|
||||||
|
batch_serial = str(batch_serial).strip()
|
||||||
|
ctx = f"set={selected_set!r} ink={selected_dir!r} serial={batch_serial!r}"
|
||||||
|
if config is None:
|
||||||
|
content, loaded_rows, config = load_config()
|
||||||
|
if rows is None:
|
||||||
|
rows = loaded_rows
|
||||||
|
if addin_paths is None:
|
||||||
|
addin_paths = content[3:5] if len(content) >= 5 else []
|
||||||
|
|
||||||
|
try:
|
||||||
|
resolved_backend = resolve_backend(backend, config.get("backend"))
|
||||||
|
except (ValueError, RuntimeError) as exc:
|
||||||
|
log.error("Create failed: %s (%s)", exc, ctx)
|
||||||
|
return CreateResult(ok=False, message=str(exc))
|
||||||
|
|
||||||
|
ctx = f"{ctx} backend={resolved_backend}"
|
||||||
|
|
||||||
|
matches = [r for r in rows if r["set_name"] == selected_set and r["dir"].endswith(selected_dir)]
|
||||||
|
if not matches:
|
||||||
|
message = f"No config row for set={selected_set!r} ink={selected_dir!r}."
|
||||||
|
log.error("Create failed: %s (%s)", message, ctx)
|
||||||
|
return CreateResult(ok=False, message=message)
|
||||||
|
|
||||||
|
row = matches[0]
|
||||||
|
path_ = Path(row["dir"])
|
||||||
|
pattern = row["pattern"]
|
||||||
|
search_pattern = pattern.replace("[SERIAL]", "*")
|
||||||
|
files = [str(x) for x in path_.glob(search_pattern) if x.is_file()]
|
||||||
|
|
||||||
|
if not files:
|
||||||
|
message = f"No workbooks matching {search_pattern!r} in {path_}"
|
||||||
|
log.error("Create failed: %s (%s)", message, ctx)
|
||||||
|
return CreateResult(
|
||||||
|
ok=False,
|
||||||
|
message=message,
|
||||||
|
backend=resolved_backend,
|
||||||
|
)
|
||||||
|
|
||||||
|
ref_workbook_name, new_workbook_name = get_workbook_names(
|
||||||
|
files, batch_serial, path_, pattern
|
||||||
|
)
|
||||||
|
template = Path(ref_workbook_name)
|
||||||
|
|
||||||
|
if new_workbook_name.is_file():
|
||||||
|
message = f"Destination already exists, skipped: {new_workbook_name}"
|
||||||
|
log.info(
|
||||||
|
"Create skipped: %s (template=%s destination=%s %s)",
|
||||||
|
message,
|
||||||
|
template,
|
||||||
|
new_workbook_name,
|
||||||
|
ctx,
|
||||||
|
)
|
||||||
|
return CreateResult(
|
||||||
|
ok=True,
|
||||||
|
skipped=True,
|
||||||
|
message=message,
|
||||||
|
template=template,
|
||||||
|
destination=new_workbook_name,
|
||||||
|
backend=resolved_backend,
|
||||||
|
)
|
||||||
|
|
||||||
|
cells_to_clear = row["cells_to_clear"]
|
||||||
|
notes_cell = row["notes_cell"]
|
||||||
|
serial_cell = row["serial_cell"]
|
||||||
|
|
||||||
|
try:
|
||||||
|
if resolved_backend == "com":
|
||||||
|
from xlsx_clean.com_backend import clean_workbook_com
|
||||||
|
|
||||||
|
with tempfile.TemporaryDirectory(prefix="xlsx_clean_") as tmp:
|
||||||
|
temp_workbook = Path(tmp) / "temp_workbook.xlsx"
|
||||||
|
shutil.copyfile(ref_workbook_name, temp_workbook)
|
||||||
|
clean_workbook_com(
|
||||||
|
source=temp_workbook,
|
||||||
|
destination=new_workbook_name,
|
||||||
|
cells_to_clear=cells_to_clear,
|
||||||
|
notes_cell=notes_cell,
|
||||||
|
serial_cell=serial_cell,
|
||||||
|
batch_serial=batch_serial,
|
||||||
|
addin_paths=addin_paths or [],
|
||||||
|
notes_value=NEW_VALUE,
|
||||||
|
)
|
||||||
|
else:
|
||||||
|
from xlsx_clean.ooxml_backend import clean_workbook_ooxml
|
||||||
|
|
||||||
|
clean_workbook_ooxml(
|
||||||
|
source=ref_workbook_name,
|
||||||
|
destination=new_workbook_name,
|
||||||
|
cells_to_clear=cells_to_clear,
|
||||||
|
notes_cell=notes_cell,
|
||||||
|
serial_cell=serial_cell,
|
||||||
|
batch_serial=batch_serial,
|
||||||
|
notes_value=NEW_VALUE,
|
||||||
|
)
|
||||||
|
except Exception as exc: # noqa: BLE001 - surface to CLI/UI
|
||||||
|
message = f"Failed to create workbook: {exc}"
|
||||||
|
log.exception(
|
||||||
|
"Create failed: %s (template=%s destination=%s %s)",
|
||||||
|
message,
|
||||||
|
template,
|
||||||
|
new_workbook_name,
|
||||||
|
ctx,
|
||||||
|
)
|
||||||
|
return CreateResult(
|
||||||
|
ok=False,
|
||||||
|
message=message,
|
||||||
|
template=template,
|
||||||
|
destination=new_workbook_name,
|
||||||
|
backend=resolved_backend,
|
||||||
|
)
|
||||||
|
|
||||||
|
message = f"Wrote {new_workbook_name}"
|
||||||
|
log.info(
|
||||||
|
"Create succeeded: %s (template=%s destination=%s %s)",
|
||||||
|
message,
|
||||||
|
template,
|
||||||
|
new_workbook_name,
|
||||||
|
ctx,
|
||||||
|
)
|
||||||
|
return CreateResult(
|
||||||
|
ok=True,
|
||||||
|
message=message,
|
||||||
|
template=template,
|
||||||
|
destination=new_workbook_name,
|
||||||
|
backend=resolved_backend,
|
||||||
|
)
|
||||||
@@ -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
|
||||||
"D:\OpenCloud\Kimia Razi\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\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
|
||||||
"D:\OpenCloud\Kimia Razi\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\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
|
||||||
"D:\OpenCloud\Kimia Razi\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\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
|
||||||
"D:\OpenCloud\Kimia Razi\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\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
|
||||||
"D:\OpenCloud\Kimia Razi\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\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
|
||||||
"D:\OpenCloud\Kimia Razi\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\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
|
||||||
"D:\OpenCloud\Kimia Razi\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\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
|
||||||
"D:\OpenCloud\Kimia Razi\Production\QC Datasheet\1403\KRBG1600T Beige","KRBG1600T Beige [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\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
|
||||||
"D:\OpenCloud\Kimia Razi\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\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
|
||||||
"D:\OpenCloud\Kimia Razi\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\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
|
||||||
"D:\OpenCloud\inco\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\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
|
||||||
"D:\OpenCloud\inco\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\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
|
||||||
"D:\OpenCloud\inco\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\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
|
||||||
"D:\OpenCloud\inco\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\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
|
||||||
"D:\OpenCloud\inco\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\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
|
||||||
"D:\OpenCloud\inco\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\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
|
||||||
"D:\OpenCloud\inco\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\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
|
||||||
"D:\OpenCloud\inco\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\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
|
||||||
"D:\OpenCloud\inco\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\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
|
||||||
"D:\OpenCloud\inco\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\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
|
||||||
"D:\OpenCloud\inco\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\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
|
||||||
"D:\OpenCloud\inco\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\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
|
||||||
"D:\OpenCloud\inco\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\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
|
||||||
"D:\OpenCloud\inco\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\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
|
||||||
|
|||||||
|
BIN
src/xlsx_clean/fonts/Inter-Bold.ttf
Normal file
BIN
src/xlsx_clean/fonts/Inter-Bold.ttf
Normal file
Binary file not shown.
BIN
src/xlsx_clean/fonts/Inter-Regular.ttf
Normal file
BIN
src/xlsx_clean/fonts/Inter-Regular.ttf
Normal file
Binary file not shown.
298
src/xlsx_clean/gui_app.py
Normal file
298
src/xlsx_clean/gui_app.py
Normal file
@@ -0,0 +1,298 @@
|
|||||||
|
"""Cross-platform Dear PyGui desktop GUI for New QC Sheet."""
|
||||||
|
|
||||||
|
from __future__ import annotations
|
||||||
|
|
||||||
|
import argparse
|
||||||
|
import sys
|
||||||
|
from importlib.metadata import PackageNotFoundError, version as package_version
|
||||||
|
|
||||||
|
import dearpygui.dearpygui as dpg
|
||||||
|
|
||||||
|
from xlsx_clean.core import (
|
||||||
|
create_datasheet,
|
||||||
|
list_ink_colors,
|
||||||
|
list_sets,
|
||||||
|
load_config,
|
||||||
|
)
|
||||||
|
from xlsx_clean.paths import default_backend, package_file
|
||||||
|
|
||||||
|
try:
|
||||||
|
_VERSION = package_version('xlsx-clean')
|
||||||
|
except PackageNotFoundError:
|
||||||
|
_VERSION = 'dev'
|
||||||
|
|
||||||
|
# Module-level variables
|
||||||
|
rows = []
|
||||||
|
addin_paths = []
|
||||||
|
config = {}
|
||||||
|
|
||||||
|
|
||||||
|
# Tags
|
||||||
|
SET_COMBO = "set_combo"
|
||||||
|
INK_COMBO = "ink_combo"
|
||||||
|
SERIAL_INPUT = "serial_input"
|
||||||
|
STATUS_TEXT = "status_text"
|
||||||
|
HEADING_FONT = "heading_font"
|
||||||
|
|
||||||
|
def on_set_change(sender, app_data):
|
||||||
|
"""Callback when the set combo changes."""
|
||||||
|
new_inks = list_ink_colors(rows, app_data)
|
||||||
|
dpg.configure_item(INK_COMBO, items=new_inks)
|
||||||
|
dpg.set_value(INK_COMBO, new_inks[0] if new_inks else '')
|
||||||
|
|
||||||
|
def on_create(sender, app_data):
|
||||||
|
"""Callback for the Create datasheet button."""
|
||||||
|
selected_set = dpg.get_value(SET_COMBO)
|
||||||
|
selected_dir = dpg.get_value(INK_COMBO)
|
||||||
|
batch_serial = dpg.get_value(SERIAL_INPUT)
|
||||||
|
|
||||||
|
try:
|
||||||
|
result = create_datasheet(
|
||||||
|
selected_set=selected_set,
|
||||||
|
selected_dir=selected_dir,
|
||||||
|
batch_serial=batch_serial,
|
||||||
|
backend=None,
|
||||||
|
rows=rows,
|
||||||
|
addin_paths=addin_paths,
|
||||||
|
config=config
|
||||||
|
)
|
||||||
|
|
||||||
|
msg = result.message
|
||||||
|
if result.template:
|
||||||
|
msg += f"\nTemplate: {result.template}"
|
||||||
|
if result.destination:
|
||||||
|
msg += f"\nDestination: {result.destination}"
|
||||||
|
if result.backend:
|
||||||
|
msg += f"\nBackend: {result.backend}"
|
||||||
|
|
||||||
|
dpg.set_value(STATUS_TEXT, msg)
|
||||||
|
|
||||||
|
if result.skipped:
|
||||||
|
dpg.configure_item(STATUS_TEXT, color=(230, 180, 30)) # Yellow
|
||||||
|
elif result.ok:
|
||||||
|
dpg.configure_item(STATUS_TEXT, color=(0, 200, 80)) # Green
|
||||||
|
else:
|
||||||
|
dpg.configure_item(STATUS_TEXT, color=(220, 60, 60)) # Red
|
||||||
|
except Exception as e:
|
||||||
|
dpg.set_value(STATUS_TEXT, f"Error: {e}")
|
||||||
|
dpg.configure_item(STATUS_TEXT, color=(220, 60, 60))
|
||||||
|
|
||||||
|
def _create_modern_theme() -> int:
|
||||||
|
"""Build a global theme that gives DPG widgets a modern, web-like feel, matching the HTML demo."""
|
||||||
|
with dpg.theme() as theme:
|
||||||
|
with dpg.theme_component(dpg.mvAll):
|
||||||
|
# Rounded corners (like CSS border-radius)
|
||||||
|
dpg.add_theme_style(dpg.mvStyleVar_FrameRounding, 4)
|
||||||
|
dpg.add_theme_style(dpg.mvStyleVar_PopupRounding, 4)
|
||||||
|
dpg.add_theme_style(dpg.mvStyleVar_WindowRounding, 8)
|
||||||
|
dpg.add_theme_style(dpg.mvStyleVar_GrabRounding, 4)
|
||||||
|
dpg.add_theme_style(dpg.mvStyleVar_TabRounding, 4)
|
||||||
|
dpg.add_theme_style(dpg.mvStyleVar_ChildRounding, 4)
|
||||||
|
dpg.add_theme_style(dpg.mvStyleVar_ScrollbarRounding, 4)
|
||||||
|
|
||||||
|
# Generous padding (like CSS padding)
|
||||||
|
dpg.add_theme_style(dpg.mvStyleVar_FramePadding, 12, 10)
|
||||||
|
dpg.add_theme_style(dpg.mvStyleVar_ItemSpacing, 10, 10)
|
||||||
|
dpg.add_theme_style(dpg.mvStyleVar_ItemInnerSpacing, 8, 6)
|
||||||
|
dpg.add_theme_style(dpg.mvStyleVar_WindowPadding, 48, 48)
|
||||||
|
|
||||||
|
# Scrollbar
|
||||||
|
dpg.add_theme_style(dpg.mvStyleVar_ScrollbarSize, 12)
|
||||||
|
|
||||||
|
# Colors from demo.html
|
||||||
|
bg = (248, 250, 252, 255) # Slate 50 (#f8fafc)
|
||||||
|
surface = (255, 255, 255, 255) # White (#ffffff)
|
||||||
|
frame = (255, 255, 255, 255) # White (inputs)
|
||||||
|
frame_hover = (240, 253, 250, 255) # Teal 50 (#f0fdfa)
|
||||||
|
frame_active = (204, 251, 241, 255) # Teal 100 (#ccfbf1)
|
||||||
|
accent = (15, 118, 110, 255) # Teal 700 (#0f766e) - Primary
|
||||||
|
accent_hover = (17, 94, 89, 255) # Teal 800 (#115e59) - Secondary
|
||||||
|
accent_active = (19, 78, 74, 255) # Teal 900 (#134e4a)
|
||||||
|
text = (15, 23, 42, 255) # Slate 900 (#0f172a)
|
||||||
|
text_dim = (100, 116, 139, 255) # Slate 500 (#64748b)
|
||||||
|
border = (203, 213, 225, 255) # Slate 300 (#cbd5e1)
|
||||||
|
popup_bg = (255, 255, 255, 255) # White dropdowns
|
||||||
|
|
||||||
|
# Window
|
||||||
|
dpg.add_theme_color(dpg.mvThemeCol_WindowBg, bg)
|
||||||
|
dpg.add_theme_color(dpg.mvThemeCol_PopupBg, popup_bg)
|
||||||
|
dpg.add_theme_color(dpg.mvThemeCol_TitleBg, bg)
|
||||||
|
dpg.add_theme_color(dpg.mvThemeCol_TitleBgActive, bg)
|
||||||
|
|
||||||
|
# Frame (combos, inputs)
|
||||||
|
dpg.add_theme_color(dpg.mvThemeCol_FrameBg, frame)
|
||||||
|
dpg.add_theme_color(dpg.mvThemeCol_FrameBgHovered, frame_hover)
|
||||||
|
dpg.add_theme_color(dpg.mvThemeCol_FrameBgActive, frame_active)
|
||||||
|
|
||||||
|
# Border
|
||||||
|
dpg.add_theme_color(dpg.mvThemeCol_Border, border)
|
||||||
|
dpg.add_theme_color(dpg.mvThemeCol_BorderShadow, (0, 0, 0, 0))
|
||||||
|
dpg.add_theme_style(dpg.mvStyleVar_FrameBorderSize, 1)
|
||||||
|
|
||||||
|
# Button (Combo box drop arrows) - blend into frame
|
||||||
|
dpg.add_theme_color(dpg.mvThemeCol_Button, frame)
|
||||||
|
dpg.add_theme_color(dpg.mvThemeCol_ButtonHovered, frame_hover)
|
||||||
|
dpg.add_theme_color(dpg.mvThemeCol_ButtonActive, frame_active)
|
||||||
|
|
||||||
|
# Header (combo dropdown items on hover)
|
||||||
|
dpg.add_theme_color(dpg.mvThemeCol_Header, frame_hover)
|
||||||
|
dpg.add_theme_color(dpg.mvThemeCol_HeaderHovered, frame_active)
|
||||||
|
dpg.add_theme_color(dpg.mvThemeCol_HeaderActive, accent)
|
||||||
|
|
||||||
|
# Text
|
||||||
|
dpg.add_theme_color(dpg.mvThemeCol_Text, text)
|
||||||
|
dpg.add_theme_color(dpg.mvThemeCol_TextDisabled, text_dim)
|
||||||
|
|
||||||
|
# Separator
|
||||||
|
dpg.add_theme_color(dpg.mvThemeCol_Separator, border)
|
||||||
|
|
||||||
|
# Scrollbar
|
||||||
|
dpg.add_theme_color(dpg.mvThemeCol_ScrollbarBg, bg)
|
||||||
|
dpg.add_theme_color(dpg.mvThemeCol_ScrollbarGrab, border)
|
||||||
|
dpg.add_theme_color(dpg.mvThemeCol_ScrollbarGrabHovered, text_dim)
|
||||||
|
dpg.add_theme_color(dpg.mvThemeCol_ScrollbarGrabActive, text)
|
||||||
|
|
||||||
|
# Check mark / selection
|
||||||
|
dpg.add_theme_color(dpg.mvThemeCol_CheckMark, accent)
|
||||||
|
|
||||||
|
return theme
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
def parse_args() -> argparse.Namespace:
|
||||||
|
parser = argparse.ArgumentParser(
|
||||||
|
description="New QC Sheet — Dear PyGui desktop application.",
|
||||||
|
)
|
||||||
|
parser.add_argument('--width', type=int, default=650, help='Window width')
|
||||||
|
parser.add_argument('--height', type=int, default=700, help='Window height')
|
||||||
|
return parser.parse_args()
|
||||||
|
|
||||||
|
|
||||||
|
def main() -> None:
|
||||||
|
global rows, addin_paths, config
|
||||||
|
args = parse_args()
|
||||||
|
|
||||||
|
dpg.create_context()
|
||||||
|
|
||||||
|
# --- Modern theme ---------------------------------------------------
|
||||||
|
modern_theme = _create_modern_theme()
|
||||||
|
dpg.bind_theme(modern_theme)
|
||||||
|
|
||||||
|
# --- Load Inter font ------------------------------------------------
|
||||||
|
font_regular = package_file("fonts/Inter-Regular.ttf")
|
||||||
|
font_bold = package_file("fonts/Inter-Bold.ttf")
|
||||||
|
default_font = None
|
||||||
|
heading_font = None
|
||||||
|
label_font = None
|
||||||
|
if font_regular.is_file():
|
||||||
|
with dpg.font_registry():
|
||||||
|
default_font = dpg.add_font(str(font_regular), 18)
|
||||||
|
label_font = dpg.add_font(str(font_regular), 14)
|
||||||
|
if font_bold.is_file():
|
||||||
|
heading_font = dpg.add_font(str(font_bold), 28, tag=HEADING_FONT)
|
||||||
|
|
||||||
|
# Load config and initialize variables
|
||||||
|
sets = []
|
||||||
|
initial_inks = []
|
||||||
|
error_msg = ""
|
||||||
|
|
||||||
|
label_set = 'Select Set'
|
||||||
|
label_ink = 'Select Ink Color'
|
||||||
|
label_serial = 'Serial:'
|
||||||
|
|
||||||
|
try:
|
||||||
|
content, loaded_rows, loaded_config = load_config()
|
||||||
|
rows = loaded_rows
|
||||||
|
config = loaded_config
|
||||||
|
if len(content) >= 5:
|
||||||
|
label_set = content[0]
|
||||||
|
label_ink = content[1]
|
||||||
|
label_serial = content[2]
|
||||||
|
addin_paths = content[3:5]
|
||||||
|
|
||||||
|
sets = list_sets(rows)
|
||||||
|
if sets:
|
||||||
|
initial_inks = list_ink_colors(rows, sets[0])
|
||||||
|
except Exception as e:
|
||||||
|
error_msg = f"Failed to load config: {e}"
|
||||||
|
|
||||||
|
with dpg.theme() as tight_theme:
|
||||||
|
with dpg.theme_component(dpg.mvAll):
|
||||||
|
dpg.add_theme_style(dpg.mvStyleVar_ItemSpacing, 10, -8)
|
||||||
|
|
||||||
|
with dpg.theme() as normal_spacing_theme:
|
||||||
|
with dpg.theme_component(dpg.mvAll):
|
||||||
|
dpg.add_theme_style(dpg.mvStyleVar_ItemSpacing, 10, 10)
|
||||||
|
|
||||||
|
with dpg.theme() as btn_theme:
|
||||||
|
with dpg.theme_component(dpg.mvButton):
|
||||||
|
dpg.add_theme_color(dpg.mvThemeCol_Text, (255, 255, 255, 255))
|
||||||
|
dpg.add_theme_color(dpg.mvThemeCol_Button, (15, 118, 110, 255))
|
||||||
|
dpg.add_theme_color(dpg.mvThemeCol_ButtonHovered, (17, 94, 89, 255))
|
||||||
|
dpg.add_theme_color(dpg.mvThemeCol_ButtonActive, (19, 78, 74, 255))
|
||||||
|
|
||||||
|
with dpg.window(tag="primary_window"):
|
||||||
|
if default_font:
|
||||||
|
dpg.bind_font(default_font)
|
||||||
|
|
||||||
|
title = dpg.add_text('New QC Sheet', color=(17, 94, 89, 255))
|
||||||
|
if heading_font:
|
||||||
|
dpg.bind_item_font(title, heading_font)
|
||||||
|
dpg.add_text(f"v{_VERSION}", color=(100, 106, 120))
|
||||||
|
dpg.add_spacer(height=4)
|
||||||
|
dpg.add_separator()
|
||||||
|
dpg.add_spacer(height=10)
|
||||||
|
|
||||||
|
def add_floating_label(text):
|
||||||
|
lbl = dpg.add_text(text, color=(15, 118, 110, 255))
|
||||||
|
if label_font:
|
||||||
|
dpg.bind_item_font(lbl, label_font)
|
||||||
|
|
||||||
|
with dpg.group() as g1:
|
||||||
|
add_floating_label(label_set)
|
||||||
|
c1 = dpg.add_combo(items=sets, default_value=sets[0] if sets else '',
|
||||||
|
tag=SET_COMBO, callback=on_set_change, width=-1)
|
||||||
|
dpg.bind_item_theme(c1, normal_spacing_theme)
|
||||||
|
dpg.bind_item_theme(g1, tight_theme)
|
||||||
|
dpg.add_spacer(height=8)
|
||||||
|
|
||||||
|
with dpg.group() as g2:
|
||||||
|
add_floating_label(label_ink)
|
||||||
|
c2 = dpg.add_combo(items=initial_inks,
|
||||||
|
default_value=initial_inks[0] if initial_inks else '',
|
||||||
|
tag=INK_COMBO, width=-1)
|
||||||
|
dpg.bind_item_theme(c2, normal_spacing_theme)
|
||||||
|
dpg.bind_item_theme(g2, tight_theme)
|
||||||
|
dpg.add_spacer(height=8)
|
||||||
|
|
||||||
|
with dpg.group() as g3:
|
||||||
|
add_floating_label(label_serial)
|
||||||
|
c3 = dpg.add_input_text(tag=SERIAL_INPUT, width=-1, hint="e.g. 1234/A")
|
||||||
|
dpg.bind_item_theme(c3, normal_spacing_theme)
|
||||||
|
dpg.bind_item_theme(g3, tight_theme)
|
||||||
|
dpg.add_spacer(height=10)
|
||||||
|
|
||||||
|
dpg.add_separator()
|
||||||
|
dpg.add_spacer(height=10)
|
||||||
|
|
||||||
|
btn = dpg.add_button(label='Create datasheet', width=-1, height=38,
|
||||||
|
callback=on_create)
|
||||||
|
dpg.bind_item_theme(btn, btn_theme)
|
||||||
|
dpg.add_spacer(height=14)
|
||||||
|
|
||||||
|
dpg.add_text(error_msg, tag=STATUS_TEXT, wrap=args.width - 40)
|
||||||
|
if error_msg:
|
||||||
|
dpg.configure_item(STATUS_TEXT, color=(220, 60, 60))
|
||||||
|
|
||||||
|
dpg.create_viewport(title=f'New QC Sheet · v{_VERSION}',
|
||||||
|
width=args.width, height=args.height)
|
||||||
|
dpg.setup_dearpygui()
|
||||||
|
dpg.show_viewport()
|
||||||
|
dpg.set_primary_window("primary_window", True)
|
||||||
|
dpg.start_dearpygui()
|
||||||
|
dpg.destroy_context()
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
main()
|
||||||
|
|
||||||
@@ -6,54 +6,42 @@ import os
|
|||||||
import sys
|
import sys
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
|
||||||
PACKAGE_DIR = Path(__file__).resolve().parent
|
|
||||||
|
|
||||||
# Historical Windows root used in file_data.csv
|
def _package_dir() -> Path:
|
||||||
DEFAULT_OPENCLOUD_ROOT = Path(r"D:\OpenCloud")
|
"""Directory containing package data (CSV/txt), including PyInstaller bundles."""
|
||||||
OPENCLOUD_MARKER = "OpenCloud"
|
if getattr(sys, "frozen", False) and hasattr(sys, "_MEIPASS"):
|
||||||
|
bundled = Path(sys._MEIPASS) / "xlsx_clean"
|
||||||
|
if bundled.is_dir():
|
||||||
|
return bundled
|
||||||
|
return Path(sys._MEIPASS)
|
||||||
|
return Path(__file__).resolve().parent
|
||||||
|
|
||||||
|
|
||||||
|
PACKAGE_DIR = _package_dir()
|
||||||
|
|
||||||
def package_file(name: str) -> Path:
|
def package_file(name: str) -> Path:
|
||||||
return PACKAGE_DIR / name
|
return PACKAGE_DIR / name
|
||||||
|
|
||||||
|
def default_config_path() -> Path:
|
||||||
def get_opencloud_root() -> Path:
|
"""Resolve the default location for the TOML configuration file."""
|
||||||
"""Workbook tree root from XLSX_CLEAN_ROOT, else D:\\OpenCloud on Windows."""
|
if getattr(sys, "frozen", False):
|
||||||
env = os.environ.get("XLSX_CLEAN_ROOT")
|
return Path(sys.executable).resolve().parent / "config.toml"
|
||||||
if env:
|
return Path.home() / ".xlsx-clean" / "config.toml"
|
||||||
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_backend() -> str:
|
def default_backend() -> str:
|
||||||
return "com" if sys.platform == "win32" else "ooxml"
|
return "com" if sys.platform == "win32" else "ooxml"
|
||||||
|
|
||||||
|
|
||||||
def resolve_backend(requested: str | None) -> str:
|
def resolve_backend(requested: str | None, config_backend: str | None = None) -> str:
|
||||||
backend = (requested or default_backend()).lower()
|
"""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"}:
|
if backend not in {"com", "ooxml"}:
|
||||||
raise ValueError(f"Unknown backend {backend!r}; use 'com' or 'ooxml'")
|
raise ValueError(f"Unknown backend {backend!r}; use 'com' or 'ooxml'")
|
||||||
if backend == "com" and sys.platform != "win32":
|
if backend == "com" and sys.platform != "win32":
|
||||||
|
|||||||
@@ -1,141 +0,0 @@
|
|||||||
"""NiceGUI web UI for selecting set / ink / serial and creating a datasheet."""
|
|
||||||
|
|
||||||
from __future__ import annotations
|
|
||||||
|
|
||||||
import argparse
|
|
||||||
import sys
|
|
||||||
|
|
||||||
from nicegui import ui
|
|
||||||
|
|
||||||
from xlsx_clean.clean_cells import (
|
|
||||||
create_datasheet,
|
|
||||||
list_ink_colors,
|
|
||||||
list_sets,
|
|
||||||
load_config,
|
|
||||||
)
|
|
||||||
from xlsx_clean.paths import default_backend
|
|
||||||
|
|
||||||
|
|
||||||
def _build_page() -> None:
|
|
||||||
content, path_df = load_config()
|
|
||||||
q1, q2, q3 = content[0], content[1], content[2]
|
|
||||||
sets = list_sets(path_df)
|
|
||||||
initial_set = sets[0] if sets else None
|
|
||||||
initial_inks = list_ink_colors(path_df, initial_set) if initial_set else []
|
|
||||||
|
|
||||||
ui.page_title("xlsx-clean")
|
|
||||||
ui.colors(primary="#0f766e", secondary="#115e59", accent="#14b8a6")
|
|
||||||
|
|
||||||
with ui.column().classes("w-full max-w-xl mx-auto p-6 gap-4"):
|
|
||||||
ui.label("xlsx-clean").classes("text-3xl font-bold text-teal-800")
|
|
||||||
ui.label(
|
|
||||||
"Create a new QC datasheet from the latest matching workbook."
|
|
||||||
).classes("text-gray-600")
|
|
||||||
|
|
||||||
ink_ref: dict = {}
|
|
||||||
|
|
||||||
def on_set_change(e) -> None:
|
|
||||||
selected = e.value
|
|
||||||
inks = list_ink_colors(path_df, selected) if selected else []
|
|
||||||
ink = ink_ref["select"]
|
|
||||||
ink.options = inks
|
|
||||||
ink.value = inks[0] if inks else None
|
|
||||||
ink.update()
|
|
||||||
|
|
||||||
set_select = ui.select(
|
|
||||||
options=sets,
|
|
||||||
value=initial_set,
|
|
||||||
label=q1,
|
|
||||||
with_input=True,
|
|
||||||
on_change=on_set_change,
|
|
||||||
).classes("w-full")
|
|
||||||
|
|
||||||
ink_select = ui.select(
|
|
||||||
options=initial_inks,
|
|
||||||
value=initial_inks[0] if initial_inks else None,
|
|
||||||
label=q2,
|
|
||||||
with_input=True,
|
|
||||||
).classes("w-full")
|
|
||||||
ink_ref["select"] = ink_select
|
|
||||||
|
|
||||||
serial_input = ui.input(label=q3, placeholder="e.g. 1234/A").classes("w-full")
|
|
||||||
|
|
||||||
backend_select = ui.select(
|
|
||||||
options=["ooxml", "com"],
|
|
||||||
value=default_backend(),
|
|
||||||
label="Backend",
|
|
||||||
).classes("w-full")
|
|
||||||
if sys.platform != "win32":
|
|
||||||
ui.label(
|
|
||||||
"COM backend requires Windows with Microsoft Excel; use ooxml here."
|
|
||||||
).classes("text-sm text-amber-700")
|
|
||||||
|
|
||||||
status = ui.markdown("Ready.").classes("w-full p-3 rounded bg-gray-50")
|
|
||||||
|
|
||||||
def on_create() -> None:
|
|
||||||
result = create_datasheet(
|
|
||||||
selected_set=set_select.value or "",
|
|
||||||
selected_dir=ink_select.value or "",
|
|
||||||
batch_serial=serial_input.value or "",
|
|
||||||
backend=backend_select.value,
|
|
||||||
path_df=path_df,
|
|
||||||
addin_paths=content[3:5] if len(content) >= 5 else [],
|
|
||||||
)
|
|
||||||
lines = [result.message]
|
|
||||||
if result.template is not None:
|
|
||||||
lines.append(f"**Template:** `{result.template.name}`")
|
|
||||||
if result.destination is not None:
|
|
||||||
lines.append(f"**Output:** `{result.destination}`")
|
|
||||||
if result.backend is not None:
|
|
||||||
lines.append(f"**Backend:** `{result.backend}`")
|
|
||||||
status.set_content("\n\n".join(lines))
|
|
||||||
if result.ok and not result.skipped:
|
|
||||||
status.classes(replace="w-full p-3 rounded bg-teal-50")
|
|
||||||
elif result.skipped:
|
|
||||||
status.classes(replace="w-full p-3 rounded bg-amber-50")
|
|
||||||
else:
|
|
||||||
status.classes(replace="w-full p-3 rounded bg-red-50")
|
|
||||||
|
|
||||||
ui.button("Create datasheet", on_click=on_create).props("unelevated").classes(
|
|
||||||
"w-full"
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
def parse_args(argv: list[str] | None = None) -> argparse.Namespace:
|
|
||||||
parser = argparse.ArgumentParser(
|
|
||||||
description="Start the xlsx-clean NiceGUI web interface."
|
|
||||||
)
|
|
||||||
parser.add_argument(
|
|
||||||
"--host",
|
|
||||||
default="127.0.0.1",
|
|
||||||
help="Bind address (default: 127.0.0.1).",
|
|
||||||
)
|
|
||||||
parser.add_argument(
|
|
||||||
"--port",
|
|
||||||
type=int,
|
|
||||||
default=8080,
|
|
||||||
help="Port (default: 8080).",
|
|
||||||
)
|
|
||||||
parser.add_argument(
|
|
||||||
"--reload",
|
|
||||||
action="store_true",
|
|
||||||
help="Enable NiceGUI auto-reload (dev only).",
|
|
||||||
)
|
|
||||||
return parser.parse_args(argv)
|
|
||||||
|
|
||||||
|
|
||||||
def main(argv: list[str] | None = None) -> None:
|
|
||||||
args = parse_args(argv)
|
|
||||||
_build_page()
|
|
||||||
ui.run(
|
|
||||||
host=args.host,
|
|
||||||
port=args.port,
|
|
||||||
reload=args.reload,
|
|
||||||
title="xlsx-clean",
|
|
||||||
show=True,
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
if __name__ in {"__main__", "__mp_main__"}:
|
|
||||||
# NiceGUI may re-import as __mp_main__ when reload is enabled.
|
|
||||||
main()
|
|
||||||
259
uv.lock
generated
Normal file
259
uv.lock
generated
Normal file
@@ -0,0 +1,259 @@
|
|||||||
|
version = 1
|
||||||
|
revision = 3
|
||||||
|
requires-python = ">=3.12"
|
||||||
|
resolution-markers = [
|
||||||
|
"python_full_version >= '3.14' and sys_platform == 'win32'",
|
||||||
|
"python_full_version >= '3.14' and sys_platform == 'emscripten'",
|
||||||
|
"python_full_version >= '3.14' and sys_platform != 'emscripten' and sys_platform != 'win32'",
|
||||||
|
"python_full_version < '3.14' and sys_platform == 'win32'",
|
||||||
|
"python_full_version < '3.14' and sys_platform == 'emscripten'",
|
||||||
|
"python_full_version < '3.14' and sys_platform != 'emscripten' and sys_platform != 'win32'",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "altgraph"
|
||||||
|
version = "0.17.5"
|
||||||
|
source = { registry = "https://pypi.org/simple" }
|
||||||
|
sdist = { url = "https://files.pythonhosted.org/packages/7e/f8/97fdf103f38fed6792a1601dbc16cc8aac56e7459a9fff08c812d8ae177a/altgraph-0.17.5.tar.gz", hash = "sha256:c87b395dd12fabde9c99573a9749d67da8d29ef9de0125c7f536699b4a9bc9e7", size = 48428, upload-time = "2025-11-21T20:35:50.583Z" }
|
||||||
|
wheels = [
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/a9/ba/000a1996d4308bc65120167c21241a3b205464a2e0b58deda26ae8ac21d1/altgraph-0.17.5-py2.py3-none-any.whl", hash = "sha256:f3a22400bce1b0c701683820ac4f3b159cd301acab067c51c653e06961600597", size = 21228, upload-time = "2025-11-21T20:35:49.444Z" },
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "beaupy"
|
||||||
|
version = "3.12.0"
|
||||||
|
source = { registry = "https://pypi.org/simple" }
|
||||||
|
dependencies = [
|
||||||
|
{ name = "emoji" },
|
||||||
|
{ name = "python-yakh" },
|
||||||
|
{ name = "questo" },
|
||||||
|
{ name = "rich" },
|
||||||
|
]
|
||||||
|
sdist = { url = "https://files.pythonhosted.org/packages/80/65/6e501a432db02adb3c974473d73360880878797fbe25405c08024fa76bce/beaupy-3.12.0.tar.gz", hash = "sha256:e0ca6d2356b611ae734c8cf97b28ed9e3bb941d3207af2426e182da836a385d6", size = 16671, upload-time = "2026-05-21T19:10:01.649Z" }
|
||||||
|
wheels = [
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/5f/91/645739784ac1cda4eb4dfaeb7b31aa0fe949499e517c0a9616341bb8201d/beaupy-3.12.0-py3-none-any.whl", hash = "sha256:b3c1451c81ae329f91b27688faac0ae0f7ccbefc5ee97967a888582000d477c9", size = 15007, upload-time = "2026-05-21T19:10:00.595Z" },
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "dearpygui"
|
||||||
|
version = "2.3.1"
|
||||||
|
source = { registry = "https://pypi.org/simple" }
|
||||||
|
wheels = [
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/20/f1/6f30c7eafa25755105d0c26049a95c89cc5c82b68971e1cc8ffea36b748a/dearpygui-2.3.1-cp312-cp312-macosx_13_0_arm64.whl", hash = "sha256:6b1efd675a358176b3b76c039587a543d407d8fbb2cc3643a527e0ab7c0f5577", size = 2002717, upload-time = "2026-05-01T22:46:00.242Z" },
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/cc/03/fa76c31087b6ebbc13948de6d9d3bc9ed9946824b13d9d1089356b54249c/dearpygui-2.3.1-cp312-cp312-manylinux1_x86_64.whl", hash = "sha256:364b5b6a0953999fec764d529d9bb0b2cc6ab6ed06188e0ded28237c1475ca98", size = 2678552, upload-time = "2026-05-01T22:46:07.502Z" },
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/f2/ef/657ec68a79664cd28d98d590eed85103c6ffc1e23e7d3c4e5aedb7ee887d/dearpygui-2.3.1-cp312-cp312-manylinux2014_aarch64.whl", hash = "sha256:199dffebda245c9f59aa7c10c3b7f62963237c5f744150ad9be409b27a2661d3", size = 2501224, upload-time = "2026-05-01T22:46:18.8Z" },
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/77/be/e67e5a04439f15e60cf596092a31b2a907272288954e47f5ced43c0b1678/dearpygui-2.3.1-cp312-cp312-win_amd64.whl", hash = "sha256:26ed9197cdb30099c665bd1b23724e0dba60ad06b71344ecca7e52748c21874b", size = 1882080, upload-time = "2026-05-01T22:45:49.366Z" },
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/42/db/56a293ad392b8dafdd3eb1a0c4d367efbde99aa6930359685fe270984dd1/dearpygui-2.3.1-cp313-cp313-macosx_13_0_arm64.whl", hash = "sha256:d2d29e72b031886893b32269e1478eff1fd651512e6c2bceda91059c3bc8ee0e", size = 2002694, upload-time = "2026-05-01T22:46:01.425Z" },
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/cc/e0/df598671f40a7fffb8390946115d9e9cf12d3f4a52f5b9381bddc5699aee/dearpygui-2.3.1-cp313-cp313-manylinux1_x86_64.whl", hash = "sha256:e3f64c8d4cae68a3b5be1b7531d08400ccbf1e4ff03c7acfc85954f98993f864", size = 2678564, upload-time = "2026-05-01T22:46:08.706Z" },
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/d0/d1/87cfb577d4a1615e809e2f6e0fd720bd4ad6cd25e365ef2fd08a6e09c86e/dearpygui-2.3.1-cp313-cp313-manylinux2014_aarch64.whl", hash = "sha256:0d8b7a5a04cd4a6e25dbf162aa0405cf12143a1c82b33e371c20e5ba8d9349f3", size = 2503196, upload-time = "2026-05-01T22:46:20.276Z" },
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/b3/38/05f74181a59353bdc927b6ec46333714f633c5755f3d4bcda34d6eb100a5/dearpygui-2.3.1-cp313-cp313-win_amd64.whl", hash = "sha256:7946722c50f1e08866dfdb78eb33dd4e67dea1a3cfe4400b159e1c96861116dc", size = 1882082, upload-time = "2026-05-01T22:45:50.915Z" },
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/4a/08/68ce3ba941cf09bcf288f2603d7178c936d473172fd545e0665b885cb840/dearpygui-2.3.1-cp314-cp314-macosx_13_0_arm64.whl", hash = "sha256:e2cbabd8d383308ea3520360e100d1e95c9a957cd26247431cd4920b23c3b56e", size = 2003034, upload-time = "2026-05-01T22:46:02.736Z" },
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/f3/3f/ac003b6d636c9f5aae910a62d00b6c119403212cf2d7772d7c59ca8ef6dd/dearpygui-2.3.1-cp314-cp314-manylinux1_x86_64.whl", hash = "sha256:953442c7272e57f3686e393edc5cf6ce73cc2f47142739735dfabed403e33770", size = 2678545, upload-time = "2026-05-01T22:46:10.181Z" },
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/1a/6b/657a2f1e2f604f356c39ed5b870aaed5d07fdeac3139fae2a455473b64ca/dearpygui-2.3.1-cp314-cp314-manylinux2014_aarch64.whl", hash = "sha256:43a561b5dc589944a3a2b469e5e68f1ab35ae38b3dcdf1f813ed9d6e024153f8", size = 2501699, upload-time = "2026-05-01T22:46:21.497Z" },
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/8c/56/93b2310891589063e0226cb07fe05e08fbdb3f409f80f9edefb1cebea84e/dearpygui-2.3.1-cp314-cp314-win_amd64.whl", hash = "sha256:272cc52c66bc5a4a332f13a3af5e603070d47ca7cc4976e6a8c247594e2b3dd0", size = 1943067, upload-time = "2026-05-01T22:45:52.255Z" },
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "emoji"
|
||||||
|
version = "2.15.0"
|
||||||
|
source = { registry = "https://pypi.org/simple" }
|
||||||
|
sdist = { url = "https://files.pythonhosted.org/packages/a2/78/0d2db9382c92a163d7095fc08efff7800880f830a152cfced40161e7638d/emoji-2.15.0.tar.gz", hash = "sha256:eae4ab7d86456a70a00a985125a03263a5eac54cd55e51d7e184b1ed3b6757e4", size = 615483, upload-time = "2025-09-21T12:13:02.755Z" }
|
||||||
|
wheels = [
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/e1/5e/4b5aaaabddfacfe36ba7768817bd1f71a7a810a43705e531f3ae4c690767/emoji-2.15.0-py3-none-any.whl", hash = "sha256:205296793d66a89d88af4688fa57fd6496732eb48917a87175a023c8138995eb", size = 608433, upload-time = "2025-09-21T12:13:01.197Z" },
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "macholib"
|
||||||
|
version = "1.16.4"
|
||||||
|
source = { registry = "https://pypi.org/simple" }
|
||||||
|
dependencies = [
|
||||||
|
{ name = "altgraph", marker = "sys_platform != 'emscripten' and sys_platform != 'win32'" },
|
||||||
|
]
|
||||||
|
sdist = { url = "https://files.pythonhosted.org/packages/10/2f/97589876ea967487978071c9042518d28b958d87b17dceb7cdc1d881f963/macholib-1.16.4.tar.gz", hash = "sha256:f408c93ab2e995cd2c46e34fe328b130404be143469e41bc366c807448979362", size = 59427, upload-time = "2025-11-22T08:28:38.373Z" }
|
||||||
|
wheels = [
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/c7/d1/a9f36f8ecdf0fb7c9b1e78c8d7af12b8c8754e74851ac7b94a8305540fc7/macholib-1.16.4-py2.py3-none-any.whl", hash = "sha256:da1a3fa8266e30f0ce7e97c6a54eefaae8edd1e5f86f3eb8b95457cae90265ea", size = 38117, upload-time = "2025-11-22T08:28:36.939Z" },
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "markdown-it-py"
|
||||||
|
version = "4.2.0"
|
||||||
|
source = { registry = "https://pypi.org/simple" }
|
||||||
|
dependencies = [
|
||||||
|
{ name = "mdurl" },
|
||||||
|
]
|
||||||
|
sdist = { url = "https://files.pythonhosted.org/packages/06/ff/7841249c247aa650a76b9ee4bbaeae59370dc8bfd2f6c01f3630c35eb134/markdown_it_py-4.2.0.tar.gz", hash = "sha256:04a21681d6fbb623de53f6f364d352309d4094dd4194040a10fd51833e418d49", size = 82454, upload-time = "2026-05-07T12:08:28.36Z" }
|
||||||
|
wheels = [
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/b3/81/4da04ced5a082363ecfa159c010d200ecbd959ae410c10c0264a38cac0f5/markdown_it_py-4.2.0-py3-none-any.whl", hash = "sha256:9f7ebbcd14fe59494226453aed97c1070d83f8d24b6fc3a3bcf9a38092641c4a", size = 91687, upload-time = "2026-05-07T12:08:27.182Z" },
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "mdurl"
|
||||||
|
version = "0.1.2"
|
||||||
|
source = { registry = "https://pypi.org/simple" }
|
||||||
|
sdist = { url = "https://files.pythonhosted.org/packages/d6/54/cfe61301667036ec958cb99bd3efefba235e65cdeb9c84d24a8293ba1d90/mdurl-0.1.2.tar.gz", hash = "sha256:bb413d29f5eea38f31dd4754dd7377d4465116fb207585f97bf925588687c1ba", size = 8729, upload-time = "2022-08-14T12:40:10.846Z" }
|
||||||
|
wheels = [
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/b3/38/89ba8ad64ae25be8de66a6d463314cf1eb366222074cfda9ee839c56a4b4/mdurl-0.1.2-py3-none-any.whl", hash = "sha256:84008a41e51615a49fc9966191ff91509e3c40b939176e643fd50a5c2196b8f8", size = 9979, upload-time = "2022-08-14T12:40:09.779Z" },
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "packaging"
|
||||||
|
version = "26.2"
|
||||||
|
source = { registry = "https://pypi.org/simple" }
|
||||||
|
sdist = { url = "https://files.pythonhosted.org/packages/d7/f1/e7a6dd94a8d4a5626c03e4e99c87f241ba9e350cd9e6d75123f992427270/packaging-26.2.tar.gz", hash = "sha256:ff452ff5a3e828ce110190feff1178bb1f2ea2281fa2075aadb987c2fb221661", size = 228134, upload-time = "2026-04-24T20:15:23.917Z" }
|
||||||
|
wheels = [
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/df/b2/87e62e8c3e2f4b32e5fe99e0b86d576da1312593b39f47d8ceef365e95ed/packaging-26.2-py3-none-any.whl", hash = "sha256:5fc45236b9446107ff2415ce77c807cee2862cb6fac22b8a73826d0693b0980e", size = 100195, upload-time = "2026-04-24T20:15:22.081Z" },
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "pefile"
|
||||||
|
version = "2024.8.26"
|
||||||
|
source = { registry = "https://pypi.org/simple" }
|
||||||
|
sdist = { url = "https://files.pythonhosted.org/packages/03/4f/2750f7f6f025a1507cd3b7218691671eecfd0bbebebe8b39aa0fe1d360b8/pefile-2024.8.26.tar.gz", hash = "sha256:3ff6c5d8b43e8c37bb6e6dd5085658d658a7a0bdcd20b6a07b1fcfc1c4e9d632", size = 76008, upload-time = "2024-08-26T20:58:38.155Z" }
|
||||||
|
wheels = [
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/54/16/12b82f791c7f50ddec566873d5bdd245baa1491bac11d15ffb98aecc8f8b/pefile-2024.8.26-py3-none-any.whl", hash = "sha256:76f8b485dcd3b1bb8166f1128d395fa3d87af26360c2358fb75b80019b957c6f", size = 74766, upload-time = "2024-08-26T21:01:02.632Z" },
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "pygments"
|
||||||
|
version = "2.20.0"
|
||||||
|
source = { registry = "https://pypi.org/simple" }
|
||||||
|
sdist = { url = "https://files.pythonhosted.org/packages/c3/b2/bc9c9196916376152d655522fdcebac55e66de6603a76a02bca1b6414f6c/pygments-2.20.0.tar.gz", hash = "sha256:6757cd03768053ff99f3039c1a36d6c0aa0b263438fcab17520b30a303a82b5f", size = 4955991, upload-time = "2026-03-29T13:29:33.898Z" }
|
||||||
|
wheels = [
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/f4/7e/a72dd26f3b0f4f2bf1dd8923c85f7ceb43172af56d63c7383eb62b332364/pygments-2.20.0-py3-none-any.whl", hash = "sha256:81a9e26dd42fd28a23a2d169d86d7ac03b46e2f8b59ed4698fb4785f946d0176", size = 1231151, upload-time = "2026-03-29T13:29:30.038Z" },
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "pyinstaller"
|
||||||
|
version = "6.21.0"
|
||||||
|
source = { registry = "https://pypi.org/simple" }
|
||||||
|
dependencies = [
|
||||||
|
{ name = "altgraph" },
|
||||||
|
{ name = "macholib", marker = "sys_platform == 'darwin'" },
|
||||||
|
{ name = "packaging" },
|
||||||
|
{ name = "pefile", marker = "sys_platform == 'win32'" },
|
||||||
|
{ name = "pyinstaller-hooks-contrib" },
|
||||||
|
{ name = "pywin32-ctypes", marker = "sys_platform == 'win32'" },
|
||||||
|
{ name = "setuptools" },
|
||||||
|
]
|
||||||
|
sdist = { url = "https://files.pythonhosted.org/packages/d5/4d/ec706c3fcf39e26888c35b39615ff4d5865d184069666c47492cff1fbe50/pyinstaller-6.21.0.tar.gz", hash = "sha256:bb9fab705983e393a2d1cac77d6972513057ad800215fd861dc15ff5272e98fd", size = 4061519, upload-time = "2026-06-13T14:15:06.25Z" }
|
||||||
|
wheels = [
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/0c/4a/53cf98bf66daed012dc9cd78c8203f19a675d696f2fc12afcf8c5049a0e0/pyinstaller-6.21.0-py3-none-macosx_10_13_universal2.whl", hash = "sha256:327d132389f37912609e01be62810cf96b5aa95b613903e4b8692e0d12fb0eda", size = 1052350, upload-time = "2026-06-13T14:13:55.88Z" },
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/30/83/b591295c352ef464c50b4c6ffff1c4f771d875c9e833f578d1b9f564f6b3/pyinstaller-6.21.0-py3-none-manylinux2014_aarch64.whl", hash = "sha256:7071d4b094d5b40deeef5fa3d3b98a1b846087f7562b49209663d5f9281fe251", size = 748477, upload-time = "2026-06-13T14:14:00.327Z" },
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/3d/8f/88fff4e403873b1e22286911350e75ff00db014aa08e57045da9d4328993/pyinstaller-6.21.0-py3-none-manylinux2014_i686.whl", hash = "sha256:6b6374d652107dd4a2eeece903ff82bb4045bb5e1006c5a158a6dcdbefe84bf2", size = 760877, upload-time = "2026-06-13T14:14:04.836Z" },
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/8a/13/f0e48fbdfd1d05d948157121cea8b1b823dcb89efe6934b71fdd8bdb3f0f/pyinstaller-6.21.0-py3-none-manylinux2014_ppc64le.whl", hash = "sha256:4e3108b3f02384560da70e39b8bf22b0ad597d02bd68a40d76ea91c1cfa00cad", size = 759194, upload-time = "2026-06-13T14:14:10.61Z" },
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/dd/d5/ea7878cf9924ed30d946d8288777424e6d069d94f5bde56b4d0890069664/pyinstaller-6.21.0-py3-none-manylinux2014_s390x.whl", hash = "sha256:697532279f535ad572bda613db4f821540e235c7854ca6da4d3bf0373f4415ee", size = 754979, upload-time = "2026-06-13T14:14:15.226Z" },
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/9f/09/51b8905714b733bac66dbc041a7821372d70d888d273ae474c4037d4202d/pyinstaller-6.21.0-py3-none-manylinux2014_x86_64.whl", hash = "sha256:605169523a6b5ace39f13dfbff21add9f2bc43df99c7daf9394fefb2c45e8b6f", size = 754812, upload-time = "2026-06-13T14:14:20.264Z" },
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/4b/43/d77779439d8c6c2e27a77bcfbd1d5cc0f568ebb611bb472b11af81b5f177/pyinstaller-6.21.0-py3-none-musllinux_1_1_aarch64.whl", hash = "sha256:5fa56746c1e76f93634d018502301378a2d0c382553d37d8c3c34ff436c12dd1", size = 753887, upload-time = "2026-06-13T14:14:25.268Z" },
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/51/8f/c22df1f6837784ac349057ba693f08e7b1ca7a0e06f9c33c63bc6280007b/pyinstaller-6.21.0-py3-none-musllinux_1_1_x86_64.whl", hash = "sha256:42395ec76df8e8120c36b13339d9db8cab83e316a12839ee303cc00fc941bb74", size = 753779, upload-time = "2026-06-13T14:14:29.445Z" },
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/c9/76/1ce8a27ce62ba8cf3a87c9ce6d575610f4e55d7cb0123e7512fc3f4b921a/pyinstaller-6.21.0-py3-none-win32.whl", hash = "sha256:c6b28d30d8fd99ce162ff3aab5013ed44dbfb747566b1f01b9bed7964d7c14e9", size = 1336462, upload-time = "2026-06-13T14:14:35.785Z" },
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/c1/fa/ca1d7e5257dd8566a9dfc0dfb02f8a8075eeb53d4b2d3c579f1276759042/pyinstaller-6.21.0-py3-none-win_amd64.whl", hash = "sha256:7fae06c494ce0ebfe6bd3055c0e409def884f63af2e3705d06bd431ad9237fc7", size = 1397487, upload-time = "2026-06-13T14:14:42.328Z" },
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/dc/75/21b51523ce8d96629b71311775a0a65f5f5a872124ab0de33e5c848f8bff/pyinstaller-6.21.0-py3-none-win_arm64.whl", hash = "sha256:f13c95c9c03fb567217135919f93815c305813126780b0ed6e0123cb8acaf025", size = 1346094, upload-time = "2026-06-13T14:14:48.914Z" },
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "pyinstaller-hooks-contrib"
|
||||||
|
version = "2026.6"
|
||||||
|
source = { registry = "https://pypi.org/simple" }
|
||||||
|
dependencies = [
|
||||||
|
{ name = "packaging" },
|
||||||
|
]
|
||||||
|
sdist = { url = "https://files.pythonhosted.org/packages/94/5b/c9fe0db5e83ee1c39b2258fa21d23b15e1a60786b6c5990ee5074ead8bb6/pyinstaller_hooks_contrib-2026.6.tar.gz", hash = "sha256:bef5002c32f4f50bd55b005da12cff64eca8783e7eaf86a06a62410164bab725", size = 173354, upload-time = "2026-06-08T22:37:16.152Z" }
|
||||||
|
wheels = [
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/e7/31/f2d7343d8ed5f7c4678377886f6ce533e6eaaa131b252ce950114c2a7efa/pyinstaller_hooks_contrib-2026.6-py3-none-any.whl", hash = "sha256:fd13b8ac126b35361175edacd41a0d97080b75dd5f4b594ecefefff969509dd3", size = 457159, upload-time = "2026-06-08T22:37:14.722Z" },
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "python-yakh"
|
||||||
|
version = "0.4.1"
|
||||||
|
source = { registry = "https://pypi.org/simple" }
|
||||||
|
sdist = { url = "https://files.pythonhosted.org/packages/d2/77/bbff0a1e6fb03b8cc2cc373a44cfbbb4fd22863c657f8630f4a0f5eb207c/python_yakh-0.4.1.tar.gz", hash = "sha256:da03e800b4f2f5d85344f1668e852687c12dc1a99a03c65cf3dc13a3680da49d", size = 3988, upload-time = "2025-01-14T18:08:15.767Z" }
|
||||||
|
wheels = [
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/22/42/72571b24514b5f59c328f12e5294b246958951b889fac2bd5321e08a4bab/python_yakh-0.4.1-py3-none-any.whl", hash = "sha256:d69507e13e03d09cefd88030f74b6d5369b67de004be975a35be28eb286122e4", size = 5826, upload-time = "2025-01-14T18:08:13.618Z" },
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "pywin32"
|
||||||
|
version = "312"
|
||||||
|
source = { registry = "https://pypi.org/simple" }
|
||||||
|
wheels = [
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/83/ff/32aa7d2ed0ab12b323aaa64f9b75e6ad4f8fd09f9ccfc28c79414d46838d/pywin32-312-cp312-cp312-win32.whl", hash = "sha256:dab4f65ac9c4e48400a2a0530c46c3c579cd5905ecd11b80692373915269208b", size = 6371877, upload-time = "2026-06-04T07:49:28.836Z" },
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/03/d9/77040d3b43df3f3be32ea289433d660d2727f5ba327bc73be835127d9d60/pywin32-312-cp312-cp312-win_amd64.whl", hash = "sha256:b457f6d628a47e8a7346ce22acb7e1a46a4a78b52e1d17e1af56871bd19a93bc", size = 6914841, upload-time = "2026-06-04T07:49:31.85Z" },
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/e3/cc/7b1ec671775756020a0ee7f4feeaf3c568f0ab86bd3900088cf986937a92/pywin32-312-cp312-cp312-win_arm64.whl", hash = "sha256:6017c58e12f6809fbb0555b75df144c2922a9ffd18e4b9b5afa863b6c1a9d950", size = 6727901, upload-time = "2026-06-04T07:49:34.244Z" },
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/2d/41/12fbfd7f36ed2146d8bc9de96c2741296bf0d490b98508496cff322e274c/pywin32-312-cp313-cp313-win32.whl", hash = "sha256:7a27df850933d16a8eabfbaeb73d52b273e2da667f80d70b01a89d1f6828d02c", size = 6370184, upload-time = "2026-06-04T07:49:36.253Z" },
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/ba/db/36a78e3403099d31d9746d13fdcde5accc43c1155f375a34d15983a479a7/pywin32-312-cp313-cp313-win_amd64.whl", hash = "sha256:c53e878d15a1c44788082bfe712a905433473aa38f86375b7cf8b45e3acbaaf9", size = 6914298, upload-time = "2026-06-04T07:49:38.876Z" },
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/84/37/c1697194092b76de9ed47ca124323f02c57ffc8a45c06f88a3d5acaf01eb/pywin32-312-cp313-cp313-win_arm64.whl", hash = "sha256:59aba5d5940842075343a5ddc6b11f1cdf0d1567fe745290359dfbcc7c2eb831", size = 6727640, upload-time = "2026-06-04T07:49:41.083Z" },
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/fc/2b/1f3cded5822fd49c02f40544cbb5f58c7cfd6b1694869fd476cb6170ee97/pywin32-312-cp314-cp314-win32.whl", hash = "sha256:a77a90fbb6881238d2ca9c6fd797b25817f3768fe78d214a90137ff055a75f5b", size = 6468928, upload-time = "2026-06-04T07:49:43.188Z" },
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/21/82/3bf86d2e2808902013132e1ce905a7da0da53790f3836c64bf44d55e24f3/pywin32-312-cp314-cp314-win_amd64.whl", hash = "sha256:a4dd3a848290ef724347b19f301045831d8e802fa4464f491b98b1e0a081432e", size = 7024157, upload-time = "2026-06-04T07:49:45.34Z" },
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/a4/0e/73f6d6800b4f27655abd9e9f6aaeaefcddb2b946e4674efa2bab184a7f7b/pywin32-312-cp314-cp314-win_arm64.whl", hash = "sha256:9fce94568364e0155e6dfb781ac5d95903be8baf28670632beab1b523f300daa", size = 6839598, upload-time = "2026-06-04T07:49:47.613Z" },
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/eb/61/caa39686032d2ebdd04ff0ab5cbe163126c0066d98e00c9018646e42393b/pywin32-312-cp315-cp315-win32.whl", hash = "sha256:5c1fbe4a937a73ae9297384a3da38518cbc694c68ad8a809b2e19acd350f03ed", size = 6471159, upload-time = "2026-06-04T07:49:50.035Z" },
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/0f/cd/7e1de64a4a6f69c04214169657ccab0d93a670ea50e35eb8f489d7378249/pywin32-312-cp315-cp315-win_amd64.whl", hash = "sha256:c2f03a0f73f804a13c2735b99392b0cd426bb4f2c4d0178e5ac966a0f21618d5", size = 7025293, upload-time = "2026-06-04T07:49:54.857Z" },
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/23/ed/4532e9388e65fa16b46776ef47ad631a64eda1631884488af707666350ed/pywin32-312-cp315-cp315-win_arm64.whl", hash = "sha256:a8597d28f267b39074aef51fa593530082b39cbe5a074226096857b1fed2dfb9", size = 6840337, upload-time = "2026-06-04T07:49:57.531Z" },
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "pywin32-ctypes"
|
||||||
|
version = "0.2.3"
|
||||||
|
source = { registry = "https://pypi.org/simple" }
|
||||||
|
sdist = { url = "https://files.pythonhosted.org/packages/85/9f/01a1a99704853cb63f253eea009390c88e7131c67e66a0a02099a8c917cb/pywin32-ctypes-0.2.3.tar.gz", hash = "sha256:d162dc04946d704503b2edc4d55f3dba5c1d539ead017afa00142c38b9885755", size = 29471, upload-time = "2024-08-14T10:15:34.626Z" }
|
||||||
|
wheels = [
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/de/3d/8161f7711c017e01ac9f008dfddd9410dff3674334c233bde66e7ba65bbf/pywin32_ctypes-0.2.3-py3-none-any.whl", hash = "sha256:8a1513379d709975552d202d942d9837758905c8d01eb82b8bcc30918929e7b8", size = 30756, upload-time = "2024-08-14T10:15:33.187Z" },
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "questo"
|
||||||
|
version = "0.4.2"
|
||||||
|
source = { registry = "https://pypi.org/simple" }
|
||||||
|
dependencies = [
|
||||||
|
{ name = "python-yakh" },
|
||||||
|
{ name = "rich" },
|
||||||
|
]
|
||||||
|
sdist = { url = "https://files.pythonhosted.org/packages/a8/e6/4a86ccd5710c2fddae92786f15f2c69637b417905ff239d7424b55e342cb/questo-0.4.2.tar.gz", hash = "sha256:bcc917c2f1a65872e2bd02e79e226a716fd2d68a1ebe0d23c1828aa116aa6da6", size = 10474, upload-time = "2025-11-30T13:08:59.403Z" }
|
||||||
|
wheels = [
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/04/9e/2669ac7d718539a3783c3a6c440b3440b68193b59d763d7f89d33c0b1e8e/questo-0.4.2-py3-none-any.whl", hash = "sha256:1afce34a638601b54fbd697e99e7551813fafb513fe523165394eb12f9607b43", size = 12442, upload-time = "2025-11-30T13:08:57.602Z" },
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "rich"
|
||||||
|
version = "15.0.0"
|
||||||
|
source = { registry = "https://pypi.org/simple" }
|
||||||
|
dependencies = [
|
||||||
|
{ name = "markdown-it-py" },
|
||||||
|
{ name = "pygments" },
|
||||||
|
]
|
||||||
|
sdist = { url = "https://files.pythonhosted.org/packages/c0/8f/0722ca900cc807c13a6a0c696dacf35430f72e0ec571c4275d2371fca3e9/rich-15.0.0.tar.gz", hash = "sha256:edd07a4824c6b40189fb7ac9bc4c52536e9780fbbfbddf6f1e2502c31b068c36", size = 230680, upload-time = "2026-04-12T08:24:00.75Z" }
|
||||||
|
wheels = [
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/82/3b/64d4899d73f91ba49a8c18a8ff3f0ea8f1c1d75481760df8c68ef5235bf5/rich-15.0.0-py3-none-any.whl", hash = "sha256:33bd4ef74232fb73fe9279a257718407f169c09b78a87ad3d296f548e27de0bb", size = 310654, upload-time = "2026-04-12T08:24:02.83Z" },
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "setuptools"
|
||||||
|
version = "83.0.0"
|
||||||
|
source = { registry = "https://pypi.org/simple" }
|
||||||
|
sdist = { url = "https://files.pythonhosted.org/packages/34/26/f5d29e25ffdb535afef2d35cdb55b325298f96debd670da4c325e08d70f4/setuptools-83.0.0.tar.gz", hash = "sha256:025bccbbf0fa05b6192bc64ae1e7b16e001fd6d6d4d5de03c97b1c1ade523bef", size = 1154254, upload-time = "2026-07-04T15:31:22.699Z" }
|
||||||
|
wheels = [
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/5d/40/e1e72872c6354b306daef1703549e8e83b4d43cfea356311bf722a043752/setuptools-83.0.0-py3-none-any.whl", hash = "sha256:29b23c360f22f414dc7336bb39178cc7bcbf6021ed2733cde173f09dba19abb3", size = 1008090, upload-time = "2026-07-04T15:31:20.885Z" },
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "xlsx-clean"
|
||||||
|
version = "0.3.0"
|
||||||
|
source = { editable = "." }
|
||||||
|
dependencies = [
|
||||||
|
{ name = "beaupy" },
|
||||||
|
{ name = "dearpygui" },
|
||||||
|
{ name = "pywin32", marker = "sys_platform == 'win32'" },
|
||||||
|
]
|
||||||
|
|
||||||
|
[package.optional-dependencies]
|
||||||
|
desktop = [
|
||||||
|
{ name = "pyinstaller" },
|
||||||
|
]
|
||||||
|
|
||||||
|
[package.metadata]
|
||||||
|
requires-dist = [
|
||||||
|
{ name = "beaupy", specifier = ">=3.12.0" },
|
||||||
|
{ name = "dearpygui", specifier = ">=2.0.0" },
|
||||||
|
{ name = "pyinstaller", marker = "extra == 'desktop'", specifier = ">=6.21.0" },
|
||||||
|
{ name = "pywin32", marker = "sys_platform == 'win32'", specifier = ">=312" },
|
||||||
|
]
|
||||||
|
provides-extras = ["desktop"]
|
||||||
Reference in New Issue
Block a user