Returns a tuple for a kind name and kind display name of an entity.
        By default, uses the app_label and model of the model object's content
        type as the kind.
423809
def get_entity_kind(self, model_obj):
        
        model_obj_ctype = ContentType.objects.get_for_model(self.queryset.model)
        return (u'{0}.{1}'.format(model_obj_ctype.app_label, model_obj_ctype.model), u'{0}'.format(model_obj_ctype))
406701
public static KindName kindName(Symbol sym) {
        switch (sym.getKind()) {
        case PACKAGE:
            return KindName.PACKAGE;

        case ENUM:
            return KindName.ENUM;

        case ANNOTATION_TYPE:
        case CLASS:
            return KindName.CLASS;

        case INTERFACE:
            return KindName.INTERFACE;

        case TYPE_PARAMETER:
            return KindName.TYPEVAR;

        case ENUM_CONSTANT:
        case FIELD:
        case PARAMETER:
        case LOCAL_VARIABLE:
        case EXCEPTION_PARAMETER:
        case RESOURCE_VARIABLE:
            return KindName.VAR;

        case CONSTRUCTOR:
            return KindName.CONSTRUCTOR;

        case METHOD:
            return KindName.METHOD;
        case STATIC_INIT:
            return KindName.STATIC_INIT;
        case INSTANCE_INIT:
            return KindName.INSTANCE_INIT;

        default:
                throw new AssertionError("Unexpected kind: "+sym.getKind());
        }
    }
489074
def get_models(app_labels):
    

    # These models are not to be output, e.g. because they can be generated automatically
    # TODO: This should be "appname.modelname" string
    EXCLUDED_MODELS = (ContentType, )

    models = []

    # If no app labels are given, return all
    if not app_labels:
        for app in apps.get_app_configs():
            models += [m for m in apps.get_app_config(app.label).get_models()
                       if m not in EXCLUDED_MODELS]
        return models

    # Get all relevant apps
    for app_label in app_labels:
        # If a specific model is mentioned, get only that model
        if "." in app_label:
            app_label, model_name = app_label.split(".", 1)
            models.append(apps.get_model(app_label, model_name))
        # Get all models for a given app
        else:
            models += [m for m in apps.get_app_config(app_label).get_models()
                       if m not in EXCLUDED_MODELS]

    return models
1323615
def get_object_by_natural_key(self, app_label, model_name, object_id):
        
        try:
            model_type = ContentType.objects.get_by_natural_key(app_label, model_name)
        except ContentType.DoesNotExist:
            return None

        # Pointless to fetch the object, if there is no URL to generate
        # Avoid another database query.
        ModelClass = model_type.model_class()
        if not hasattr(ModelClass, 'get_absolute_url'):
            return None

        try:
            return model_type.get_object_for_this_type(pk=object_id)
        except ObjectDoesNotExist:
            return None
213775
def label_from_instance(self, obj):
        
        return '%s %s' % (self.level_indicator * getattr(obj, obj._mptt_meta.level_attr), obj)
1142942
def model_factory(abstract_class):
    
    app_label = abstract_class.Meta.app_label
    model_name = abstract_class.__name__.replace('Abstract', '')

    if not is_model_registered(app_label, model_name):
        return type(str(model_name), (abstract_class, ), {'__module__': __name__, })
792074
def _get_kind(cls):
    
    bases = cls._get_hierarchy()
    if not bases:
      # We have to jump through some hoops to call the superclass'
      # _get_kind() method.  First, this is called by the metaclass
      # before the PolyModel name is defined, so it can't use
      # super(PolyModel, cls)._get_kind().  Second, we can't just call
      # Model._get_kind() because that always returns 'Model'.  Hence
      # the 'im_func' hack.
      return model.Model._get_kind.im_func(cls)
    else:
      return bases[0]._class_name()
392873
def generic_type_name(v):
    
    if isinstance(v, AstExampleRef):
        return "reference"
    elif isinstance(v, numbers.Integral):
        # Must come before real numbers check since integrals are reals too
        return 'integer'
    elif isinstance(v, numbers.Real):
        return 'float'
    elif isinstance(v, (tuple, list)):
        return 'list'
    elif isinstance(v, six.string_types):
        return 'string'
    elif v is None:
        return 'null'
    else:
        return type(v).__name__
586941
def tag_kind(tag, default=consts.TAG_KIND_UNKNOWN):
    
    if len(tag) == 2:
        return consts.TAG_KIND_GEO
    if u',' in tag:
        return consts.TAG_KIND_PERSON
    if tag[0] in u'Kk' and len(tag) == 4:
        return consts.TAG_KIND_PROGRAM
    t = tag.upper()
    if t in _TAGS_SUBJECT:
        return consts.TAG_KIND_SUBJECT
    if t in _TAGS_ORG:
        return consts.TAG_KIND_ORG
    return default
201805
def type_and_model_to_query(self, request):
        
        try:
            content_type_id = request.GET["content_type_id"]
            object_id = request.GET["object_id"]
        except KeyError:
            return HttpResponseBadRequest()

        try:
            content_type = ContentType.objects.get(pk=content_type_id)
            model = content_type.model_class()
            result = model.objects.get(pk=object_id)
        except ObjectDoesNotExist:
            data = ""
        else:
            data = '%s: "%d: %s"' % (content_type.model, result.pk, result)

        return JsonResponse({"query": data})
249350
def label(self):
        
        value = self._element_dict.get("value")
        type_name = type(value).__name__

        if type_name == "NoneType":
            return ""

        if type_name == "list":
            # ---like '10-15' or 'A-F'---
            return "-".join([str(item) for item in value])

        if type_name in ("float", "int"):
            return str(value)

        if type_name in ("str", "unicode"):
            return value

        # ---For CA and MR subvar dimensions---
        name = value.get("references", {}).get("name")
        return name if name else ""
738993
def is_model_registered(app_label, model_name):
    
    try:
        apps.get_registered_model(app_label, model_name)
    except LookupError:
        return False
    else:
        return True
1171118
def get_entity_description(entity):
    

    try:
        entity_name = entity.__name__.strip('_')
    except AttributeError:
        # entity is a class instance
        entity_name = entity.__class__.__name__

    label = '* %s' % formatting.camelcase_to_spaces(entity_name)
    if entity.__doc__ is not None:
        entity_docstring = formatting.dedent(smart_text(entity.__doc__)).replace('\n', '\n\t')
        return '%s\n * %s' % (label, entity_docstring)

    return label
366539
public static KindName kindName(int kind) {
        switch (kind) {
        case PCK: return KindName.PACKAGE;
        case TYP: return KindName.CLASS;
        case VAR: return KindName.VAR;
        case VAL: return KindName.VAL;
        case MTH: return KindName.METHOD;
            default : throw new AssertionError("Unexpected kind: "+kind);
        }
    }
210294
def get_type_name(type_name, sub_type=None):
    
    if type_name == "enum":
        return type_name
    elif type_name == "boolean":
        return "bool"
    elif type_name == "integer":
        return "long"
    elif type_name == "time":
        return "long"
    elif type_name == "object":
        return "Object"
    elif type_name == "list":
        return "List"
    elif type_name == "float":
        return "float"
    else:
        return "String"
260001
def get_name_for_model(cls, model):
        
        key = cls.get_model_key(model)
        model_str = cls._get_model_str(model)
        service = cls._registry[key]
        if model_str in service['resources']:
            return '{}.{}'.format(service['name'], service['resources'][model_str]['name'])
        else:
            return service['name']
387029
def get_model(app_label, model_name):
    
    try:
        return apps.get_model(app_label, model_name)
    except AppRegistryNotReady:
        if apps.apps_ready and not apps.models_ready:
            # If the models module of the considered app has not been loaded yet,
            # we try to import it manually in order to retrieve the model class.
            # This trick is usefull in order to get the model class during the
            # ``apps.populate()`` call and the execution of related methods of AppConfig
            # instances (eg. ``ready``).

            # Firts, the config of the consideration must be retrieved
            app_config = apps.get_app_config(app_label)
            # Then the models module is manually imported
            import_module('%s.%s' % (app_config.name, MODELS_MODULE_NAME))
            # Finally, tries to return the registered model class
            return apps.get_registered_model(app_label, model_name)
        else:
            raise