Answer architecture round 3: 0 🔴, 2 🟡 (0 misread); a record write names its version, even None, in every backend, and the unreleased section is read through markdown_text.section by one title pattern
This commit is contained in:
@@ -31,8 +31,8 @@ class RecordStore(typing.Protocol):
|
||||
def held(self) -> Held | Failure:
|
||||
"""The record as it stands, with the version a write over it names."""
|
||||
|
||||
def write(self, text: str, over: str | None = None) -> Held | Failure:
|
||||
"""Replaces the record's whole text, creating the record where it doesn't exist yet, and gives the record as the write left it. over is the version held() gave: where someone saved the record since, the write refuses. None replaces the record as it stands."""
|
||||
def write(self, text: str, over: str | None) -> Held | Failure:
|
||||
"""Replaces the record's whole text, creating the record where it doesn't exist yet, and gives the record as the write left it. over is the version held() gave: where someone saved the record since, the write refuses. None replaces the record as it stands, so a caller passes it only where it read no version."""
|
||||
|
||||
|
||||
@dataclasses.dataclass(frozen=True)
|
||||
@@ -59,7 +59,7 @@ class FileStore:
|
||||
except OSError as failure:
|
||||
return Failure(f"cannot read {self.path}: {failure.strerror}")
|
||||
|
||||
def write(self, text: str, over: str | None = None) -> Held | Failure:
|
||||
def write(self, text: str, over: str | None) -> Held | Failure:
|
||||
try:
|
||||
self.path.parent.mkdir(parents=True, exist_ok=True)
|
||||
except OSError as failure:
|
||||
@@ -108,7 +108,7 @@ def local_file(record: RecordStore, copy: pathlib.Path) -> pathlib.Path | Failur
|
||||
if isinstance(held, Failure):
|
||||
return held
|
||||
if held.text:
|
||||
written = FileStore(copy, None).write(held.text)
|
||||
written = FileStore(copy, None).write(held.text, None)
|
||||
if isinstance(written, Failure):
|
||||
return written
|
||||
else:
|
||||
@@ -145,7 +145,7 @@ def version_file(copy: pathlib.Path) -> pathlib.Path:
|
||||
def kept(copy: pathlib.Path, version: str | None) -> Failure | None:
|
||||
"""Keeps version beside copy, or removes the file that kept an earlier one where version is None."""
|
||||
if version is not None:
|
||||
written = FileStore(version_file(copy), None).write(version)
|
||||
written = FileStore(version_file(copy), None).write(version, None)
|
||||
return written if isinstance(written, Failure) else None
|
||||
try:
|
||||
version_file(copy).unlink(missing_ok=True)
|
||||
|
||||
Reference in New Issue
Block a user