From 4b4cf9aae81f9b210025c7e11d169270900a0a4c Mon Sep 17 00:00:00 2001 From: diaco Date: Wed, 23 Sep 2026 11:28:13 +0330 Subject: [PATCH] Use note: lines for HTML metadata, not # comments Co-authored-by: Cursor --- README.md | 10 ++++++---- auto-scan.sh | 7 ++++--- average-results.py | 14 ++++++++++---- measure.sh | 3 ++- prompt-next-sample.py | 10 ++++++---- run-measurement.sh | 6 ++++-- samples.example.txt | 11 +++++++---- tsv-to-csv.py | 10 ++++++---- 8 files changed, 45 insertions(+), 26 deletions(-) diff --git a/README.md b/README.md index 23f9971..2973d1b 100644 --- a/README.md +++ b/README.md @@ -86,12 +86,14 @@ material codes); copy the template to create your own: cp samples.example.txt samples.txt ``` -Lines starting with `#` are ignored. Material names can be any codes. -Append ` > REF` to measure that sample's `dE00` against another sample; a -bare name (no `>`) is itself a **reference**. Mix samples use the pattern -`NAME_A+NAME_B[w1 to w2 mix]`, e.g.: +Lines starting with `#` are comments. Lines starting with `note:` are +metadata shown above the table in `averaged.html` (not samples). Material +names can be any codes. Append ` > REF` to measure that sample's `dE00` +against another sample; a bare name (no `>`) is itself a **reference**. +Mix samples use the pattern `NAME_A+NAME_B[w1 to w2 mix]`, e.g.: ```text +note: Glaze: CPO1192 INK_A INK_B > INK_A INK_A+INK_B[75 to 15 mix] > INK_A diff --git a/auto-scan.sh b/auto-scan.sh index 70168a4..6fd0310 100755 --- a/auto-scan.sh +++ b/auto-scan.sh @@ -133,8 +133,8 @@ scan_samples() { SAMPLES=() while IFS= read -r line; do SAMPLES+=("$line") - done < <(grep -v '^#' "$SAMPLES_FILE" | grep -v '^[[:space:]]*$' \ - | sed -E 's/[[:space:]]*>.*$//') + done < <(grep -v '^#' "$SAMPLES_FILE" | grep -iv '^[[:space:]]*note:' \ + | grep -v '^[[:space:]]*$' | sed -E 's/[[:space:]]*>.*$//') local count="${#SAMPLES[@]}" [[ "$count" -gt 0 ]] || fail "No sample names found in $SAMPLES_FILE" @@ -190,7 +190,8 @@ update_average() { info "Step 5/5: Updating $AVERAGED_CSV" local expected - expected="$(grep -v '^#' "$SAMPLES_FILE" | grep -cv '^[[:space:]]*$' || true)" + expected="$(grep -v '^#' "$SAMPLES_FILE" | grep -iv '^[[:space:]]*note:' \ + | grep -cv '^[[:space:]]*$' || true)" # Collect scan CSVs (timestamped files only) with the expected reading count local -a scans=() diff --git a/average-results.py b/average-results.py index 8aca1e7..3c4f6e5 100755 --- a/average-results.py +++ b/average-results.py @@ -20,18 +20,22 @@ WHITE_POINT = (96.422, 100.0, 82.521) # (no ">") are references themselves. The " > REF" suffix is stripped to # recover the real sample name used as sample_id. REF_SEP = ">" -NOTE_PREFIX = "# note:" +NOTE_PREFIX = "note:" + + +def _is_note_line(line: str) -> bool: + return line.strip().lower().startswith(NOTE_PREFIX) def load_notes(path: Path) -> list[str]: - """Read display notes from '# note: ...' comment lines in the samples file.""" + """Read display notes from 'note: ...' lines in the samples file.""" if not path.exists(): return [] notes = [] for line in path.read_text(encoding="utf-8").splitlines(): stripped = line.strip() if stripped.lower().startswith(NOTE_PREFIX): - notes.append(stripped[len(NOTE_PREFIX):].strip()) + notes.append(stripped[len(NOTE_PREFIX) :].strip()) return notes @@ -48,7 +52,9 @@ def _sample_lines(path: Path) -> list[str]: return [ line.strip() for line in path.read_text(encoding="utf-8").splitlines() - if line.strip() and not line.strip().startswith("#") + if line.strip() + and not line.strip().startswith("#") + and not _is_note_line(line) ] diff --git a/measure.sh b/measure.sh index 7e690ad..03c5f84 100755 --- a/measure.sh +++ b/measure.sh @@ -45,7 +45,8 @@ esac SAMPLE_COUNT=0 if [[ -f samples.txt ]]; then - SAMPLE_COUNT="$(grep -cv '^#\|^$' samples.txt || true)" + SAMPLE_COUNT="$(grep -v '^#' samples.txt | grep -iv '^[[:space:]]*note:' \ + | grep -cv '^[[:space:]]*$' || true)" fi echo "" diff --git a/prompt-next-sample.py b/prompt-next-sample.py index 1a6fc41..ceb46cf 100755 --- a/prompt-next-sample.py +++ b/prompt-next-sample.py @@ -18,13 +18,15 @@ RESET = "\033[0m" def load_sample_names(path: Path) -> list[str]: # Optional "NAME > REF": keep only the sample name (before ">"). + # Skip "#" comments and "note: ..." metadata lines. names = [] for line in path.read_text(encoding="utf-8").splitlines(): line = line.strip() - if line and not line.startswith("#"): - if ">" in line: - line = line.split(">", 1)[0].strip() - names.append(line) + if not line or line.startswith("#") or line.lower().startswith("note:"): + continue + if ">" in line: + line = line.split(">", 1)[0].strip() + names.append(line) return names diff --git a/run-measurement.sh b/run-measurement.sh index d6599d5..ce482ed 100755 --- a/run-measurement.sh +++ b/run-measurement.sh @@ -16,7 +16,8 @@ if [[ -z "$LATEST" ]]; then exit 1 fi -if grep -qv '^#' samples.txt 2>/dev/null && grep -q '[^[:space:]]' samples.txt; then +if grep -v '^#' samples.txt 2>/dev/null | grep -iv '^[[:space:]]*note:' \ + | grep -q '[^[:space:]]'; then ./tsv-to-csv.py "$LATEST" -s samples.txt else ./tsv-to-csv.py "$LATEST" @@ -24,7 +25,8 @@ fi CSV="${LATEST%.tsv}.csv" READING_COUNT="$(($(wc -l < "$LATEST") - 1))" -EXPECTED="$(grep -cv '^#\|^$' samples.txt 2>/dev/null || echo 0)" +EXPECTED="$(grep -v '^#' samples.txt 2>/dev/null | grep -iv '^[[:space:]]*note:' \ + | grep -cv '^[[:space:]]*$' || echo 0)" echo "" echo "============================================" diff --git a/samples.example.txt b/samples.example.txt index dafc96d..50c15f3 100644 --- a/samples.example.txt +++ b/samples.example.txt @@ -1,5 +1,6 @@ # One sample name per line, in measurement order. -# Lines starting with # are ignored. +# Lines starting with # are comments (ignored). Lines starting with "note:" +# are HTML report metadata (not samples). # # Name a Delta-E reference with "NAME > REF": that sample's dE00 (CIEDE2000 # in averaged.csv) is measured against REF. A bare name (no ">") is itself a @@ -7,9 +8,11 @@ # INK_A # INK_B > INK_A # -# Optional notes for averaged.html (one per line, shown above the results table): -# note: Glaze: CPO1192 -# note: Firing Temperature: 1150 C +# Optional notes for averaged.html (one per line, NOT starting with #): +# note: Glaze: CPO1192 +# note: Firing Temperature: 1150 C +# +# Lines starting with "note:" are metadata for the HTML report, not samples. # # Single materials: just the material name/code, e.g. # INK_A diff --git a/tsv-to-csv.py b/tsv-to-csv.py index 8b9d0a5..f3e336e 100755 --- a/tsv-to-csv.py +++ b/tsv-to-csv.py @@ -9,13 +9,15 @@ from pathlib import Path def load_sample_names(path: Path) -> list[str]: # Optional "NAME > REF": keep only the sample name (before ">"). + # Skip "#" comments and "note: ..." metadata lines. names = [] for line in path.read_text(encoding="utf-8").splitlines(): line = line.strip() - if line and not line.startswith("#"): - if ">" in line: - line = line.split(">", 1)[0].strip() - names.append(line) + if not line or line.startswith("#") or line.lower().startswith("note:"): + continue + if ">" in line: + line = line.split(">", 1)[0].strip() + names.append(line) return names