returns a list of carts containing a package with the specified name

    env: the name of an environment from the juicer config
    pkg_name: the name of the package for which to search
    repos: a list of repos in which to search for the package

def search_carts(env, pkg_name, repos):
    """
    returns a list of carts containing a package with the specified name

    env: the name of an environment from the juicer config
    pkg_name: the name of the package for which to search
    repos: a list of repos in which to search for the package
    """
    db = cart_db()
    carts = db[env]

    for repo in repos:
        field = 'repos_items.%s' % repo
        value = '.*%s.*' % pkg_name

        found_carts = []

        for cart in carts.find({field: {'$regex': value}}):
            found_carts.append(cart)
        return found_carts