2 # -*- coding: utf-8 -*-
7 xml = etree.parse(sys.argv[1])
8 for e in xml.xpath('//*[@routing="RuleBased"]'):
9 e.attrib['routing'] = "Full"
10 ids = e.xpath('./*[@id]/@id')
12 for asr in e.xpath("./ASroute"):
16 src_s = re.search(r"%s"%asr.attrib['src'], id)
17 dst_s = re.search(r"%s"%asr.attrib['dst'], id)
22 for sid, smat in src_ids.items():
23 for did, dmat in dst_ids.items():
24 todo = tuple(sorted((smat.group(1), dmat.group(1))))
25 if todo not in done or asr.attrib.get("symmetrical")=="NO":
27 dasr = etree.tounicode(asr)
28 dasr = dasr.replace("$1src", smat.group(1))
29 dasr = dasr.replace("$1dst", dmat.group(1))
30 dasr = etree.fromstring(dasr)
31 dasr.tag = "__ASroute__"
32 dasr.attrib['src'] = sid
33 dasr.attrib['dst'] = did
35 asr.getparent().remove(asr)
37 print etree.tounicode(xml).replace("__ASroute__", "ASroute")