2019-01-05 20:43:48 +01:00
|
|
|
from cbpi.utils.encoder import ComplexEncoder
|
2018-11-16 20:35:59 +01:00
|
|
|
|
2019-01-02 21:20:44 +01:00
|
|
|
__all__ = ['load_config',"json_dumps"]
|
2018-11-04 00:47:26 +01:00
|
|
|
|
2018-11-01 19:50:04 +01:00
|
|
|
import json
|
2018-11-01 21:27:37 +01:00
|
|
|
import yaml
|
|
|
|
|
2018-11-01 19:50:04 +01:00
|
|
|
|
2018-11-01 21:27:37 +01:00
|
|
|
def load_config(fname):
|
2018-11-16 20:35:59 +01:00
|
|
|
try:
|
|
|
|
with open(fname, 'rt') as f:
|
|
|
|
data = yaml.load(f)
|
|
|
|
return data
|
2018-12-29 00:27:19 +01:00
|
|
|
except Exception as e:
|
2018-11-16 20:35:59 +01:00
|
|
|
pass
|
2018-11-01 21:27:37 +01:00
|
|
|
|
2018-11-01 19:50:04 +01:00
|
|
|
def json_dumps(obj):
|
2018-11-01 21:27:37 +01:00
|
|
|
return json.dumps(obj, cls=ComplexEncoder)
|