# Path: config/config.py
# CONFIG = Config(dictionary)
# 
# Path: bigbang/utils.py
# def get_paths_to_files_in_directory(
#     directory: str, file_dsc: str = "*"
# ) -> List[str]:
#     """Get paths of all files matching file_dsc in directory"""
#     template = f"{directory}{file_dsc}"
#     file_paths = glob.glob(template)
#     return file_paths
# 
# def get_paths_to_dirs_in_directory(
#     directory: str, folder_dsc: str = "*"
# ) -> List[str]:
#     """Get paths of all directories matching file_dsc in directory"""
#     template = f"{directory}{folder_dsc}"
#     dir_paths = glob.glob(template)
#     # normalize directory paths
#     dir_paths = [dir_path + "/" for dir_path in dir_paths]
#     return dir_paths
# 
# Path: bigbang/analysis/utils.py
# def get_index_of_msgs_with_subject(
#     df: pd.DataFrame,
#     return_boolmask: bool = False,
# ) -> np.array:
#     boolmask = np.array(
#         [
#             True if (isinstance(sb, str)) and not pd.isna(sb) else False
#             for sb in df.loc[:, "subject"].values
#         ],
#         dtype="bool",
#     )
#     index = np.arange(len(boolmask))[boolmask]
#     if return_boolmask:
#         return boolmask
#     else:
#         index = df.loc[boolmask].index.values
#         return index
# 
# def get_index_of_msgs_with_datetime(
#     df: pd.DataFrame,
#     return_boolmask: bool = False,
# ) -> np.array:
#     cond = lambda x: (
#         True
#         if (isinstance(x, str) and (len(x) > 10))
#         or isinstance(x, datetime.datetime)
#         and not pd.isna(x)
#         else False
#     )
#     boolmask = np.array(
#         [cond(dt) for dt in df.loc[:, "date"].values], dtype="bool"
#     )
#     if return_boolmask:
#         return boolmask
#     else:
#         index = df.loc[boolmask].index.values
#         return index


import copy
import datetime
import email
import logging
import mailbox
import os
import re
import subprocess
import time
import warnings
import networkx as nx
import numpy as np
import pandas as pd
import requests
import yaml
import bigbang.bigbang_io as bio
from mailbox import mboxMessage
from pathlib import Path
from typing import Dict, List, Optional, Tuple, Union
from bs4 import BeautifulSoup
from config.config import CONFIG
from bigbang.utils import (
    get_paths_to_files_in_directory,
    get_paths_to_dirs_in_directory,
)
from bigbang.analysis.utils import (
    get_index_of_msgs_with_subject,
    get_index_of_msgs_with_datetime,
)


class ListservMailListDomain:
    """
    Parameters
    ----------
    name
        The of whom the mail list domain is (e.g. 3GPP, IEEE, ...)
    filedsc
        The file description of the mail list domain
    lists
        A list containing the mailing lists as `ListservMailList` types

    Methods
    -------
        get_mlistscount_per_institution
    """

    def __init__(self, name: str, filedsc: str, lists: pd.DataFrame):
        self.name = name
        self.filedsc = filedsc
        self.df = lists

    @classmethod
    def from_mbox(
        cls,
        name: str,
        directorypath: str,
        filedsc: str = "*.mbox",
    ) -> "ListservMailListDomain":

# Path: config/config.py
# CONFIG = Config(dictionary)
# 
# Path: bigbang/utils.py
# def get_paths_to_files_in_directory(
#     directory: str, file_dsc: str = "*"
# ) -> List[str]:
#     """Get paths of all files matching file_dsc in directory"""
#     template = f"{directory}{file_dsc}"
#     file_paths = glob.glob(template)
#     return file_paths
# 
# def get_paths_to_dirs_in_directory(
#     directory: str, folder_dsc: str = "*"
# ) -> List[str]:
#     """Get paths of all directories matching file_dsc in directory"""
#     template = f"{directory}{folder_dsc}"
#     dir_paths = glob.glob(template)
#     # normalize directory paths
#     dir_paths = [dir_path + "/" for dir_path in dir_paths]
#     return dir_paths
# 
# Path: bigbang/analysis/utils.py
# def get_index_of_msgs_with_subject(
#     df: pd.DataFrame,
#     return_boolmask: bool = False,
# ) -> np.array:
#     boolmask = np.array(
#         [
#             True if (isinstance(sb, str)) and not pd.isna(sb) else False
#             for sb in df.loc[:, "subject"].values
#         ],
#         dtype="bool",
#     )
#     index = np.arange(len(boolmask))[boolmask]
#     if return_boolmask:
#         return boolmask
#     else:
#         index = df.loc[boolmask].index.values
#         return index
# 
# def get_index_of_msgs_with_datetime(
#     df: pd.DataFrame,
#     return_boolmask: bool = False,
# ) -> np.array:
#     cond = lambda x: (
#         True
#         if (isinstance(x, str) and (len(x) > 10))
#         or isinstance(x, datetime.datetime)
#         and not pd.isna(x)
#         else False
#     )
#     boolmask = np.array(
#         [cond(dt) for dt in df.loc[:, "date"].values], dtype="bool"
#     )
#     if return_boolmask:
#         return boolmask
#     else:
#         index = df.loc[boolmask].index.values
#         return index


# Path: bigbang/analysis/listserv.py
import copy
import datetime
import email
import logging
import mailbox
import os
import re
import subprocess
import time
import warnings
import networkx as nx
import numpy as np
import pandas as pd
import requests
import yaml
import bigbang.bigbang_io as bio
from mailbox import mboxMessage
from pathlib import Path
from typing import Dict, List, Optional, Tuple, Union
from bs4 import BeautifulSoup
from config.config import CONFIG
from bigbang.utils import (
    get_paths_to_files_in_directory,
    get_paths_to_dirs_in_directory,
)
from bigbang.analysis.utils import (
    get_index_of_msgs_with_subject,
    get_index_of_msgs_with_datetime,
)



class ListservMailListDomain:
    """
    Parameters
    ----------
    name
        The of whom the mail list domain is (e.g. 3GPP, IEEE, ...)
    filedsc
        The file description of the mail list domain
    lists
        A list containing the mailing lists as `ListservMailList` types

    Methods
    -------
        get_mlistscount_per_institution
    """

    def __init__(self, name: str, filedsc: str, lists: pd.DataFrame):
        self.name = name
        self.filedsc = filedsc
        self.df = lists

    @classmethod
    def from_mbox(
        cls,
        name: str,
        directorypath: str,
        filedsc: str = "*.mbox",
    ) -> "ListservMailListDomain":

        filepaths = get_paths_to_files_in_directory(directorypath, filedsc)