import difflib


def compareDependencyFiles(file1, file2):
    """
    Compare two files with lists of jpackages, to find out which ones are new, which ones have been removed, and which ones have been changed between the two.
    The files need to be compiled with releaseMgmt.createDependencyFile()

    Parameters:
    - file1, file2: string - the pathnames of the files to be compared

    Returns:
    - a list of strings, each string is a line starting with '+' if the line is added in file2, '-' if it is removed from file2, '?' for some additional explanation w.r.t. possible changes
    """
    with open(file1, 'r') as f1:
        f1stringlist = f1.readlines()
    with open(file2, 'r') as f2:
        f2stringlist = f2.readlines()
    d = difflib.Differ()
    return list(d.compare(f1stringlist, f2stringlist))