for type_key, type in TYPES.iteritems():
for sub_type_key, sub_type in type.iteritems():
for sig in sub_type['signatures']:
it should be:
for type_key, type in TYPES.iteritems():
for sig in type['signatures']:
But "type" is a poor choice of name in this case ... you do not want to obscure the embedded file.
Essentially, type_key has a name (hotmail or gmail), and type has a dictionary, which is the value associated with this key. So the type ['signatureatures] is what you want.
, "gmail" ; 'type_key' type['type'].
, , : (: )
providers = {
'hotmail':{
'type':'hotmail',
'lookup':'mixed',
'dkim': 'no',
'signatures':[
'|S|Return-Path: postmaster@hotmail.com',
'|R|^Return-Path:\s*[^@]+@(?:hot|msn)',
'^Received: from .*hotmail.com$']
},
'gmail':{
'type':'gmail',
'lookup':'mixed',
'dkim': 'yes',
'signatures':['|S|Subject: unsubscribe','','','']
}
}
for provider, provider_info in providers.iteritems():
for sig in provicer_info['signatures']:
if ("|S|" in sig):
clean_sig = sig[3:len(sig)]
if (clean_sig in file_contents):
sig_match += 1
elif ("|R|" in sig):
clean_sig = sig[3:len(sig)]
if (sig_match == sig.count):
return provider
return None