File size: 3,970 Bytes
75c683a
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
#!/usr/bin/env python3
"""Generate SAMPLE family data in ./data for local testing.

The public repo contains zero personal data; this script creates placeholder
people/events with solid-color photos so the whole app can be tested locally
without the private dataset. Run from the repo root:

    python scripts/make_sample_data.py
"""

from __future__ import annotations

import json
import os
import struct
import zlib
from pathlib import Path

ROOT = Path(__file__).resolve().parent.parent
DATA = ROOT / "data"


def make_png(path: Path, rgb: tuple, size: int = 240) -> None:
    """Minimal solid-color PNG writer (no dependencies)."""
    raw = b"".join(b"\x00" + bytes(rgb) * size for _ in range(size))

    def chunk(tag: bytes, data: bytes) -> bytes:
        c = struct.pack(">I", len(data)) + tag + data
        return c + struct.pack(">I", zlib.crc32(tag + data) & 0xFFFFFFFF)

    png = b"\x89PNG\r\n\x1a\n"
    png += chunk(b"IHDR", struct.pack(">IIBBBBB", size, size, 8, 2, 0, 0, 0))
    png += chunk(b"IDAT", zlib.compress(raw))
    png += chunk(b"IEND", b"")
    path.parent.mkdir(parents=True, exist_ok=True)
    path.write_bytes(png)


SAMPLE_NOTE = ("SAMPLE data for local testing only. Real family data lives in the "
               "private HF dataset (data/ is fully gitignored). Regenerate with "
               "scripts/make_sample_data.py; upload real data with "
               "scripts/upload_family_data.py.")

PEOPLE = {
    "_comment": SAMPLE_NOTE,
    "people": [
        {"id": "beth", "name": "Beth", "aliases": ["Bethje"], "relation": "vriendin van Luke",
         "photos": ["photos/people/beth/1.png"], "birthday": "07-06", "active": True},
        {"id": "luke", "name": "Luke", "aliases": [], "relation": "je oudste kleinzoon",
         "photos": ["photos/people/luke/1.png"], "active": True},
        {"id": "jacq", "name": "Jacq", "aliases": [], "relation": "je dochter",
         "photos": ["photos/people/jacq/1.png"], "active": True},
        {"id": "pieter", "name": "Pieter", "aliases": ["Piet"], "relation": "je oude schaakvriend",
         "photos": ["photos/people/pieter/1.png"], "active": True},
    ]
}

EVENTS = {
    "_comment": SAMPLE_NOTE,
    "events": [
        {"id": "vakantie_1998", "photo": "photos/events/vakantie_1998.png",
         "title": "Vakantie in Frankrijk, 1998",
         "description": "In de zomer van 1998 reden jullie met de auto naar Frankrijk. "
                        "Het was warm, de wijn was lekker, en er werd elke avond buiten "
                        "gegeten onder de platanen.",
         "prompts": ["Waar was dit?", "Wie waren erbij?", "Wat aten jullie daar graag?"],
         "active": True},
        {"id": "schaakclub", "photo": "photos/events/schaakclub.png",
         "title": "De schaakclub",
         "description": "Jarenlang speelde je elke donderdagavond op de schaakclub. "
                        "Er werd fanatiek gespeeld, maar vooral veel gelachen — en na "
                        "afloop altijd één biertje.",
         "prompts": ["Met wie speelde je het liefst?", "Won je vaak?"],
         "active": True},
    ]
}

PHOTOS = {
    "photos/people/beth/1.png": (232, 163, 61),
    "photos/people/luke/1.png": (127, 168, 160),
    "photos/people/jacq/1.png": (217, 136, 128),
    "photos/people/pieter/1.png": (130, 176, 216),
    "photos/events/vakantie_1998.png": (246, 185, 59),
    "photos/events/schaakclub.png": (168, 213, 162),
}


def main() -> None:
    (DATA / "progress").mkdir(parents=True, exist_ok=True)
    (DATA / "recordings").mkdir(parents=True, exist_ok=True)
    (DATA / "people.json").write_text(
        json.dumps(PEOPLE, ensure_ascii=False, indent=2), encoding="utf-8")
    (DATA / "events.json").write_text(
        json.dumps(EVENTS, ensure_ascii=False, indent=2), encoding="utf-8")
    for rel, rgb in PHOTOS.items():
        make_png(DATA / rel, rgb)
    print(f"sample data written to {DATA}")


if __name__ == "__main__":
    main()