-
-
Notifications
You must be signed in to change notification settings - Fork 278
/
Copy pathbase_config.py
42 lines (30 loc) · 1.08 KB
/
base_config.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
from __future__ import annotations
from pathlib import Path
from commitizen.defaults import DEFAULT_SETTINGS, Settings
class BaseConfig:
def __init__(self):
self._settings: Settings = DEFAULT_SETTINGS.copy()
self.encoding = self.settings["encoding"]
self._path: Path | None = None
self._settings_from_configs: Settings = {}
@property
def settings(self) -> Settings:
return self._settings
@property
def mutated_settings(self) -> Settings:
return self._settings_from_configs
@property
def path(self) -> Path | None:
return self._path
def set_key(self, key, value):
"""Set or update a key in the conf.
For now only strings are supported.
We use to update the version number.
"""
raise NotImplementedError()
def update(self, data: Settings) -> None:
self._settings.update(data)
def add_path(self, path: str | Path) -> None:
self._path = Path(path)
def _parse_setting(self, data: bytes | str) -> None:
raise NotImplementedError()