def setPathTreeStatus(pathTree: Tree): """ set values of tree entries to true or false, showing if they can be resolved or not return True if all members are found, False if not """ fullyResolved = True for branch in pathTree.allBranches(includeSelf=False): modulePath = branch.address if branch.isLeaf: modulePath = modulePath[:-1] modLookup = checkModuleLoad(modulePath) if modLookup is None: branch.v["found"] = False fullyResolved = False continue if branch.isLeaf: try: memberLookup = getattr(modLookup, branch.name) except: branch.v["found"] = False fullyResolved = False continue branch.v["found"] = True continue return fullyResolved
def pathsToTokenTree(pythonPathMap: Ty.Dict[str, str], stripFound=False): """build tree of given tokens""" pathTree = Tree("paths") for pythonPath, member in pythonPathMap.items(): branch = pathTree(*pythonPath.split(".")) leaf = branch(member) for branch in pathTree.allBranches(includeSelf=False): branch.v = {"found": False, "isMember": branch.isLeaf} return pathTree