Use note: lines for HTML metadata, not # comments
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
10
README.md
10
README.md
@@ -86,12 +86,14 @@ material codes); copy the template to create your own:
|
|||||||
cp samples.example.txt samples.txt
|
cp samples.example.txt samples.txt
|
||||||
```
|
```
|
||||||
|
|
||||||
Lines starting with `#` are ignored. Material names can be any codes.
|
Lines starting with `#` are comments. Lines starting with `note:` are
|
||||||
Append ` > REF` to measure that sample's `dE00` against another sample; a
|
metadata shown above the table in `averaged.html` (not samples). Material
|
||||||
bare name (no `>`) is itself a **reference**. Mix samples use the pattern
|
names can be any codes. Append ` > REF` to measure that sample's `dE00`
|
||||||
`NAME_A+NAME_B[w1 to w2 mix]`, e.g.:
|
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
|
```text
|
||||||
|
note: Glaze: CPO1192
|
||||||
INK_A
|
INK_A
|
||||||
INK_B > INK_A
|
INK_B > INK_A
|
||||||
INK_A+INK_B[75 to 15 mix] > INK_A
|
INK_A+INK_B[75 to 15 mix] > INK_A
|
||||||
|
|||||||
@@ -133,8 +133,8 @@ scan_samples() {
|
|||||||
SAMPLES=()
|
SAMPLES=()
|
||||||
while IFS= read -r line; do
|
while IFS= read -r line; do
|
||||||
SAMPLES+=("$line")
|
SAMPLES+=("$line")
|
||||||
done < <(grep -v '^#' "$SAMPLES_FILE" | grep -v '^[[:space:]]*$' \
|
done < <(grep -v '^#' "$SAMPLES_FILE" | grep -iv '^[[:space:]]*note:' \
|
||||||
| sed -E 's/[[:space:]]*>.*$//')
|
| grep -v '^[[:space:]]*$' | sed -E 's/[[:space:]]*>.*$//')
|
||||||
local count="${#SAMPLES[@]}"
|
local count="${#SAMPLES[@]}"
|
||||||
[[ "$count" -gt 0 ]] || fail "No sample names found in $SAMPLES_FILE"
|
[[ "$count" -gt 0 ]] || fail "No sample names found in $SAMPLES_FILE"
|
||||||
|
|
||||||
@@ -190,7 +190,8 @@ update_average() {
|
|||||||
info "Step 5/5: Updating $AVERAGED_CSV"
|
info "Step 5/5: Updating $AVERAGED_CSV"
|
||||||
|
|
||||||
local expected
|
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
|
# Collect scan CSVs (timestamped files only) with the expected reading count
|
||||||
local -a scans=()
|
local -a scans=()
|
||||||
|
|||||||
@@ -20,18 +20,22 @@ WHITE_POINT = (96.422, 100.0, 82.521)
|
|||||||
# (no ">") are references themselves. The " > REF" suffix is stripped to
|
# (no ">") are references themselves. The " > REF" suffix is stripped to
|
||||||
# recover the real sample name used as sample_id.
|
# recover the real sample name used as sample_id.
|
||||||
REF_SEP = ">"
|
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]:
|
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():
|
if not path.exists():
|
||||||
return []
|
return []
|
||||||
notes = []
|
notes = []
|
||||||
for line in path.read_text(encoding="utf-8").splitlines():
|
for line in path.read_text(encoding="utf-8").splitlines():
|
||||||
stripped = line.strip()
|
stripped = line.strip()
|
||||||
if stripped.lower().startswith(NOTE_PREFIX):
|
if stripped.lower().startswith(NOTE_PREFIX):
|
||||||
notes.append(stripped[len(NOTE_PREFIX):].strip())
|
notes.append(stripped[len(NOTE_PREFIX) :].strip())
|
||||||
return notes
|
return notes
|
||||||
|
|
||||||
|
|
||||||
@@ -48,7 +52,9 @@ def _sample_lines(path: Path) -> list[str]:
|
|||||||
return [
|
return [
|
||||||
line.strip()
|
line.strip()
|
||||||
for line in path.read_text(encoding="utf-8").splitlines()
|
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)
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -45,7 +45,8 @@ esac
|
|||||||
|
|
||||||
SAMPLE_COUNT=0
|
SAMPLE_COUNT=0
|
||||||
if [[ -f samples.txt ]]; then
|
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
|
fi
|
||||||
|
|
||||||
echo ""
|
echo ""
|
||||||
|
|||||||
@@ -18,13 +18,15 @@ RESET = "\033[0m"
|
|||||||
|
|
||||||
def load_sample_names(path: Path) -> list[str]:
|
def load_sample_names(path: Path) -> list[str]:
|
||||||
# Optional "NAME > REF": keep only the sample name (before ">").
|
# Optional "NAME > REF": keep only the sample name (before ">").
|
||||||
|
# Skip "#" comments and "note: ..." metadata lines.
|
||||||
names = []
|
names = []
|
||||||
for line in path.read_text(encoding="utf-8").splitlines():
|
for line in path.read_text(encoding="utf-8").splitlines():
|
||||||
line = line.strip()
|
line = line.strip()
|
||||||
if line and not line.startswith("#"):
|
if not line or line.startswith("#") or line.lower().startswith("note:"):
|
||||||
if ">" in line:
|
continue
|
||||||
line = line.split(">", 1)[0].strip()
|
if ">" in line:
|
||||||
names.append(line)
|
line = line.split(">", 1)[0].strip()
|
||||||
|
names.append(line)
|
||||||
return names
|
return names
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -16,7 +16,8 @@ if [[ -z "$LATEST" ]]; then
|
|||||||
exit 1
|
exit 1
|
||||||
fi
|
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
|
./tsv-to-csv.py "$LATEST" -s samples.txt
|
||||||
else
|
else
|
||||||
./tsv-to-csv.py "$LATEST"
|
./tsv-to-csv.py "$LATEST"
|
||||||
@@ -24,7 +25,8 @@ fi
|
|||||||
|
|
||||||
CSV="${LATEST%.tsv}.csv"
|
CSV="${LATEST%.tsv}.csv"
|
||||||
READING_COUNT="$(($(wc -l < "$LATEST") - 1))"
|
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 ""
|
||||||
echo "============================================"
|
echo "============================================"
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
# One sample name per line, in measurement order.
|
# 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
|
# 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
|
# in averaged.csv) is measured against REF. A bare name (no ">") is itself a
|
||||||
@@ -7,9 +8,11 @@
|
|||||||
# INK_A
|
# INK_A
|
||||||
# INK_B > INK_A
|
# INK_B > INK_A
|
||||||
#
|
#
|
||||||
# Optional notes for averaged.html (one per line, shown above the results table):
|
# Optional notes for averaged.html (one per line, NOT starting with #):
|
||||||
# note: Glaze: CPO1192
|
# note: Glaze: CPO1192
|
||||||
# note: Firing Temperature: 1150 C
|
# 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.
|
# Single materials: just the material name/code, e.g.
|
||||||
# INK_A
|
# INK_A
|
||||||
|
|||||||
@@ -9,13 +9,15 @@ from pathlib import Path
|
|||||||
|
|
||||||
def load_sample_names(path: Path) -> list[str]:
|
def load_sample_names(path: Path) -> list[str]:
|
||||||
# Optional "NAME > REF": keep only the sample name (before ">").
|
# Optional "NAME > REF": keep only the sample name (before ">").
|
||||||
|
# Skip "#" comments and "note: ..." metadata lines.
|
||||||
names = []
|
names = []
|
||||||
for line in path.read_text(encoding="utf-8").splitlines():
|
for line in path.read_text(encoding="utf-8").splitlines():
|
||||||
line = line.strip()
|
line = line.strip()
|
||||||
if line and not line.startswith("#"):
|
if not line or line.startswith("#") or line.lower().startswith("note:"):
|
||||||
if ">" in line:
|
continue
|
||||||
line = line.split(">", 1)[0].strip()
|
if ">" in line:
|
||||||
names.append(line)
|
line = line.split(">", 1)[0].strip()
|
||||||
|
names.append(line)
|
||||||
return names
|
return names
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user