# Path: onecodex/vendored/potion_client/utils.py
# def escape(html):
#     """Returns the given HTML with ampersands, quotes and carets encoded."""
#     return html \
#         .replace('&', '&amp;') \
#         .replace('<', '&lt;') \
#         .replace('>', '&gt;') \
#         .replace('"', '&quot;') \
#         .replace("'", '&#39;')


import collections
from pprint import pformat
from .utils import escape
        if isinstance(item, slice):
            return [self.__getitem__(index) for index in range(*item.indices(self._total_count))]

        if item < 0 or item >= self._total_count:
            raise IndexError()

        page, offset = item // self._per_page + 1, item % self._per_page
        if page not in self._pages:
            self.fetch_page(page, self._per_page)
        return self._pages[page][offset]

    def __len__(self):
        return self._total_count

    def fetch_page(self, page, per_page):
        params = dict(page=page, per_page=per_page)
        params.update(self._request_params)
        response, response_data = self._binding.make_request(None, params)

        try:
            self._total_count = int(response.headers['X-Total-Count'])
        except KeyError:
            self._total_count = len(response_data)

        self._pages[page] = response_data

    def _repr_html_(self):
        if len(self) <= 10:
            items = [escape(pformat(item)) for item in self[:]]
        else:

# Path: onecodex/vendored/potion_client/utils.py
# def escape(html):
#     """Returns the given HTML with ampersands, quotes and carets encoded."""
#     return html \
#         .replace('&', '&amp;') \
#         .replace('<', '&lt;') \
#         .replace('>', '&gt;') \
#         .replace('"', '&quot;') \
#         .replace("'", '&#39;')


# Path: onecodex/vendored/potion_client/collection.py
import collections
from pprint import pformat
from .utils import escape

        if isinstance(item, slice):
            return [self.__getitem__(index) for index in range(*item.indices(self._total_count))]

        if item < 0 or item >= self._total_count:
            raise IndexError()

        page, offset = item // self._per_page + 1, item % self._per_page
        if page not in self._pages:
            self.fetch_page(page, self._per_page)
        return self._pages[page][offset]

    def __len__(self):
        return self._total_count

    def fetch_page(self, page, per_page):
        params = dict(page=page, per_page=per_page)
        params.update(self._request_params)
        response, response_data = self._binding.make_request(None, params)

        try:
            self._total_count = int(response.headers['X-Total-Count'])
        except KeyError:
            self._total_count = len(response_data)

        self._pages[page] = response_data

    def _repr_html_(self):
        if len(self) <= 10:
            items = [escape(pformat(item)) for item in self[:]]
        else:

            items = [escape(pformat(item)) for item in self[:5]] + \