X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/49e85177c669d793e84242983a1b1f430e47184e..30d60b272963b1b130ea80840af783ee9c146b97:/tools/platf_route_rulebased2full.py diff --git a/tools/platf_route_rulebased2full.py b/tools/platf_route_rulebased2full.py index 948ddbb505..191d473d14 100755 --- a/tools/platf_route_rulebased2full.py +++ b/tools/platf_route_rulebased2full.py @@ -7,38 +7,38 @@ # This program is free software; you can redistribute it and/or modify it # under the terms of the license (GNU LGPL) which comes with this package. -import sys, re +import sys +import re from lxml import etree xml = etree.parse(sys.argv[1]) for e in xml.xpath('//*[@routing="RuleBased"]'): - e.attrib['routing'] = "Full" - ids = e.xpath('./*[@id]/@id') - done = set() - for asr in e.xpath("./ASroute"): - src_ids = {} - dst_ids = {} - for id in ids: - src_s = re.search(r"%s"%asr.attrib['src'], id) - dst_s = re.search(r"%s"%asr.attrib['dst'], id) - if src_s : - src_ids[id] = src_s - if dst_s: - dst_ids[id] = dst_s - for sid, smat in src_ids.items(): - for did, dmat in dst_ids.items(): - todo = tuple(sorted((smat.group(1), dmat.group(1)))) - if todo not in done or asr.attrib.get("symmetrical")=="NO": - done.add(todo) - dasr = etree.tounicode(asr) - dasr = dasr.replace("$1src", smat.group(1)) - dasr = dasr.replace("$1dst", dmat.group(1)) - dasr = etree.fromstring(dasr) - dasr.tag = "__ASroute__" - dasr.attrib['src'] = sid - dasr.attrib['dst'] = did - asr.addnext(dasr) - asr.getparent().remove(asr) + e.attrib['routing'] = "Full" + ids = e.xpath('./*[@id]/@id') + done = set() + for asr in e.xpath("./ASroute"): + src_ids = {} + dst_ids = {} + for id in ids: + src_s = re.search(r"%s" % asr.attrib['src'], id) + dst_s = re.search(r"%s" % asr.attrib['dst'], id) + if src_s: + src_ids[id] = src_s + if dst_s: + dst_ids[id] = dst_s + for sid, smat in src_ids.items(): + for did, dmat in dst_ids.items(): + todo = tuple(sorted((smat.group(1), dmat.group(1)))) + if todo not in done or asr.attrib.get("symmetrical") == "NO": + done.add(todo) + dasr = etree.tounicode(asr) + dasr = dasr.replace("$1src", smat.group(1)) + dasr = dasr.replace("$1dst", dmat.group(1)) + dasr = etree.fromstring(dasr) + dasr.tag = "__ASroute__" + dasr.attrib['src'] = sid + dasr.attrib['dst'] = did + asr.addnext(dasr) + asr.getparent().remove(asr) print etree.tounicode(xml).replace("__ASroute__", "ASroute") -