I have a list, I need to check whether all the elements of this list are in the .cfg file, if one of these elements is not found in the file, it is necessary to write the missing element in the file_diff.html file and run the sender() function. If all items from the list have been found, run the main() function. I implemented it like this, but only the first element(v[0]) is checked. But elif is also processed as if nothing from the list is in the file.
def validator():
v = ['ip arp inspection',
f'ip arp inspection vlan {l[2]}',
'ip dhcp snooping',
f'ip dhcp snooping vlan {l[2]}',
'ip dhcp snooping information option'
]
with open(f'/home/tftp/cfg/{today}/all/edgecore/{l[0]}.cfg', 'r') as val:
for line in val:
if all(word in line for word in v):
main()
elif not any(word in line for word in v):
with open('file_diff.html', 'w') as noname:
title = f"The configuration on switch {l[0]} do not valid"
noname.write(title)
sender()