import os
import glob


def get_participant_files(path, name):
    """Function for getting all of the files which were generated by the participant

    Keyword arguments:
    path -- path where all of the files are held
    name -- name of the participant
    Return: return a list of all file names which had the participant in them
    """

    path = os.path.join(path, name + "_*")
    path2 = os.path.join(path, "*_" + name + "_*")
    files = glob.glob(path)
    files += glob.glob(path2)

    return files


def split_conversation(conv, participant1, participant2):
    list_conv = conv.splitlines()
    conv1 = []
    conv2 = []
    for line in list_conv:
        if line.startswith(participant1):
            conv1.append(line)
        elif line.startswith(participant2):
            conv2.append(line)

    return "\n\n".join(conv1), "\n\n".join(conv2)
