import glob


def find_matched_sourcelists(ref_path,comp_path):
    """
    Generate a list of sourcelists found in both ref_path/logs and comp_path/logs.

    :param ref_path: input reference path
    :param comp_path: input comparision path
    :type ref_path: string
    :type comp_path: sting
    :return: list of sourcelists found in both ref_path/logs and comp_path/logs.
    """
    refList=[]
    compList=[]
    for item in glob.glob(ref_path+"/logs/*phot.txt"):
        refList.append(item.split("logs/")[-1])
    for item in glob.glob(ref_path+"*.ecsv"):
        refList.append(item)
    for item in glob.glob(comp_path+"/logs/*phot.txt"):
        compList.append(item.split("logs/")[-1])
    for item in glob.glob(comp_path+"*.ecsv"):
        compList.append(item)
    outList=list(set(refList).intersection(set(compList)))
    return(outList)