2 # -*- coding: utf-8 -*-
4 # grep -ohrI 'bw=".*"' . | sort | uniq
6 import sys, fnmatch, os
7 from decimal import Decimal
11 return re.sub(r"(\.\d*?)0*$", r"\1", dec.to_eng_string()).rstrip(".")
13 def format(xml, formats, attrib):
15 m = re.search(r'%s="(.*?)"'%attrib, xml)
27 tmp = "%s%s"%(to_str(d), f)
31 print "Error with:", val
33 m = re.search(r'%s="(.*?)"'%attrib, xml)
39 return sorted(((Decimal(i), j) for i,j in list), key=lambda x: x[0], reverse=True)
41 for root, dirnames, filenames in os.walk(sys.argv[1]):
42 for filename in fnmatch.filter(filenames, '*.xml'):
43 print root, dirnames, filename
44 path = os.path.join(root, filename)
45 xml = open(path).read()
47 power_formats = formats([( "1E0", "f"),
55 xml = format(xml, power_formats, "power")
57 bandwidth_formats = formats([( "1E0", "Bps"),
62 xml = format(xml, bandwidth_formats, "bandwidth")
63 xml = format(xml, bandwidth_formats, "bw")
64 xml = format(xml, bandwidth_formats, "bb_bw")
65 xml = format(xml, bandwidth_formats, "bw_in")
66 xml = format(xml, bandwidth_formats, "bw_out")
68 time_formats = formats([( "1E-12", "ps"),
77 xml = format(xml, time_formats, "latency")
78 xml = format(xml, time_formats, "lat")
79 xml = format(xml, time_formats, "bb_lat")
82 file = open(path, "w")