From 1e94a7fd8de6ef3b5d660a98eeff870145ecda73 Mon Sep 17 00:00:00 2001 From: Yesen Date: Thu, 9 Nov 2023 13:24:47 +0300 Subject: [PATCH] =?UTF-8?q?=D0=9E=D0=B1=D0=BD=D0=BE=D0=B2=D0=B8=D1=82?= =?UTF-8?q?=D1=8C=20task3.py?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- task3.py | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/task3.py b/task3.py index e69de29..f4c9a11 100644 --- a/task3.py +++ b/task3.py @@ -0,0 +1,26 @@ +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') \ No newline at end of file