'Adds borders to the table by adjusting the input kwarg to
instruct cells to build a border in the right positions.
Args:
ix (int): x index positions in table.
iy (int): y index positions in table.
nx (int): x size of table.
ny (int): y size of table.
Kwargs:
Keywords as per `EvTable.__init__`.
Returns:
table (str): string with the correct borders.
Notes:
A copy of the kwarg is returned to the cell. This is method
is called by self._borders.'

def _cellborders(self, ix, iy, nx, ny, **kwargs):

    ret = kwargs.copy()
    border = self.border
    header = self.header
    bwidth = self.border_width
    headchar = self.header_line_char
    def corners(ret):
        'Handle    corners    of    table'
        if ((ix == 0) and (iy == 0)):
            ret['corner_top_left_char'] = self.corner_top_left_char
        if ((ix == nx) and (iy == 0)):
            ret['corner_top_right_char'] = self.corner_top_right_char
        if ((ix == 0) and (iy == ny)):
            ret['corner_bottom_left_char'] = self.corner_bottom_left_char
        if ((ix == nx) and (iy == ny)):
            ret['corner_bottom_right_char'] = self.corner_bottom_right_char
        return ret
    def left_edge(ret):
        'add    vertical    border    along    left    table    edge'
        if (ix == 0):
            ret['border_left'] = bwidth
        return ret
    def top_edge(ret):
        'add    border    along    top    table    edge'
        if (iy == 0):
            ret['border_top'] = bwidth
        return ret
    def right_edge(ret):
        'add    vertical    border    along    right    table    edge'
        if (ix == nx):
            ret['border_right'] = bwidth
        return ret
    def bottom_edge(ret):
        'add    border    along    bottom    table    edge'
        if (iy == ny):
            ret['border_bottom'] = bwidth
        return ret
    def cols(ret):
        'Adding    vertical    borders    inside    the    table'
        if (0 <= ix < nx):
            ret['border_right'] = bwidth
        return ret
    def rows(ret):
        'Adding    horizontal    borders    inside    the    table'
        if (0 <= iy < ny):
            ret['border_bottom'] = bwidth
        return ret
    def head(ret):
        'Add    header    underline'
        if (iy == 0):
            ret['border_bottom'] = bwidth
            ret['border_bottom_char'] = headchar
        return ret
    if (border in ('table', 'tablecols', 'cells')):
        ret = bottom_edge(right_edge(top_edge(left_edge(corners(ret)))))
    if (border in ('cols', 'tablecols', 'cells')):
        ret = cols(right_edge(left_edge(ret)))
    if (border in 'incols'):
        ret = cols(ret)
    if (border in ('rows', 'cells')):
        ret = rows(bottom_edge(top_edge(ret)))
    if (header and (border not in ('none', None))):
        ret = head(ret)
    return ret
