Franziska Kunsmann
36bd6f5755
Some checks failed
bundlewrap/pipeline/head There was a failure building this commit
19 lines
640 B
Python
19 lines
640 B
Python
from tomlkit import document as toml_document
|
|
|
|
from bundlewrap.utils import Fault
|
|
|
|
# Copied from bw core, because bw core doesn't support faults
|
|
def dict_to_toml(dict_obj):
|
|
toml_doc = toml_document()
|
|
for key, value in sorted(dict_obj.items()):
|
|
if isinstance(value, tuple):
|
|
toml_doc[key] = list(value)
|
|
elif isinstance(value, set):
|
|
toml_doc[key] = sorted(value)
|
|
elif isinstance(value, dict):
|
|
toml_doc[key] = dict_to_toml(value)
|
|
elif isinstance(value, Fault):
|
|
toml_doc[key] = str(value)
|
|
else:
|
|
toml_doc[key] = value
|
|
return toml_doc
|