MCPcopy Create free account
hub / github.com/commitizen-tools/commitizen / FileProvider

Class FileProvider

commitizen/providers/base_provider.py:43–64  ·  view source on GitHub ↗

Base class for file-based version providers

Source from the content-addressed store, hash-verified

41
42
43class FileProvider(VersionProvider):
44 """
45 Base class for file-based version providers
46 """
47
48 filename: ClassVar[str]
49
50 @property
51 def file(self) -> Path:
52 return Path() / self.filename
53
54 def _get_encoding(self) -> str:
55 return self.config.settings["encoding"]
56
57 def _write_text(self, path: Path, content: str) -> None:
58 """Write `content` to `path` with the configured encoding.
59
60 The file is opened with `smart_open`, so the line ending follows
61 `git config core.eol`, as it does for `version_files` and the changelog.
62 """
63 with smart_open(path, "w", encoding=self._get_encoding()) as file:
64 file.write(content)
65
66
67class JsonProvider(FileProvider):

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected