__author__ = 'marcusmorgenstern'
__mail__ = ''

from tabulate import tabulate
from utils import PhysicsQuantities as PQ
from base import Calculators as Calcs
from BasePlugin import BasePlugin

class Column:
    def __init__(self, quantity):
        self.quantity = quantity

    def __eq__(self, other):
        return (self.quantity == other.quantity)


class TableMaker(BasePlugin):
    def __init__(self, config):
        self.cols = config['cols']

    def invoke(self, data):
        for det, vals in data.items():
            tab = dict(filter(lambda c: c[0] in self.cols, vals.iteritems()))
            """
            work around to stringify
            """
            if 'Isotope' in self.cols:
                tab['Isotope'] = [i.__str__() for i in tab['Isotope']]
            _table = tabulate(tab, tablefmt='latex', floatfmt=".2f")
            print _table

    def _writeTable(self, data):
        pass

@@ -50,112 +50,68 @@
 rom 
-tabulate import tabulate%0Afrom utils import PhysicsQuantities as PQ%0Afrom base import Calculators as Calcs
+collections import OrderedDict%0Afrom tabulate import tabulate
 %0Afro
@@ -141,16 +141,49 @@
 ePlugin%0A
+from operator import itemgetter%0A%0A
 %0Aclass C
@@ -524,12 +524,26 @@
 b = 
-dict
+OrderedDict(sorted
 (fil
@@ -592,17 +592,170 @@
 items())
-)
+,%0A                                     cmp=lambda x, y: self.cols.index(x) - self.cols.index(y),%0A                                     key=itemgetter(0)))%0A
 %0A       
@@ -926,16 +926,16 @@
 tope'%5D%5D%0A
+
         
@@ -999,76 +999,4 @@
 f%22)%0A
-            print _table%0A%0A    def _writeTable(self, data):%0A        pass%0A

fix ordering bug