# Path: python_bindings/rust_qpick/lib.py
# def find_library():


import os
from .lib import ffi, lib
        keyword_dist = dist.keyword
        cosine_dist = None if dist.cosine == -1.0 else dist.cosine

        self._free_item_fn(item)
        self._free_dist_fn(dist)

        return (query, cosine_dist, keyword_dist)

class Qpick(object):
    def __init__(self, dir_path=None, start_shard=None, end_shard=None, _pointer=None):
        """Loads a query index from a given directory.

        :param dir_path:    Directory path to index on disk
        :param start_shard: Index of the first shard in the index to load
        :param end_shard:   Index of the last shard in the index to load
        """
        # self._ctx = ffi.gc(lib.qpick_context_new(), lib.qpick_context_free)

        if dir_path:
            if not os.path.isdir(dir_path):
                raise Exception("%s is not a directory!" % dir_path)

            if type(dir_path) == str:
                dir_path = dir_path.encode('utf-8')

            if start_shard is not None and end_shard is not None:
                if end_shard <= start_shard:
                    raise Exception("Index of the last shard has to be greater than the start index!")
                else:
                    # returns a pointer to rust Qpick struct

# Path: python_bindings/rust_qpick/lib.py
# def find_library():


# Path: python_bindings/rust_qpick/qpick.py
import os
from .lib import ffi, lib

        keyword_dist = dist.keyword
        cosine_dist = None if dist.cosine == -1.0 else dist.cosine

        self._free_item_fn(item)
        self._free_dist_fn(dist)

        return (query, cosine_dist, keyword_dist)

class Qpick(object):
    def __init__(self, dir_path=None, start_shard=None, end_shard=None, _pointer=None):
        """Loads a query index from a given directory.

        :param dir_path:    Directory path to index on disk
        :param start_shard: Index of the first shard in the index to load
        :param end_shard:   Index of the last shard in the index to load
        """
        # self._ctx = ffi.gc(lib.qpick_context_new(), lib.qpick_context_free)

        if dir_path:
            if not os.path.isdir(dir_path):
                raise Exception("%s is not a directory!" % dir_path)

            if type(dir_path) == str:
                dir_path = dir_path.encode('utf-8')

            if start_shard is not None and end_shard is not None:
                if end_shard <= start_shard:
                    raise Exception("Index of the last shard has to be greater than the start index!")
                else:
                    # returns a pointer to rust Qpick struct

                    s = lib.qpick_init_with_shard_range(dir_path, start_shard, end_shard)