importtempfileimportos.pathimportsubprocessDOT_FILE="""strict graph { a -- b b -- a a -- c}"""tmp=tempfile.TemporaryDirectory()dot_file=os.path.join(tmp.name,'dot_file.dot')xdot_txt=os.path.join(tmp.name,'xdot.txt')withopen(dot_file,'w')asf:f.write(DOT_FILE)subprocess.call(f"dot -T plain-ext -o {xdot_txt}{dot_file}")classNode(object):def__init__(self):self.name=""self.pos_X=0self.pos_Y=0self.size_X=0self.size_Y=0self._inputs=[]self._outputs=[]defaddInputs(self,n):ifnnotinself._inputs:self._inputs.append(n)defaddOutputs(self,n):ifnnotinself._outputs:self._outputs.append(n)nodes={}withopen(xdot_txt,'r')asf:foriinf.readlines():print(i)buff=i.split(" ")ifbuff[0]=="node":node=Node()node.name=buff[1]node.pos_X=float(buff[2])node.pos_Y=float(buff[3])node.size_X=float(buff[4])node.size_Y=float(buff[5])nodes[buff[1]]=nodeelifbuff[0]=="edge":nodes[buff[1]].addOutputs(nodes[buff[2]])nodes[buff[2]].addInputs(nodes[buff[1]])print(nodes)tmp.cleanup()