'this function takes a list a dictionaries to display in columns. Dictionnaries keys are the columns names.
All dictionaries must have the same keys.
wl is a whitelist of column names to display
bl is a blacklist of columns names to hide'

@staticmethod
def table_format(diclist, wl=[], bl=[]):

    res = ''
    if diclist:
        diclist = obj2utf8(diclist)
        keys = [x for x in diclist[0].iterkeys()]
        if wl:
            keys = [x for x in wl if (x in keys)]
        if bl:
            keys = [x for x in keys if (x not in bl)]
        titlesdic = {}
        for k in keys:
            titlesdic[k] = k
        diclist.insert(0, titlesdic)
        colsize = get_columns_size(diclist)
        i = 0
        for c in diclist:
            if (i == 1):
                res += (('-' * sum([(k + 2) for k in [y for (x, y) in colsize.iteritems() if (x in titlesdic)]])) + '\n')
            i += 1
            for name in keys:
                if (c[name] is not unicode):
                    value = str(c[name]).strip()
                else:
                    value = c[name].strip()
                utf8align = (len(value) - len(value.decode('utf8', errors='replace')))
                escalign = len(''.join(re.findall('(\x1b[^m]+m)', value)))
                res += value.ljust((((colsize[name] + 2) + utf8align) + escalign))
            res += '\n'
    return res
