<commit_before>#!/usr/bin/env python
"""
This module has utility functions for reading models and their fields.
"""
import inspect
import settings
from django.core.management import setup_environ

setup_environ(settings)

def is_instance_of_model(reference):
    """ Is instance of Model
    
    Tests if a given reference is a reference to a class that extends 
    django.db.models.Model
    
    Args : 
        reference : A given Anonymous reference.
    
    Returns :
        A boolean value that is true only if the given reference is a reference
        to a class.
    """
    if not inspect.isclass(reference):
        return False
    bases = ['%s.%s' % (b.__module__, b.__name__) for b 
            in inspect.getmro(reference)]
    return 'django.db.models.base.Model' in bases


<commit_msg>List of models function is added.<commit_after>#!/usr/bin/env python
"""
This module has utility functions for reading models and their fields.
"""
import inspect
import settings
from django.core.management import setup_environ

setup_environ(settings)

def is_instance_of_model(reference):
    """ Is instance of Model
    
    Tests if a given reference is a reference to a class that extends 
    django.db.models.Model
    
    Args : 
        reference : A given Anonymous reference.
    
    Returns :
        A boolean value that is true only if the given reference is a reference
        to a class.
    """
    if not inspect.isclass(reference):
        return False
    bases = ['%s.%s' % (b.__module__, b.__name__) for b 
            in inspect.getmro(reference)]
    return 'django.db.models.base.Model' in bases


def list_of_models(models_module, abstract=None):
    """ List of models
    
    This function filters the models from the instances in given module. 
    
    Args:
        models_module : A reference to a given models module.
        abstact(optional) : A boolean value that decides filtering of abstract
                            models.
                
    Returns:
        A list of reference to the classes of the models in 
        the imported models file.
    """
    models = filter(is_instance_of_model, models_module.__dict__.values())
    if abstract:
        return models
    else:
        def isnt_abstract(model):
            return not model._meta.abstract
        return filter(isnt_abstract, models)



{'fraction_non_alphanumeric': 0.07033898305084746, 'fraction_numerical': 0.0, 'mean_word_length': 2.497777777777778, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2472203', 'n_tokens_mistral': 632, 'n_tokens_neox': 618, 'n_words': 239}