craftbeerpi4-pione/cbpi/utils/utils.py
2019-01-05 20:43:48 +01:00

18 lines
344 B
Python

from cbpi.utils.encoder import ComplexEncoder
__all__ = ['load_config',"json_dumps"]
import json
import yaml
def load_config(fname):
try:
with open(fname, 'rt') as f:
data = yaml.load(f)
return data
except Exception as e:
pass
def json_dumps(obj):
return json.dumps(obj, cls=ComplexEncoder)