Compare commits
23 Commits
cursor/ui-
...
cursor/aut
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
8ee6cebea3 | ||
| a07d3b46dc | |||
|
|
78d1a0a5fc | ||
| 89bb9689e9 | |||
|
|
86d0006291 | ||
| 8443149979 | |||
|
|
3a0e02d9e0 | ||
|
|
19b81201b8 | ||
| f1b99e5da9 | |||
|
|
7cc3a350cd | ||
| 34a68b4e22 | |||
| 61f1a737a4 | |||
| f0a004b637 | |||
| 7e305f18be | |||
| 6b2d13272f | |||
| 8f5d0d24c9 | |||
| 911e6f3612 | |||
| 0fc5eecfb4 | |||
| b389a13add | |||
| 5fb66a2794 | |||
| 9e317e41df | |||
| d5f1a563e2 | |||
| a9f1e90fc1 |
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,6 +1,6 @@
|
||||
[project]
|
||||
name = "xlsx-clean"
|
||||
version = "0.1.0"
|
||||
version = "0.2.0"
|
||||
description = "Create a new QC datasheet from the latest matching workbook"
|
||||
authors = [
|
||||
{ name = "Diaco Soltanpour", email = "dyaco8464@yahoo.com" }
|
||||
@@ -41,3 +41,19 @@ packages = ["src/xlsx_clean"]
|
||||
|
||||
[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}"'
|
||||
|
||||
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
|
||||
@@ -13,6 +13,7 @@ import pandas
|
||||
from beaupy import prompt, select
|
||||
from rich.console import Console
|
||||
|
||||
from xlsx_clean.app_logging import get_logger
|
||||
from xlsx_clean.paths import (
|
||||
default_backend,
|
||||
get_opencloud_root,
|
||||
@@ -89,19 +90,32 @@ def create_datasheet(
|
||||
|
||||
Shared by the CLI and the NiceGUI web UI.
|
||||
"""
|
||||
log = get_logger()
|
||||
ctx = f"set={selected_set!r} ink={selected_dir!r} serial={batch_serial!r}"
|
||||
|
||||
if not selected_set:
|
||||
return CreateResult(ok=False, message="Select a set.")
|
||||
message = "Select a set."
|
||||
log.error("Create failed: %s (%s)", message, ctx)
|
||||
return CreateResult(ok=False, message=message)
|
||||
if not selected_dir:
|
||||
return CreateResult(ok=False, message="Select an ink color.")
|
||||
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():
|
||||
return CreateResult(ok=False, message="Enter a serial.")
|
||||
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}"
|
||||
try:
|
||||
resolved_backend = resolve_backend(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}"
|
||||
|
||||
if path_df is None or addin_paths is None:
|
||||
content, loaded_df = load_config()
|
||||
if path_df is None:
|
||||
@@ -114,10 +128,9 @@ def create_datasheet(
|
||||
& (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}.",
|
||||
)
|
||||
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.iloc[0]
|
||||
path_ = Path(row["dir"])
|
||||
@@ -125,9 +138,11 @@ def create_datasheet(
|
||||
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=f"No workbooks matching {search_pattern!r} in {path_}",
|
||||
message=message,
|
||||
backend=resolved_backend,
|
||||
)
|
||||
|
||||
@@ -137,10 +152,18 @@ def create_datasheet(
|
||||
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=f"Destination already exists, skipped: {new_workbook_name}",
|
||||
message=message,
|
||||
template=template,
|
||||
destination=new_workbook_name,
|
||||
backend=resolved_backend,
|
||||
@@ -180,17 +203,33 @@ def create_datasheet(
|
||||
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=f"Failed to create workbook: {exc}",
|
||||
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=f"Wrote {new_workbook_name}",
|
||||
message=message,
|
||||
template=template,
|
||||
destination=new_workbook_name,
|
||||
backend=resolved_backend,
|
||||
|
||||
@@ -6,7 +6,7 @@ dir,pattern,set_name,cells_to_clear,serial_cell,notes_cell
|
||||
"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"
|
||||
"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"
|
||||
"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"
|
||||
"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"
|
||||
"D:\OpenCloud\Kimia Razi\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"
|
||||
"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"
|
||||
"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"
|
||||
|
||||
|
@@ -26,7 +26,7 @@ def _app_version() -> str:
|
||||
try:
|
||||
return package_version(_PACKAGE_NAME)
|
||||
except PackageNotFoundError:
|
||||
return "0.1.0"
|
||||
return "dev"
|
||||
|
||||
|
||||
def _app_title(version: str | None = None) -> str:
|
||||
|
||||
Reference in New Issue
Block a user