2 # -*- coding: utf-8 -*-
4 # Copyright (c) 2013-2014. The SimGrid Team.
7 # This program is free software; you can redistribute it and/or modify it
8 # under the terms of the license (GNU LGPL) which comes with this package.
12 from lxml import etree
14 xml = etree.parse(sys.argv[1])
15 for e in xml.xpath('//*[@routing="RuleBased"]'):
16 e.attrib['routing'] = "Full"
17 ids = e.xpath('./*[@id]/@id')
19 for asr in e.xpath("./ASroute"):
23 src_s = re.search(r"%s" % asr.attrib['src'], id)
24 dst_s = re.search(r"%s" % asr.attrib['dst'], id)
29 for sid, smat in src_ids.items():
30 for did, dmat in dst_ids.items():
31 todo = tuple(sorted((smat.group(1), dmat.group(1))))
32 if todo not in done or asr.attrib.get("symmetrical") == "NO":
34 dasr = etree.tounicode(asr)
35 dasr = dasr.replace("$1src", smat.group(1))
36 dasr = dasr.replace("$1dst", dmat.group(1))
37 dasr = etree.fromstring(dasr)
38 dasr.tag = "__ASroute__"
39 dasr.attrib['src'] = sid
40 dasr.attrib['dst'] = did
42 asr.getparent().remove(asr)
44 print etree.tounicode(xml).replace("__ASroute__", "ASroute")