[Checkins] SVN: bbkit/trunk/ Use PrettyTable to create table
Baiju M
baiju.m.mail at gmail.com
Tue Mar 2 21:37:39 EST 2010
Log message for revision 109582:
Use PrettyTable to create table
(Thanks to Stephan Richter for the pointer)
Changed:
U bbkit/trunk/buildout.cfg
U bbkit/trunk/scripts/comparison_chart.py
-=-
Modified: bbkit/trunk/buildout.cfg
===================================================================
--- bbkit/trunk/buildout.cfg 2010-03-03 02:36:27 UTC (rev 109581)
+++ bbkit/trunk/buildout.cfg 2010-03-03 02:37:39 UTC (rev 109582)
@@ -4,6 +4,7 @@
test-bluebream
test-community
depgraph
+ py
extensions = mr.developer
extends = bluebream.cfg
community.cfg
@@ -17,6 +18,7 @@
z3c.recipe.compattest = 0.9
z3c.recipe.depgraph = 0.5
mr.developer = 1.9
+PrettyTable = 0.5
[test-ztk]
recipe = z3c.recipe.compattest
@@ -42,3 +44,8 @@
extras = True
variants = base
scc
+
+[py]
+recipe = zc.recipe.egg
+eggs = PrettyTable
+interpreter = py
Modified: bbkit/trunk/scripts/comparison_chart.py
===================================================================
--- bbkit/trunk/scripts/comparison_chart.py 2010-03-03 02:36:27 UTC (rev 109581)
+++ bbkit/trunk/scripts/comparison_chart.py 2010-03-03 02:37:39 UTC (rev 109582)
@@ -1,27 +1,32 @@
from ConfigParser import SafeConfigParser
+from prettytable import PrettyTable
def process_file(file_name):
config_parser = SafeConfigParser()
config_parser.read(file_name)
- section_attrs = dict(config_parser.items('versions'))
- return section_attrs
+ versions = dict(config_parser.items('versions'))
+ return versions
-if __name__ == '__main__':
- bb_section_attrs = process_file('releases/bluebream-1.0a2.cfg')
- zope_section_attrs = process_file('releases/zope-3.4.0.cfg')
- for key, value in zope_section_attrs.iteritems():
- print "+"+ ''.rjust(31, '-') + "+" + ''.rjust(25, '-') + "+" + ''.rjust(54, '-') + "+"
- key_len = len(key)
- if key in bb_section_attrs:
- bb_len = len(bb_section_attrs[key])
- rjust = 48 if (bb_len==5) else 47
- print "|", key.ljust(29), "|", value.ljust(23), "|", bb_section_attrs[key], "|".rjust(rjust)
- else:
- #print "|", key.ljust(29), "|", value, "|".rjust(19), "|".rjust(54)
- rjust = 19 if (len(value)==5) else 21
- print "|", key.ljust(29), "|".rjust(rjust), "|".rjust(10), value, "|".rjust(54)
- for key, value in bb_section_attrs.iteritems():
- if key not in zope_section_attrs:
- rjust = 19 if (len(value)==5) else 21
- print "|", key.ljust(29), "|", value, "|".rjust(rjust), "|".rjust(54)
- print "+"+ ''.rjust(31, '-') + "+" + ''.rjust(25, '-') + "+" + ''.rjust(54, '-') + "+"
+new = process_file('releases/bluebream-1.0a2.cfg')
+old = process_file('releases/zope-3.4.0.cfg')
+
+chart = PrettyTable(["Package Name", "Zope 3.4.0", "BlueBream 1.0.0"])
+chart.set_field_align("Package Name", "l")
+chart.set_padding_width(1)
+chart.set_field_align("Zope 3.4.0", "l")
+chart.set_padding_width(1)
+chart.set_field_align("BlueBream 1.0.0", "l")
+chart.set_padding_width(1)
+
+data = []
+
+for package, version in new.items():
+ if package in old:
+ data.append([package, old[package], version])
+ else:
+ data.append([package, '', version])
+
+for row in data:
+ chart.add_row(row)
+
+chart.printt(hrules=1)
More information about the checkins
mailing list