# Path: src/sii/lib/printing/helpers.py
# def escape_tex(string):
#     chars = '%|\$|&'
# 
#     return re.sub('(?<!\\\\)({0})'.format(chars), r'\\\1', string)
# 
# Path: src/sii/lib/printing/TemplateElement.py
# class TemplateElement(object):
# 
#     @property
#     def resources(self):
#         """ Requires the return of a list of `Resource` object providing
#         the filename the template is going to expect, and the data that
#         should be inside of it.
# 
#         In case of none, return an empty list.
#         """
#         return []
# 
#     @property
#     def carta(self) -> str:
#         """ Create TeX Template for printable medium: "US Letter"
#         """
#         raise NotImplementedError
# 
#     @property
#     def oficio(self) -> str:
#         """ Create TeX Template for printable medium: "American Foolscap"
#         """
#         raise NotImplementedError
# 
#     @property
#     def thermal80mm(self) -> str:
#         """ Create TeX Template for printable medium: "Thermal endless 80mm width"
#         """
#         raise NotImplementedError


from .helpers import escape_tex
from .TemplateElement import TemplateElement
            self._build_rows(),
            self._build_disclaimer()
        )

    def _build_tablecols(self):
        cols = []
        cols.append('' if self._table_margins else '@{}')

        for coldef in self._colsettings:
            setstr  = 'X['
            setstr += {True: '', False: '-1'}[coldef['expand']]
            setstr += {'left': 'l', 'center': 'c', 'right': 'r'}[coldef['align']]
            setstr += ']'
            cols.append(setstr)

        cols.append('' if self._table_margins else '@{}')
        return ' '.join(cols)

    def _build_headers(self):
        cols = ['\\textbf{%s}' % escape_tex(col['name']) for col in self._colsettings]
        tex  = (' & \n' + ' ' * 4 * 3).join(cols)
        tex += ' \\\\\n'

        return tex

    def _build_rows(self):
        rows = []

        for row in self._items:
            stringed = (str(col) for col in row)

# Path: src/sii/lib/printing/helpers.py
# def escape_tex(string):
#     chars = '%|\$|&'
# 
#     return re.sub('(?<!\\\\)({0})'.format(chars), r'\\\1', string)
# 
# Path: src/sii/lib/printing/TemplateElement.py
# class TemplateElement(object):
# 
#     @property
#     def resources(self):
#         """ Requires the return of a list of `Resource` object providing
#         the filename the template is going to expect, and the data that
#         should be inside of it.
# 
#         In case of none, return an empty list.
#         """
#         return []
# 
#     @property
#     def carta(self) -> str:
#         """ Create TeX Template for printable medium: "US Letter"
#         """
#         raise NotImplementedError
# 
#     @property
#     def oficio(self) -> str:
#         """ Create TeX Template for printable medium: "American Foolscap"
#         """
#         raise NotImplementedError
# 
#     @property
#     def thermal80mm(self) -> str:
#         """ Create TeX Template for printable medium: "Thermal endless 80mm width"
#         """
#         raise NotImplementedError


# Path: src/sii/lib/printing/SectionItems.py
from .helpers import escape_tex
from .TemplateElement import TemplateElement

            self._build_rows(),
            self._build_disclaimer()
        )

    def _build_tablecols(self):
        cols = []
        cols.append('' if self._table_margins else '@{}')

        for coldef in self._colsettings:
            setstr  = 'X['
            setstr += {True: '', False: '-1'}[coldef['expand']]
            setstr += {'left': 'l', 'center': 'c', 'right': 'r'}[coldef['align']]
            setstr += ']'
            cols.append(setstr)

        cols.append('' if self._table_margins else '@{}')
        return ' '.join(cols)

    def _build_headers(self):
        cols = ['\\textbf{%s}' % escape_tex(col['name']) for col in self._colsettings]
        tex  = (' & \n' + ' ' * 4 * 3).join(cols)
        tex += ' \\\\\n'

        return tex

    def _build_rows(self):
        rows = []

        for row in self._items:
            stringed = (str(col) for col in row)

            escaped  = (escape_tex(colstr) for colstr in stringed)