I have extracted some data stored in a json file. Based on all data we need to which all element missing:
cookie_notice = data['Column Names']['Cookie Notice']
possible values:
- 'n/a'
- valid extracted link
- not found
So similar data for all the json values. Considering when only each element has n/a or not found like missing cookie notice, cookie_site_link, banner_cookielink, etc
Query: print which all elements has n/a or not found
- which method helps to figure out what element missing instead of going with 30 - 40 or many if else condition.
- which is better way to configure using python.
OtAutoBlock = data['CookieSolution'][0]['OneTrust']
logging.info('ot1 %s', OtAutoBlock)
optanon_category = data['CookieSolution'][0]['class']
logging.info('opta2 %s', optanon_category)
data_optanongroupid =data['CookieSolution'][0]['data-optanongroupid']
logging.info('opta2 %s', data_optanongroupid)
tgdach = data['CookieSolution'][1]['CookieQ']
logging.info('tgdach %s', tgdach)
cookie_notice = data['Column Names']['Cookie Notice']
logging.info('cn %s', cookie_notice)
cookie_site_link = data['Column Names']['Cookie Site Link']
logging.info('cnl%s',cookie_site_link)
privacy_notice = data['Column Names']['Privacy Notice']
logging.info('pn %s',privacy_notice)
privacy_site_link = data['Column Names']['Privacy Site Link']
logging.info('psl %s',privacy_site_link)
banner_cookielink = data['Column Names']['Banner Cookie Site Link']
logging.info("banner %s",banner_cookielink)
if-elif sample statements
if(cookie_site_link == 'not found' and privacy_site_link == 'not found' and cookie_notice == 'not found' and privacy_notice == 'not found'):
fixup(data['Column Names'],"Error Message", 'Cookie notice link is missing in the banner and Cookie notice label, link, Privacy notice label, link mismatch against abc.com')
elif(cookie_notice == 'not found' and cookie_site_link =='not found'):
fixup(data['Column Names'],"Error Message",'Cookie notice link is missing in the banner,Cookie notice label and Cookie notice link mismatch against abc.com')
elif(privacy_notice == 'not found'and privacy_site_link == 'not found'):
fixup(data['Column Names'],"Error Message",'Cookie notice link is missing in the banner,Privacy notice label and Privacy notice link mismatch against abc.com')
else:
fixup(data['Column Names'],"Error Message", 'Cookie notice link is missing in the banner')
Aucun commentaire:
Enregistrer un commentaire