Skip to content
Snippets Groups Projects
Commit a673410c authored by Tobias Westphal's avatar Tobias Westphal
Browse files

jsonparse.py main:

added main funktion to jsonparse.py
parent 36e3ae8c
Branches
No related tags found
No related merge requests found
......@@ -84,48 +84,52 @@ def changerange(string):
print(string)
try:
JSON_MODEL = sys.argv[1][:-5]
if not os.path.exists(os.path.join('..', 'SOIL OPC-UA', f'{JSON_MODEL}.json')):
raise Exception()
except Exception as e:
print('You must provide a file from the folder to be used as root file of the parsing, e.g., "python jsonparser.py model.json".')
exit()
with open(f'{JSON_MODEL}.json') as file:
#robot = json.dumps(file.read())
robotload = json.loads(file.read())
measurements = robotload["measurements"]
if len(measurements) > 0:
measurementobj = []
for i in measurements:
obj = i
#del obj["value"]
del obj["uuid"]
dimensionchange(obj)
#if i["range"]:
changerange(obj)
obj = json.dumps(i)
measurementobji = json.loads(obj, object_hook=measurementJsonDecod)
measurementobj.append(measurementobji)
print(measurementobj)
parameters = robotload["parameters"]
if len(parameters) > 0:
parameterobj = []
for i in parameters:
obj = i
# del obj["value"]
del obj["uuid"]
dimensionchange(obj)
if i["range"]:
def main():
try:
JSON_MODEL = sys.argv[1][:-5]
if not os.path.exists(os.path.join('..', 'SOIL OPC-UA', f'{JSON_MODEL}.json')):
raise Exception()
except Exception as e:
print('You must provide a file from the folder to be used as root file of the parsing, e.g., "python jsonparser.py model.json".')
exit()
with open(f'{JSON_MODEL}.json') as file:
#robot = json.dumps(file.read())
robotload = json.loads(file.read())
measurements = robotload["measurements"]
if len(measurements) > 0:
measurementobj = []
for i in measurements:
obj = i
#del obj["value"]
del obj["uuid"]
dimensionchange(obj)
#if i["range"]:
changerange(obj)
obj = json.dumps(i)
parameterobji = json.loads(obj, object_hook=parameterJsonDecod)
parameterobj.append(parameterobji)
print(parameterobj)
obj = json.dumps(i)
measurementobji = json.loads(obj, object_hook=measurementJsonDecod)
measurementobj.append(measurementobji)
print(measurementobj)
parameters = robotload["parameters"]
if len(parameters) > 0:
parameterobj = []
for i in parameters:
obj = i
# del obj["value"]
del obj["uuid"]
dimensionchange(obj)
if i["range"]:
changerange(obj)
obj = json.dumps(i)
parameterobji = json.loads(obj, object_hook=parameterJsonDecod)
parameterobj.append(parameterobji)
print(parameterobj)
if __name__ == '__main__':
main()
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment