jsonify the config object

This commit is contained in:
Reid 'arrdem' McKenzie 2022-11-26 22:51:31 -07:00
parent 8e53c8e509
commit f964f64800
2 changed files with 11 additions and 1 deletions

View file

@ -198,4 +198,5 @@ class RelayConfig(DotDict):
def save(self):
with open(self._path, "w") as fd:
yaml.dump(self, fd, sort_keys=False)
fd.write("---\n")
yaml.dump(self.jsonify(), fd, sort_keys=True)

View file

@ -328,6 +328,15 @@ class DotDict(dict):
def to_json(self, indent=None):
return json.dumps(self, indent=indent)
def jsonify(self):
def _xform(v):
if hasattr(v, 'jsonify'):
return v.jsonify()
else:
return v
return {k: _xform(v) for k, v in self.items()}
def update(self, _data, **kwargs):
if isinstance(_data, dict):
for key, value in _data.items():