# Path: onecodex/vendored/potion_client/exceptions.py
# class ItemNotFound(Exception):
#     pass
# 
# class MultipleItemsFound(Exception):
#     pass
# 
# 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
import six
from pprint import pformat
from .exceptions import ItemNotFound, MultipleItemsFound
from .utils import escape
    def fetch(cls, id):
        return cls._self(id=id)

    def check(self):
        pass

    def save(self):
        # TODO only save the appropriate properties defined in the schemas
        # That logic should live in the links themselves.

        if self._uri is None:
            return self._create(**self)
        else:
            return self._update(**self)

    def delete(self):
        return self._destroy(id=self.id)

    def _repr_html_(self):
        return '''<table>
        <thead>
            <tr>
                <th colspan="2"><code>{cls}({id})</code></th>
            </tr>
        </thead>
        <tbody>{properties}</tbody>
        </table>'''.format(
            cls=self.__class__.__name__,
            id=escape(repr(self.id)),
            properties='\n'.join('<tr><td>{}</td><td><code>{}</code></td>'.format(escape(k),

# Path: onecodex/vendored/potion_client/exceptions.py
# class ItemNotFound(Exception):
#     pass
# 
# class MultipleItemsFound(Exception):
#     pass
# 
# 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/resource.py
import collections
import six
from pprint import pformat
from .exceptions import ItemNotFound, MultipleItemsFound
from .utils import escape

    def fetch(cls, id):
        return cls._self(id=id)

    def check(self):
        pass

    def save(self):
        # TODO only save the appropriate properties defined in the schemas
        # That logic should live in the links themselves.

        if self._uri is None:
            return self._create(**self)
        else:
            return self._update(**self)

    def delete(self):
        return self._destroy(id=self.id)

    def _repr_html_(self):
        return '''<table>
        <thead>
            <tr>
                <th colspan="2"><code>{cls}({id})</code></th>
            </tr>
        </thead>
        <tbody>{properties}</tbody>
        </table>'''.format(
            cls=self.__class__.__name__,
            id=escape(repr(self.id)),
            properties='\n'.join('<tr><td>{}</td><td><code>{}</code></td>'.format(escape(k),

                                                                                  escape(pformat(v)))