mirror of
https://github.com/yavook/kiwi-scp.git
synced 2024-11-21 20:33:00 +00:00
prefer "long" project configs
This commit is contained in:
parent
b76b6b59ed
commit
aa8f0d9e6a
3 changed files with 11 additions and 7 deletions
|
@ -45,12 +45,11 @@ class ProjectConfig(BaseModel):
|
||||||
def kiwi_dict(self) -> Dict[str, Any]:
|
def kiwi_dict(self) -> Dict[str, Any]:
|
||||||
"""write this object as a dictionary of strings"""
|
"""write this object as a dictionary of strings"""
|
||||||
|
|
||||||
if self.override_storage is None:
|
|
||||||
return {self.name: self.enabled}
|
|
||||||
|
|
||||||
else:
|
|
||||||
result = self.dict(exclude={"override_storage"})
|
result = self.dict(exclude={"override_storage"})
|
||||||
|
|
||||||
|
if self.override_storage is not None:
|
||||||
result["override_storage"] = self.override_storage.kiwi_dict
|
result["override_storage"] = self.override_storage.kiwi_dict
|
||||||
|
|
||||||
return result
|
return result
|
||||||
|
|
||||||
@validator("name")
|
@validator("name")
|
||||||
|
|
|
@ -10,7 +10,7 @@ from ._constants import HEADER_KIWI_CONF_NAME
|
||||||
class YAML(ruamel.yaml.YAML):
|
class YAML(ruamel.yaml.YAML):
|
||||||
def __init__(self, *args, **kwargs) -> None:
|
def __init__(self, *args, **kwargs) -> None:
|
||||||
super().__init__(*args, **kwargs)
|
super().__init__(*args, **kwargs)
|
||||||
self.indent(offset=2)
|
self.indent(sequence=4, offset=2)
|
||||||
|
|
||||||
def dump(self, data, stream=None, **kwargs) -> Optional[str]:
|
def dump(self, data, stream=None, **kwargs) -> Optional[str]:
|
||||||
into_str: bool = False
|
into_str: bool = False
|
||||||
|
|
|
@ -221,7 +221,12 @@ class TestProject:
|
||||||
assert p.name == "project"
|
assert p.name == "project"
|
||||||
assert not p.enabled
|
assert not p.enabled
|
||||||
assert p.override_storage is None
|
assert p.override_storage is None
|
||||||
assert p.kiwi_dict == kiwi_dict
|
|
||||||
|
resulting_kiwi_dict = {
|
||||||
|
"name": "project",
|
||||||
|
"enabled": False,
|
||||||
|
}
|
||||||
|
assert p.kiwi_dict == resulting_kiwi_dict
|
||||||
|
|
||||||
def test_dict(self):
|
def test_dict(self):
|
||||||
c = KiwiConfig(projects={"name": "project"})
|
c = KiwiConfig(projects={"name": "project"})
|
||||||
|
|
Loading…
Reference in a new issue