import re

if __name__ == '__main__':
    dependency = dict()
    with open("[TODO]") as f:  # The dependency file generated by CLASSYCLE
        for lines in f:
            from_ent, to_ent = lines.split(" ")[1].strip(), lines.split(" ")[2].strip()
            if dependency.__contains__(from_ent):
                dependency[from_ent].append(to_ent)
            else:
                dependency[from_ent] = []
                dependency[from_ent].append(to_ent)
        print(dependency['org.junit.jupiter.api.parallel.ResourceLocks'])

    dependency_dot = dict()
    with open("files/dep/jdps-junit-5.4.2-dep.dot") as f: # The dependency file generated by JDEPS
        for lines in f:
            if not lines.__contains__("->"):
                continue
            pattern = r'[\s]+'
            from_ent, to_ent = re.split(pattern, lines)[1].strip().split("\"")[1], \
                               re.split(pattern, lines)[3].strip().split("\"")[1]
            if dependency_dot.__contains__(from_ent):
                dependency_dot[from_ent].append(to_ent)
            else:
                dependency_dot[from_ent] = []
                dependency_dot[from_ent].append(to_ent)
    print(dependency.__len__())
    print(dependency_dot.__len__())
    for key in dependency:
        if dependency_dot.__contains__(key):
            for value in dependency[key]:
                if dependency_dot.__contains__(key):
                    if not dependency_dot[key].__contains__(value):
                        print(key, "->", value)
        else:
            print("NO KEY ERROR", key)
