# Path: casacore/tables/tablehelper.py
# def _check_key_slice(key, nrows, name):
#     if not isinstance(key, slice):
#         inx = _check_index(key, name)
#         # A single index (possibly negative, thus from the end).
#         if inx < 0:
#             inx += nrows
#         if inx < 0 or inx >= nrows:
#             raise IndexError(name + " index out of range")
#         return [inx]
#     # Given as start:stop:step where each part is optional and can
#     # be negative.
#     incr = 1
#     if key.step is not None:
#         incr = _check_index(key.step, name)
#         if incr == 0:
#             raise RuntimeError(name + " slice step cannot be zero")
#     strow = 0
#     endrow = nrows
#     if incr < 0:
#         strow = nrows - 1
#         endrow = -1
#     if key.start is not None:
#         strow = _check_index(key.start, name)
#         if strow < 0:
#             strow += nrows
#         strow = min(max(strow, 0), nrows - 1)
#     if key.stop is not None:
#         endrow = _check_index(key.stop, name)
#         if endrow < 0:
#             endrow += nrows
#         endrow = min(max(endrow, -1), nrows)
#     if incr > 0:
#         nrow = int((endrow - strow + incr - 1) / incr)
#     else:
#         nrow = int((strow - endrow - incr - 1) / -incr)
#     nrow = max(0, nrow)
#     return [strow, nrow, incr]


from ._tables import TableRow
from .tablehelper import _check_key_slice
        """Get the contents of the given row."""
        return self._get(rownr)

    def put(self, rownr, value, matchingfields=True):
        """Put the values into the given row.

        The value should be a dict (as returned by method :func:`get`.
        The names of the fields in the dict should match the names of the
        columns used in the `tablerow` object.

        `matchingfields=True` means that the value may contain more fields
        and only fields matching a column name will be used.

        """
        self._put(rownr, value, matchingfields)

    def _getitem(self, key, nrows):
        sei = _check_key_slice(key, nrows, 'tablerow')
        rownr = sei[0]
        if len(sei) == 1:
            return self.get(rownr)
        result = []
        inx = 0
        while inx < sei[1]:
            result.append(self.get(rownr))
            rownr += sei[2]
            inx += 1
        return result

    def _setitem(self, key, value, nrows):

# Path: casacore/tables/tablehelper.py
# def _check_key_slice(key, nrows, name):
#     if not isinstance(key, slice):
#         inx = _check_index(key, name)
#         # A single index (possibly negative, thus from the end).
#         if inx < 0:
#             inx += nrows
#         if inx < 0 or inx >= nrows:
#             raise IndexError(name + " index out of range")
#         return [inx]
#     # Given as start:stop:step where each part is optional and can
#     # be negative.
#     incr = 1
#     if key.step is not None:
#         incr = _check_index(key.step, name)
#         if incr == 0:
#             raise RuntimeError(name + " slice step cannot be zero")
#     strow = 0
#     endrow = nrows
#     if incr < 0:
#         strow = nrows - 1
#         endrow = -1
#     if key.start is not None:
#         strow = _check_index(key.start, name)
#         if strow < 0:
#             strow += nrows
#         strow = min(max(strow, 0), nrows - 1)
#     if key.stop is not None:
#         endrow = _check_index(key.stop, name)
#         if endrow < 0:
#             endrow += nrows
#         endrow = min(max(endrow, -1), nrows)
#     if incr > 0:
#         nrow = int((endrow - strow + incr - 1) / incr)
#     else:
#         nrow = int((strow - endrow - incr - 1) / -incr)
#     nrow = max(0, nrow)
#     return [strow, nrow, incr]


# Path: casacore/tables/tablerow.py
from ._tables import TableRow
from .tablehelper import _check_key_slice

        """Get the contents of the given row."""
        return self._get(rownr)

    def put(self, rownr, value, matchingfields=True):
        """Put the values into the given row.

        The value should be a dict (as returned by method :func:`get`.
        The names of the fields in the dict should match the names of the
        columns used in the `tablerow` object.

        `matchingfields=True` means that the value may contain more fields
        and only fields matching a column name will be used.

        """
        self._put(rownr, value, matchingfields)

    def _getitem(self, key, nrows):
        sei = _check_key_slice(key, nrows, 'tablerow')
        rownr = sei[0]
        if len(sei) == 1:
            return self.get(rownr)
        result = []
        inx = 0
        while inx < sei[1]:
            result.append(self.get(rownr))
            rownr += sei[2]
            inx += 1
        return result

    def _setitem(self, key, value, nrows):

        sei = _check_key_slice(key, nrows, 'tablerow')