def use_model(model_name, include_models, exclude_models):
    """
    Decide whether to use a model, based on the model name and the lists of
    models to exclude and include.
    """
    # Check against exclude list.
    if exclude_models:
        for model_pattern in exclude_models:
            model_pattern = \
                '^%s$' % model_pattern.replace('*', '.*')
            if re.search(model_pattern, model_name):
                return False
    # Check against exclude list.
    elif include_models:
        for model_pattern in include_models:
            model_pattern = \
                '^%s$' % model_pattern.replace('*', '.*')
            if re.search(model_pattern, model_name):
                return True
    # Return `True` if `include_models` is falsey, otherwise return `False`.
    return not include_models
dataset/ETHPy150Open django-extensions/django-extensions/django_extensions/management/modelviz.py/use_model/original