add repo.libs.faults.dict_as_toml

This commit is contained in:
Franzi 2024-03-23 10:34:41 +01:00
parent 1d5bcf74c0
commit 773e8d118f
Signed by: kunsi
GPG key ID: 12E3D2136B818350
11 changed files with 16 additions and 34 deletions

View file

@ -1,7 +1,10 @@
from json import dumps, loads
from tomlkit import dumps as toml_dumps
from bundlewrap.metadata import metadata_to_json
from bundlewrap.utils import Fault
from bundlewrap.utils.text import toml_clean
def resolve_faults(dictionary: dict) -> dict:
@ -45,3 +48,11 @@ def dict_as_json(json):
lambda o: metadata_to_json(o) + '\n',
o=json
)
def dict_as_toml(toml):
return Fault(
'dict_as_toml',
lambda o: toml_clean(toml_dumps(resolve_faults(o), sort_keys=True)) + '\n',
o=toml
)