diff --git a/doc/generateDocumentationData.py b/doc/generateDocumentationData.py index 703286fa55b6226bbbec2d9c9b2f7b1cf0af6b7e..0573fb3c4a881cbf114a0fd39f07e62155d2426c 100644 --- a/doc/generateDocumentationData.py +++ b/doc/generateDocumentationData.py @@ -1,29 +1,39 @@ -from pprint import pprint from doc.analysis.generaterobotdata import GenerateRobotData import json +import sys from os.path import dirname, exists from os import makedirs -if __name__ == "__main__": +def create_json_of_robotfile(robot_path_to_be_processed: str, robot_file_to_be_processed: str): folder_test_suites = dirname(dirname(__file__)) folder_result_path = f'{folder_test_suites}/doc/results' - result_file = f'{folder_result_path}/result.json' - robot_file = f'{folder_test_suites}/TP/NGSI-LD/CommonBehaviours/044_01.robot' + result_file = f'{folder_result_path}/{robot_file_to_be_processed}.json' + robot_file = f'{folder_test_suites}/TP/NGSI-LD/{robot_path_to_be_processed}/{robot_file_to_be_processed}.robot' # Check that the folder '/results' exists and if not, create it if not exists(folder_result_path): makedirs(folder_result_path) - data = GenerateRobotData(robot_file=robot_file, - execdir=folder_test_suites) - data.parse_robot() - info = data.get_info() + try: + data = GenerateRobotData(robot_file=robot_file, execdir=folder_test_suites) + data.parse_robot() + info = data.get_info() + except Exception as e: + print("WHILE GENERATING ROBOT DATA:", e) + info = {} + info["error_while_parsing"] = True + + info["robotpath"] = robot_path_to_be_processed + info["robotfile"] = robot_file_to_be_processed with open(result_file, 'w') as fp: json.dump(obj=info, indent=4, fp=fp) - # data = GenerateRobotData(robot_file='../TP/NGSI-LD/ContextInformation/Provision/Entities/CreateEntity/001_01.robot', - # execdir='/home/fla/Documents/workspace/bdd/ngsi-ld-test-suite') - # data.parse_robot() - # info = data.get_info() - # pprint(info) + return info + +if __name__ == "__main__": + args = sys.argv[1:] + robot_path_tbp = args[0] + robot_file_tbp = args[1] + resulting_json = create_json_of_robotfile(robot_path_tbp, robot_file_tbp) + print("Correctly exiting")