python_intership/task3/task3.py

26 lines
671 B
Python
Raw Permalink Normal View History

2023-11-09 13:28:19 +03:00
import sys
import json
import shutil
file1 = "task3/" + sys.argv[1]
file2 = "task3/" + sys.argv[2]
with open(file1, 'r') as file:
tests_data = json.load(file)
with open(file2, 'r') as file:
values_data = json.load(file)
def update_tests(tests, values):
for test in tests:
for value in values:
if value['id'] == test['id']:
test['value'] = value['value']
if 'values' in test:
update_tests(test['values'], values)
update_tests(tests_data['tests'], values_data['values'])
with open('report.json', 'w') as file:
json.dump(tests_data, file, indent=4)
shutil.move('report.json', 'task3/report.json')