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.
10 # grep -ohrI 'bw=".*"' . | sort | uniq
12 import sys, fnmatch, os
13 from decimal import Decimal
17 return re.sub(r"(\.\d*?)0*$", r"\1", dec.to_eng_string()).rstrip(".")
19 def format(xml, formats, attrib):
21 m = re.search(r'%s="(.*?)"'%attrib, xml)
33 tmp = "%s%s"%(to_str(d), f)
37 print "Error with:", val
39 m = re.search(r'%s="(.*?)"'%attrib, xml)
45 return sorted(((Decimal(i), j) for i,j in list), key=lambda x: x[0], reverse=True)
47 for root, dirnames, filenames in os.walk(sys.argv[1]):
48 for filename in fnmatch.filter(filenames, '*.xml'):
49 print root, dirnames, filename
50 path = os.path.join(root, filename)
51 xml = open(path).read()
53 power_formats = formats([( "1E0", "f"),
61 xml = format(xml, power_formats, "power")
63 bandwidth_formats = formats([( "1E0", "Bps"),
68 xml = format(xml, bandwidth_formats, "bandwidth")
69 xml = format(xml, bandwidth_formats, "bw")
70 xml = format(xml, bandwidth_formats, "bb_bw")
71 xml = format(xml, bandwidth_formats, "bw_in")
72 xml = format(xml, bandwidth_formats, "bw_out")
74 time_formats = formats([( "1E-12", "ps"),
83 xml = format(xml, time_formats, "latency")
84 xml = format(xml, time_formats, "lat")
85 xml = format(xml, time_formats, "bb_lat")
88 file = open(path, "w")