Dec-22-2023, 12:26 PM
i have metadata and api_request as below.
only that data and in those filtered data , i need to ensure that name should of the mentioned regex.
Requirement:detail_in and detail_out should be present in a given metadata
if the filtered data has both detail_in and detail_out present in name for a given metadata...i should not raise any error.if either
detail_in or detail_out is absent ,i need to raise error and mentioned the error like "detail in not present" or "detailout not present "
i did the following way,but i am not able to proceed further
for the above example of metadata ,there should be no error raised
suppose the metadata is as below
waiting for a response.Thank you
metadata = [ {"path": "d/scripts", "name": "../"}, {"path": "d/scripts", "name": "../"}, {"path": "d/scripts", "name": "unn_details_in.cfg"}, {"path": "d/scripts", "name": "unn_details_out.cfg"}, {"path": "d/scripts", "name": "unn_details_in_v1.cfg"}, {"path": "d/scripts", "name": "unn_details_out_v1.cfg"}, {"path": "c/scripts", "name": "./"}, {"path": "c/scripts", "name": "../"} ] api_request = {"response_filter": [ {"path": {"value": "d/scripts"}, "name": {"value": "[a-z_]*details_in[a-z1-2_]*.cfg$", "operator": "match"}}, {"path": {"value": "d/scripts"}, "name": {"value": "[a-z_]*details_out[a-z1-2_]*.cfg$", "operator": "match"}} ]} final_list=[] for details in api_request["response_filter"]: for key,value in details.items(): final_list.extend( data for data in metadata if OPERATION_MAPPER[value.get("operator","eq")](value.get("value"),data[key]) and data not in final_list) print(final_list)i am supposed to iterate api_request["response_filter"] and what ever is the value for path(in this case d/scripts),i need to filter
only that data and in those filtered data , i need to ensure that name should of the mentioned regex.
Requirement:detail_in and detail_out should be present in a given metadata
if the filtered data has both detail_in and detail_out present in name for a given metadata...i should not raise any error.if either
detail_in or detail_out is absent ,i need to raise error and mentioned the error like "detail in not present" or "detailout not present "
i did the following way,but i am not able to proceed further
for the above example of metadata ,there should be no error raised
suppose the metadata is as below
metadata = [ {"path": "d/scripts", "name": "../"}, {"path": "d/scripts", "name": "../"}, {"path": "d/scripts", "name": "unn_details_in.cfg"}, {"path": "d/scripts", "name": "unn_details_in_v1.cfg"}, {"path": "c/scripts", "name": "./"}, {"path": "c/scripts", "name": "../"} ]we should get the message as details_out absent
waiting for a response.Thank you