entries
entries
#
Keyed props — how one is built from a container, and how a component reads it back.
- Build.
entries_of— the walk behind everyofconstructor — runsfunctionover a container withpmap(aMapby key, anArrayby index) as a progress step named for the component, keeping the results that are there, and records which entry each kept result came from asEntries. An entry whosefunctionfails is left out like an absent one; the walk raises only when every entry fails. - Read.
items_ofis the one way a component enumerates a keyed prop, whether it was given plainly or built byof:(position, key, item)triples, absent items left out but still counted in the position, so a prop read alongside it lines up; the key isNonefor a plain list.item_hrefssays where each item links — its entry's page underof, nowhere otherwise — andcaptioncaptions it by key.
Entries
dataclass
#
The container entry each item of a keyed prop came from, in the prop's order.
Source code in capturegraph-lib/capturegraph/ui/entries.py
hrefs(render)
#
The relative link to each entry's page, None where the container has no position.
caption(key)
#
key as a caption: an instant or a date in ISO form, anything else as text.
entries_of(container, function, label)
#
function over container, keyed as the container is, with the entries kept.
thumbnails, entries = entries_of(journal.sessions, lambda s: thumbnail(s.photo), "Gallery")
assert entries.keys == (noon, dusk)
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
container
|
Map[K, E] | Array[E]
|
The |
required |
function
|
Callable[[E], R | None]
|
The per-element operation. |
required |
label
|
str
|
What the walk's progress step shows, the component's name. |
required |
Source code in capturegraph-lib/capturegraph/ui/entries.py
item_hrefs(render, entries, count)
#
Where each of count items links: its entry's page under of, else nowhere.
Source code in capturegraph-lib/capturegraph/ui/entries.py
items_of(prop)
#
The (position, key, item) triples of a keyed prop, absent items left out.
The position is where the item sits in the prop as given, absent items
counted, so a prop read alongside it — a component's labels — still
lines up. A list has no keys, so its key is None.
assert items_of([a, b]) == [(0, None, a), (1, None, b)]
assert items_of(target.sessions.photo) == [(0, noon, noon_photo)] # dusk has no photo
Source code in capturegraph-lib/capturegraph/ui/entries.py
present(value)
#
Whether value is a value at all, rather than None or a Missing.