g_lovelace_default_convert.py
user_3364516
python
9 months ago
851 B
7
Indexable
hassio yaml save lovelace convert
try:
import simplejson as json
except ImportError:
print('simplejson missing, install with "pip install simplejson"')
try:
import yaml
except ImportError:
print('yaml missing, install with "pip install pyyaml"')
READFILE = r"E:\hassio\dailies\scratch\lovelace"
WRITEFILE = r"E:\hassio\dailies\scratch\lovelace_todays.yaml"
def convert():
"""Start convertion."""
try:
lljson = open(READFILE, "r+")
lldata = json.load(lljson)
lljson.close()
llyaml = open(WRITEFILE, "w+")
yaml.dump(lldata["data"]["config"], llyaml, default_flow_style=False)
llyaml.close()
print("Convertion done!")
except Exception as error: # pylint: disable=broad-except
errormsg = "Something went wrong - {}".format(error)
print(errormsg)
convert()Editor is loading...
Leave a Comment