Please help sir,where i am wrong.getting this output in project 1


#1

import eml_parser
import os, pathlib, re
def EmailList(path, select, matches, where = None):
email_paths = []
all_emails = []
for path, subdirs, files in os.walk(path):
for file in files:
if(file.endswith(‘sqlite’)):
continue

        email_paths.append(pathlib.PurePath(path, file))
for email in email_paths:
    raw_email = ""
    with open(email, 'rb') as raw_data:
        raw_email = raw_data.read()
    parsed_eml = eml_parser.eml_parser.decode_email_b(raw_email)
    t = 0
    s_email = []
    if where: 
        if where in select:
            try:
                eml = "None"
                e = parsed_eml["header"][where]
                if len(e) < 2:
                    e = e[0]
                eml=re.findall(matches,e)[0]
                s_email.append(eml)
                all_emails.append(tuple(s_email))
            except:
                pass
    else:
        try:
            for i in select:
                try:
                    eml = "None"
                    e = parsed_eml["header"][i]
                    if len(e) < 2:
                        e = e[0]
                    eml=re.findall(matches,e)[0]
                    s_email.append(eml)
                except:
                    pass
            
            all_emails.append(tuple(s_email))
        except:
            pass
    
    break   ############### Remove This Break if You Want all emails..
    
print(all_emails)

EmailList(path="GYB-GMail-Backup-kretika.tiwari99@gmail.com/", select=[“to”, “from”, “subject”],
matches=".+" )

OUTPUT:
[]