forked from JsBergbau/MiTemperature2
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathjsonToIni.py
More file actions
executable file
·28 lines (23 loc) · 843 Bytes
/
jsonToIni.py
File metadata and controls
executable file
·28 lines (23 loc) · 843 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#!/usr/bin/python3
import configparser
import argparse
import os
import json as JSON
parser = argparse.ArgumentParser(allow_abbrev=False)
parser.add_argument("--readfile", "-rf", help="Specify filename of json-File to convert",
metavar='filename', required=True)
parser.add_argument("--writefile", "-wf", help="Specify filename of json-File to convert",
metavar='filename', required=True)
args = parser.parse_args()
if not os.path.exists(args.readfile):
print("Error specified device list file '",
args.devicelistfile, "' not found")
os._exit(1)
with open (args.readfile,"r") as json_file:
json=JSON.load(json_file)
# for key in json:
# print(key)
sensors = configparser.ConfigParser()
sensors.read_dict(json)
with open (args.writefile,"x") as ini_file:
sensors.write(ini_file)