# 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,
)
        if "localpart" in list(per_address_field.keys()):
            _addr = pd.Series(
                [
                    ListservMailList.get_name_localpart_domain(addr)[1]
                    for addr in mlist["from"].values
                ],
                index=mlist.index.values,
            ).dropna()
            mlist = mlist.loc[_addr.index]
            mlist = mlist[_addr.isin(per_address_field["localpart"])]
        return ListservMailList.from_pandas_dataframe(
            df=mlist,
            name=self.name,
            filepath=self.filepath,
        )

    def crop_by_subject(self, match=str, place: int = 2) -> "ListservMailList":
        """
        Parameters
        ----------
        match : Only keep messages with subject lines containing `match` string.
        place : Define how to filter for `match`. Use on of the following methods:
            0 = Using Regex expression
            1 = String ends with match
            2 =

        Returns
        -------
        `ListservMailList` object cropped to message subject.
        """

# 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,
)

        if "localpart" in list(per_address_field.keys()):
            _addr = pd.Series(
                [
                    ListservMailList.get_name_localpart_domain(addr)[1]
                    for addr in mlist["from"].values
                ],
                index=mlist.index.values,
            ).dropna()
            mlist = mlist.loc[_addr.index]
            mlist = mlist[_addr.isin(per_address_field["localpart"])]
        return ListservMailList.from_pandas_dataframe(
            df=mlist,
            name=self.name,
            filepath=self.filepath,
        )

    def crop_by_subject(self, match=str, place: int = 2) -> "ListservMailList":
        """
        Parameters
        ----------
        match : Only keep messages with subject lines containing `match` string.
        place : Define how to filter for `match`. Use on of the following methods:
            0 = Using Regex expression
            1 = String ends with match
            2 =

        Returns
        -------
        `ListservMailList` object cropped to message subject.
        """

        index = get_index_of_msgs_with_subject(self.df)