Example #1
0
 def entity_to_id(cl, entity: ProvEntity, tree: Tree) -> str:
     """
     convert a provenence entity to a [leaf] node identifier of a tree.
     tree: can be a project or subproject tree
     """
     try:
         epath = entity.localpart.split("/")
     except AttributeError:
         epath = entity.identifier.localpart.split("/")
     epath = ["project", "subproject"] + epath
     filtfun = lambda nodeli: all([n.tag in epath for n in nodeli])
     nodesli = list(tree.filter_to_leaves(filtfun))
     idli = [nli[-1].identifier for nli in nodesli]
     assert len(idli) == 1, "Error: Multiple paths %s match entities" % idli
     return idli[0]