Index: utils/extract_vplan.py =================================================================== --- utils/extract_vplan.py +++ utils/extract_vplan.py @@ -30,7 +30,7 @@ VPlans.append(CurVPlan) CurVPlan = '' else: - m = re.search("(VF.*,UF.*), ", line) + m = re.match("graph.+(VF.*,UF.*), ", line) if m: name = re.sub('[^a-zA-Z0-9]', '', m.group(1)) Names.append(name) @@ -40,19 +40,18 @@ if len(VPlans) != len(Names): raise RuntimeError("Incongruent number of VPlans and respective names") -for i in range(len(VPlans)): +for name, vplan in zip(Names, VPlans): if args.png: - filename = 'VPlan' + Names[i] + '.png' - print("Exporting " + Names[i] + " to PNG via dot: " + filename) + filename = 'VPlan' + name + '.png' + print("Exporting " + name + " to PNG via dot: " + filename) p = subprocess.Popen([dot, '-Tpng', '-o', filename], encoding='utf-8', stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE) - out, err = p.communicate(input=VPlans[i]) + out, err = p.communicate(input=vplan) if err: raise RuntimeError("Error running dot: " + err) else: - filename = 'VPlan' + Names[i] + '.dot' + filename = 'VPlan' + name + '.dot' print("No visualisation requested, saving to file: " + filename) - out = open(filename, 'w') - out.write(VPlans[i]) - out.close() + with open(filename, 'w') as out: + out.write(vplan)