Example #1
0
def obcene_to_mongo(db, filename):
    """Runs all the steps required for loading an email fresh from the
    file system into it's representation in MongoDB.
    """
    def line_handler(json_data):
        email_dict = obcene_convert_keys(json_data)
        email_doc = LuceneEmail(**email_dict)
        insert_email(db, email_doc)

    process_json_feed(line_handler, filename)
Example #2
0
def obcene_header_count(filename):
    """This function takes the keys from line_dict, eg the email headers, and
    accumulates a count in keys_found.
    """
    keys_found = dict()
    
    def line_handler(line_dict):
        """Loops over each key (eg. mail header)"""
        for header in line_dict.keys():
            count_header_instances(header, keys_found)
            
    process_json_feed(line_handler, filename)
    return keys_found