resource
Common interface for mutable, file-backed policy resources.
-
ChangelogItem
A user-facing message that describes one policy change.
-
Changelog
Messages reported by a policy check.
alias of list[str]
-
class ModifiableResource[source]
Bases: AbstractContextManager, ABC
A file loaded once and written once after in-memory modification.
-
abstractmethod classmethod load() → Self[source]
Load the resource from the working tree.
-
abstract property changelog: list[str][source]
Changes made to the in-memory representation.
-
abstractmethod dump() → None[source]
Write the in-memory representation to the working tree.
-
property changed: bool[source]
Whether the resource needs to be flushed.
-
class ModifiablePath(path: Path, content: bytes | None, *, is_directory: bool = False)[source]
Bases: ModifiableResource
Deferred in-memory state for one arbitrary working-tree path.
-
classmethod load() → Self[source]
Load the resource from the working tree.
-
classmethod load_path(path: Path | str) → Self[source]
-
property changelog: list[str][source]
Changes made to the in-memory representation.
-
property changed: bool[source]
Whether the resource needs to be flushed.
-
property exists: bool[source]
-
read_text() → str[source]
-
write_text(content: str, message: str | None = None) → bool[source]
-
remove(message: str | None = None) → bool[source]
-
dump() → None[source]
Write the in-memory representation to the working tree.