livery.workshop._regions¶
livery.workshop._regions ¶
The content a repository owns inside its managed files.
A managed file is rendered whole and judged byte for byte, and a
repository still needs lines of its own in some of them: its own
rules in the root .gitignore, its own tables in pyproject.toml,
its own tasks below the mount in tasks.py. A region carries them.
A region is a pair of marker comments the template renders, with the repository's lines between them. The fragment engine reads each region from the committed file and writes it back in place, so a sync preserves it by construction and the drift gate still compares whole bytes: an edit inside a region is the repository's, an edit outside it is drift, and a removed marker is drift too. A file without the region yet gains the markers, empty, on the next apply.
The markers are one shape in every comment style, so a reader who has seen one has seen them all::
# -- workshop: region tables, yours to edit; the render keeps it --
# -- workshop: end tables --
Classes:
| Name | Description |
|---|---|
Region |
One region as a committed file carries it. |
Functions:
| Name | Description |
|---|---|
regions_in |
Every region text carries, in file order. |
region_names |
The names the markers in text open, whether or not they close. |
contents |
The committed file's regions, name to content; empty when the file is absent. |
unmatched |
The names whose markers do not pair up in text. |
marker_lines |
The opening and closing marker for name under leader. |
Attributes:
| Name | Type | Description |
|---|---|---|
OPEN |
|
|
CLOSE |
|
OPEN
module-attribute
¶
Region
dataclass
¶
One region as a committed file carries it.
Attributes:
| Name | Type | Description |
|---|---|---|
name |
str
|
The region's name, as its markers spell it. |
content |
str
|
The lines between the markers, newline-terminated when there are any, empty otherwise. |
first |
int
|
The line number of the opening marker, one-based. |
last |
int
|
The line number of the closing marker, one-based. |
regions_in ¶
Every region text carries, in file order.
A marker without its partner is not a region: the drift gate reports the file, since the markers are rendered bytes.
Source code in packages/workshop/src/livery/workshop/_regions.py
region_names ¶
The names the markers in text open, whether or not they close.
contents ¶
The committed file's regions, name to content; empty when the file is absent.
Source code in packages/workshop/src/livery/workshop/_regions.py
unmatched ¶
The names whose markers do not pair up in text.
Source code in packages/workshop/src/livery/workshop/_regions.py
marker_lines ¶
The opening and closing marker for name under leader.