cutan.characters.drawn¶
What the character factory wrote, as it wrote it: the in-memory log behind its record of drawn bytes.
The machine’s record of bytes the factory drew (an#269,
an.library.registry.record_generated) verifies the factory’s stamps in the
asset library. It must hold the digests of bytes the factory itself produced,
never of whatever sits on disk when it finishes: a file swapped in while
new_character runs is not the factory’s drawing. So every file the factory
writes goes through write_text() / write_bytes(), which write it AND,
while a drawing() is open in this context, log the SHA-256 of the exact
bytes written — computed in memory at write time.
>>> import tempfile, pathlib
>>> with tempfile.TemporaryDirectory() as d, drawing() as log:
... p = pathlib.Path(d) / "a.svg"
... write_text(p, "<svg/>")
... log[str(p.resolve())] == hashlib.sha256(b"<svg/>").hexdigest()
True
Functions
|
Log |
|
Write |
|
Write |
|
Write |
- cutan.characters.drawn.drawing()[source]¶
Log
{resolved path: sha256}of every file written through this module, in this context.Re-entrant: inside an open drawing (
add_gazecalled bynew_character) the same log is shared, so the outer call sees every byte the inner one wrote.
- cutan.characters.drawn.write_bytes(path, data)[source]¶
Write
datatopath, logging its digest if adrawing()is open.- Return type:
- cutan.characters.drawn.write_derived_text(path, source, text, *, encoding='utf-8')[source]¶
Write
text, derived fromsource— the bytes just read back frompath.Logged only if
sourceis exactly what this drawing itself wrote there: a file swapped in between the factory’s write and its re-read (a rescale) is rewritten, but not as the factory’s drawing (review-288 round 2).>>> import tempfile, pathlib >>> with tempfile.TemporaryDirectory() as d, drawing() as log: ... p = pathlib.Path(d) / "a.svg" ... write_text(p, "<svg/>") ... p.write_bytes(b"<svg>swapped</svg>") # not the factory's write ... write_derived_text(p, p.read_bytes(), "<svg>scaled</svg>") ... str(p.resolve()) in log 18 False- Return type: