import pickle
import pkg_resources
from pathlib import Path


def load_model(model):
    """Loads the model from the passed path or name"""

    if isinstance(model, Path):
        return pickle.loads(model.read_bytes())

    model = 'models/' + model + '.pkl'
    model = pkg_resources.resource_string('botrecon', model)

    return pickle.loads(model)