def mailfile_to_mongo(db, root_dir, email_path): """Runs all the steps required for loading an email fresh from the file system into it's representation in MongoDB. """ msg = mailfile_to_message(email_path) folder = email_path.replace(root_dir+"/", '') email_doc = MaildirEmail.gen_from_message(msg) email_doc.folder = folder email_id = insert_email(db, email_doc) email_doc.id = email_id return email_doc
def line_handler(json_data): email_dict = obcene_convert_keys(json_data) email_doc = LuceneEmail(**email_dict) insert_email(db, email_doc)