Merge pull request 'Use note: lines for HTML metadata, not # comments' (#3) from cursor/note-prefix-not-comment into main
Reviewed-on: #3
This commit was merged in pull request #3.
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
|
||||
```
|
||||
|
||||
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
|
||||
|
||||
@@ -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=()
|
||||
|
||||
@@ -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)
|
||||
]
|
||||
|
||||
|
||||
|
||||
@@ -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 ""
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
|
||||
@@ -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 "============================================"
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user