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.
11 from lxml import etree
13 xml = etree.parse(sys.argv[1])
14 for e in xml.xpath('//*[@routing="RuleBased"]'):
15 e.attrib['routing'] = "Full"
16 ids = e.xpath('./*[@id]/@id')
18 for asr in e.xpath("./ASroute"):
22 src_s = re.search(r"%s"%asr.attrib['src'], id)
23 dst_s = re.search(r"%s"%asr.attrib['dst'], id)
28 for sid, smat in src_ids.items():
29 for did, dmat in dst_ids.items():
30 todo = tuple(sorted((smat.group(1), dmat.group(1))))
31 if todo not in done or asr.attrib.get("symmetrical")=="NO":
33 dasr = etree.tounicode(asr)
34 dasr = dasr.replace("$1src", smat.group(1))
35 dasr = dasr.replace("$1dst", dmat.group(1))
36 dasr = etree.fromstring(dasr)
37 dasr.tag = "__ASroute__"
38 dasr.attrib['src'] = sid
39 dasr.attrib['dst'] = did
41 asr.getparent().remove(asr)
43 print etree.tounicode(xml).replace("__ASroute__", "ASroute")