# Path: onecodex/exceptions.py
# class OneCodexException(Exception):
#     pass
# 
# class UnboundObject(OneCodexException):
#     """To use against the One Codex server, all classes must be derived from an Api() instance."""
# 
#     pass


import click
import inspect
import os
import requests
from onecodex.exceptions import OneCodexException, UnboundObject
    from onecodex.models import OneCodexBase  # in here to prevent circular import
        from requests.adapters import HTTPAdapter
        from requests.packages.urllib3.util.retry import Retry
            sort_clause[item[1:]] = False
        else:
            sort_clause[item] = True
    return sort_clause


def generate_potion_keyword_where(keyword_filters, where_schema, base_class):
    where = {}
    for keyword in keyword_filters:
        search_value = keyword_filters[keyword]

        if keyword == "id":
            keyword = "$uri"

        if keyword not in where_schema:
            raise AttributeError(
                "{} can not be searched on {}".format(base_class.__name__, keyword)
            )

        avail_searches = [v["required"] for v in where_schema[keyword]["anyOf"] if "required" in v]
        # flatten the list
        avail_searches = [item for sublist in avail_searches for item in sublist]

        # TODO: do schema type checking here too?
        if "$eq" not in avail_searches and "$containsall" in avail_searches:
            if not isinstance(search_value, list):
                search_value = [search_value]
            where[keyword] = {
                "$containsall": [coerce_search_value(v, keyword, base_class) for v in search_value]
            }

# Path: onecodex/exceptions.py
# class OneCodexException(Exception):
#     pass
# 
# class UnboundObject(OneCodexException):
#     """To use against the One Codex server, all classes must be derived from an Api() instance."""
# 
#     pass


# Path: onecodex/models/helpers.py
import click
import inspect
import os
import requests
from onecodex.exceptions import OneCodexException, UnboundObject
    from onecodex.models import OneCodexBase  # in here to prevent circular import
        from requests.adapters import HTTPAdapter
        from requests.packages.urllib3.util.retry import Retry

            sort_clause[item[1:]] = False
        else:
            sort_clause[item] = True
    return sort_clause


def generate_potion_keyword_where(keyword_filters, where_schema, base_class):
    where = {}
    for keyword in keyword_filters:
        search_value = keyword_filters[keyword]

        if keyword == "id":
            keyword = "$uri"

        if keyword not in where_schema:
            raise AttributeError(
                "{} can not be searched on {}".format(base_class.__name__, keyword)
            )

        avail_searches = [v["required"] for v in where_schema[keyword]["anyOf"] if "required" in v]
        # flatten the list
        avail_searches = [item for sublist in avail_searches for item in sublist]

        # TODO: do schema type checking here too?
        if "$eq" not in avail_searches and "$containsall" in avail_searches:
            if not isinstance(search_value, list):
                search_value = [search_value]
            where[keyword] = {
                "$containsall": [coerce_search_value(v, keyword, base_class) for v in search_value]
            }

        elif isinstance(search_value, list):