# Path: config/config.py
# CONFIG = Config(dictionary)
# 
# Path: bigbang/analysis/utils.py
# def get_index_of_msgs_with_subject(
#     df: pd.DataFrame,
#     return_boolmask: bool = False,
# ) -> np.array:
# def get_index_of_msgs_with_datetime(
#     df: pd.DataFrame,
#     return_boolmask: bool = False,
# ) -> np.array:
# def clean_addresses(df: pd.DataFrame) -> pd.DataFrame:
# def clean_subject(df: pd.DataFrame) -> pd.DataFrame:
# def clean_datetime(df: pd.DataFrame) -> pd.DataFrame:
# def extract_email(from_field):
# def extract_domain(from_field):
# def domain_entropy(domain, froms):
# 
# Path: bigbang/data_types.py



import datetime
import glob
import os
import re
import logging
import mailbox
import numpy as np
import pandas as pd
from typing import Dict, List, Optional, Tuple, Union
from mailbox import mboxMessage
from pathlib import Path
from config.config import CONFIG
from bigbang.analysis import utils
from bigbang.data_types import Message, MailList, MailListDomain
    Saves a List[mailbox.mboxMessage] as .mbox file.
    For a clearer definition on what a mailing list is, see:
    bigbang.ingress.abstract.AbstractList
    """
    # create directory path if it doesn't exist yet
    Path(dir_out).mkdir(parents=True, exist_ok=True)
    # create filepath
    filepath = f"{dir_out}/{filename}.mbox"
    # delete file if there is one at the filepath
    if Path(filepath).is_file():
        Path(filepath).unlink()
    mbox = mailbox.mbox(filepath)
    mbox.lock()
    for msg in msgs:
        try:
            mbox.add(msg)
        except Exception as e:
            logger.info(
                f'Add to .mbox error for {msg["Archived-At"]} because, {e}'
            )
    mbox.flush()
    mbox.unlock()
    logger.info(f"The list {filename} is saved at {filepath}.")
    mbox.lock()
    mbox.add(msg)
    mbox.flush()
    mbox.unlock()


def mlistdom_to_dict(

# Path: config/config.py
# CONFIG = Config(dictionary)
# 
# Path: bigbang/analysis/utils.py
# def get_index_of_msgs_with_subject(
#     df: pd.DataFrame,
#     return_boolmask: bool = False,
# ) -> np.array:
# def get_index_of_msgs_with_datetime(
#     df: pd.DataFrame,
#     return_boolmask: bool = False,
# ) -> np.array:
# def clean_addresses(df: pd.DataFrame) -> pd.DataFrame:
# def clean_subject(df: pd.DataFrame) -> pd.DataFrame:
# def clean_datetime(df: pd.DataFrame) -> pd.DataFrame:
# def extract_email(from_field):
# def extract_domain(from_field):
# def domain_entropy(domain, froms):
# 
# Path: bigbang/data_types.py



# Path: bigbang/bigbang_io.py
import datetime
import glob
import os
import re
import logging
import mailbox
import numpy as np
import pandas as pd
from typing import Dict, List, Optional, Tuple, Union
from mailbox import mboxMessage
from pathlib import Path
from config.config import CONFIG
from bigbang.analysis import utils
from bigbang.data_types import Message, MailList, MailListDomain

    Saves a List[mailbox.mboxMessage] as .mbox file.
    For a clearer definition on what a mailing list is, see:
    bigbang.ingress.abstract.AbstractList
    """
    # create directory path if it doesn't exist yet
    Path(dir_out).mkdir(parents=True, exist_ok=True)
    # create filepath
    filepath = f"{dir_out}/{filename}.mbox"
    # delete file if there is one at the filepath
    if Path(filepath).is_file():
        Path(filepath).unlink()
    mbox = mailbox.mbox(filepath)
    mbox.lock()
    for msg in msgs:
        try:
            mbox.add(msg)
        except Exception as e:
            logger.info(
                f'Add to .mbox error for {msg["Archived-At"]} because, {e}'
            )
    mbox.flush()
    mbox.unlock()
    logger.info(f"The list {filename} is saved at {filepath}.")
    mbox.lock()
    mbox.add(msg)
    mbox.flush()
    mbox.unlock()


def mlistdom_to_dict(

    mlists: MailListDomain, include_body: bool = True