'Returns a column spec of table.
This is what LaTeX calls the \'preamble argument\' of the used table environment.
.. note:: the ``\X`` and ``T`` column type specifiers are defined in ``sphinx.sty``.'

def get_colspec(self):

    if self.colspec:
        return self.colspec
    elif (self.colwidths and ('colwidths-given' in self.classes)):
        total = sum(self.colwidths)
        colspecs = [('\\X{%d}{%d}' % (width, total)) for width in self.colwidths]
        return ('{|%s|}\n' % '|'.join(colspecs))
    elif self.has_problematic:
        return ('{|*{%d}{\\X{1}{%d}|}}\n' % (self.colcount, self.colcount))
    elif (self.get_table_type() == 'tabulary'):
        return (('{|' + ('T|' * self.colcount)) + '}\n')
    elif self.has_oldproblematic:
        return ('{|*{%d}{\\X{1}{%d}|}}\n' % (self.colcount, self.colcount))
    else:
        return (('{|' + ('l|' * self.colcount)) + '}\n')
