Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
# print("~" * 100)
# extract data from "fantasy_content" field if it exists
if raw_response_data:
logger.debug("Data fetched with query URL: {}".format(response.url))
logger.debug("Response (Yahoo fantasy data extracted from: \"fantasy_content\"): {}".format(
raw_response_data))
else:
logger.error("NO DATA FOUND WHEN ATTEMPTING EXTRACTION FROM FIELD \"fantasy_content\"")
sys.exit()
# iterate through list of data keys and drill down to final desired data field
for i in range(len(data_key_list)):
if isinstance(raw_response_data, list):
if isinstance(data_key_list[i], list):
reformatted = reformat_json_list(raw_response_data)
raw_response_data = [
{data_key_list[i][0]: reformatted[data_key_list[i][0]]},
{data_key_list[i][1]: reformatted[data_key_list[i][1]]}
]
else:
raw_response_data = reformat_json_list(raw_response_data)[data_key_list[i]]
else:
if isinstance(data_key_list[i], list):
raw_response_data = [
{data_key_list[i][0]: raw_response_data[data_key_list[i][0]]},
{data_key_list[i][1]: raw_response_data[data_key_list[i][1]]}
]
else:
raw_response_data = raw_response_data.get(data_key_list[i])
if raw_response_data:
raw_response_data))
else:
logger.error("NO DATA FOUND WHEN ATTEMPTING EXTRACTION FROM FIELD \"fantasy_content\"")
sys.exit()
# iterate through list of data keys and drill down to final desired data field
for i in range(len(data_key_list)):
if isinstance(raw_response_data, list):
if isinstance(data_key_list[i], list):
reformatted = reformat_json_list(raw_response_data)
raw_response_data = [
{data_key_list[i][0]: reformatted[data_key_list[i][0]]},
{data_key_list[i][1]: reformatted[data_key_list[i][1]]}
]
else:
raw_response_data = reformat_json_list(raw_response_data)[data_key_list[i]]
else:
if isinstance(data_key_list[i], list):
raw_response_data = [
{data_key_list[i][0]: raw_response_data[data_key_list[i][0]]},
{data_key_list[i][1]: raw_response_data[data_key_list[i][1]]}
]
else:
raw_response_data = raw_response_data.get(data_key_list[i])
if raw_response_data:
logger.debug("Response (Yahoo fantasy data extracted from: {}): {}".format(data_key_list,
raw_response_data))
else:
logger.error("NO DATA FOUND WHEN ATTEMPTING EXTRACTION FROM FIELDS {}".format(data_key_list))
sys.exit()