Base class for file-based version providers
| 41 | |
| 42 | |
| 43 | class 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 | |
| 67 | class JsonProvider(FileProvider): |
nothing calls this directly
no outgoing calls
no test coverage detected