Returns object with label for an object that goes into the elacticsearch
    'label' field

    args:
        obj: data object to update
        def_obj: the class instance that has defintion values
428315
def get_es_label(obj, def_obj):
    
    label_flds = LABEL_FIELDS
    if def_obj.es_defs.get('kds_esLabel'):
        label_flds = def_obj.es_defs['kds_esLabel'] + LABEL_FIELDS
    try:
        for label in label_flds:
            if def_obj.cls_defs.get(label):
                 obj['label'] = def_obj.cls_defs[label][0]
                 break
        if not obj.get('label'):
            obj['label'] = def_obj.__class__.__name__.split("_")[-1]
    except AttributeError:
        # an attribute error is caused when the class is only
        # an instance of the BaseRdfClass. We will search the rdf_type
        # property and construct a label from rdf_type value
        if def_obj.get('rdf_type'):
            obj['label'] = def_obj['rdf_type'][-1].value[-1]
        else:
            obj['label'] = "no_label"
    return obj
1293862
def label(self, value):
        
        return self._labels.get(value) or text.pretty(self(value))
487649
def get_field_label(self, trans, field):
        
        try:
            # get from the instance
            object_field_label = trans._meta.get_field_by_name(field)[0].verbose_name
        except Exception:
            try:
                # get from the class
                object_field_label = self.sender._meta.get_field_by_name(field)[0].verbose_name
            except Exception:
                # in the worst case we set the field name as field label
                object_field_label = field
        return object_field_label
15157
def label_from_folder(self, label_cls:Callable=None, **kwargs)->'LabelList':
        ""
        return self.label_from_func(func=lambda o: (o.parts if isinstance(o, Path) else o.split(os.path.sep))[-2],
                                    label_cls=label_cls, **kwargs)
1268020
def object_annotation(obj):
    
    # For basic types, use the repr.
    if isinstance(obj, BASE_TYPES):
        return repr(obj)
    if type(obj).__name__ == 'function':
        return "function\\n{}".format(obj.__name__)
    elif isinstance(obj, types.MethodType):
        if six.PY2:
            im_class = obj.im_class
            if im_class is None:
                im_class_name = "<None>"
            else:
                im_class_name = im_class.__name__

            try:
                func_name = obj.__func__.__name__
            except AttributeError:
                func_name = "<anonymous>"
            return "instancemethod\\n{}.{}".format(
                im_class_name,
                func_name,
            )
        else:
            try:
                func_name = obj.__func__.__qualname__
            except AttributeError:
                func_name = "<anonymous>"
            return "instancemethod\\n{}".format(func_name)
    elif isinstance(obj, list):
        return "list[{}]".format(len(obj))
    elif isinstance(obj, tuple):
        return "tuple[{}]".format(len(obj))
    elif isinstance(obj, dict):
        return "dict[{}]".format(len(obj))
    elif isinstance(obj, types.ModuleType):
        return "module\\n{}".format(obj.__name__)
    elif isinstance(obj, type):
        return "type\\n{}".format(obj.__name__)
    elif six.PY2 and isinstance(obj, types.InstanceType):
        return "instance\\n{}".format(obj.__class__.__name__)
    elif isinstance(obj, weakref.ref):
        referent = obj()
        if referent is None:
            return "weakref (dead referent)"
        else:
            return "weakref to id 0x{:x}".format(id(referent))
    elif isinstance(obj, types.FrameType):
        filename = obj.f_code.co_filename
        if len(filename) > FRAME_FILENAME_LIMIT:
            filename = "..." + filename[-(FRAME_FILENAME_LIMIT-3):]
        return "frame\\n{}:{}".format(
            filename,
            obj.f_lineno,
        )
    else:
        return "object\\n{}.{}".format(
            type(obj).__module__,
            type(obj).__name__,
        )
348086
def _compute_example_flat_helper(self, label):
        
        assert label in self._raw_examples, label

        example = self._raw_examples[label]

        def deref_example_ref(dt, val):
            dt, _ = unwrap_nullable(dt)
            if not dt._has_example(val.label):
                raise InvalidSpec(
                    "Reference to example for '%s' with label '%s' "
                    "does not exist." % (dt.name, val.label),
                    val.lineno, val.path)
            return dt._compute_example(val.label).value

        # Do a deep copy of the example because we're going to mutate it.
        ex_val = OrderedDict()

        def get_json_val(dt, val):
            if isinstance(val, AstExampleRef):
                # Embed references to other examples directly.
                return deref_example_ref(dt, val)
            elif isinstance(val, TagRef):
                return val.union_data_type._compute_example(val.tag_name).value
            elif isinstance(val, list):
                dt, _ = unwrap_nullable(dt)
                return [get_json_val(dt.data_type, v) for v in val]
            elif isinstance(val, dict):
                dt, _ = unwrap_nullable(dt)
                if is_alias(dt):
                    return val
                return {k: get_json_val(dt.value_data_type, v) for (k, v) in val.items()}
            else:
                return val

        for field in self.all_fields:
            if field.name in example.fields:
                example_field = example.fields[field.name]
                if example_field.value is None:
                    # Serialized format doesn't include fields with null.
                    pass
                else:
                    ex_val[field.name] = get_json_val(
                        field.data_type, example_field.value)
            elif field.has_default:
                ex_val[field.name] = get_json_val(
                    field.data_type, field.default)

        return Example(example.label, example.text, ex_val, ast_node=example)
428505
def update_dict(self, label: Dict, pred: Dict):
        
        if not set(self.label_names).issubset(set(label.keys())):
            label.update({name:pred[name] for name in self.label_names})
        super().update_dict(label, pred)
447064
def label_from_instance(self, obj):
        
        level = getattr(obj, obj._mptt_meta.level_attr)
        level_indicator = mark_safe(conditional_escape(self.level_indicator) * level)
        return mark_safe(u'%s %s' % (level_indicator, conditional_escape(smart_unicode(obj))))
854995
def inspect_object(obj, refresh=True):
    
    if hasattr(obj, "inspect"):
        return obj.inspect(refresh=refresh)
    return obj.get_metadata(refresh=refresh)
539766
def update(self, obj, matches=None, mt=None, lt=None, eq=None):
        '''
        
        '''
        updated = False
        objects = list()
        for _obj in self.get(obj.__class__):
            if self.__criteria(_obj, matches=matches, mt=mt, lt=lt, eq=eq):
                objects.append(obj)
                updated = True
            else:
                objects.append(_obj)
        self.flush(obj._TABLE)
        self.create_table_from_object(obj)
        for obj in objects:
            self.store(obj)

        return updated
719181
def app_model_id(obj):
    
    ct = ContentType.objects.get_for_model(obj)

    return '%s-%s-%s' % (ct.app_label, ct.model, obj.id)
1354051
def get_title(self, obj):
        """"""
        search_title = self.get_model_config_value(obj, 'search_title')

        if not search_title:
            return super().get_title(obj)

        return search_title.format(**obj.__dict__)
773921
def value_to_string(self, obj):
        
        statefield = self.to_python(self.value_from_object(obj))
        return statefield.state.name
954578
def update_form_labels(self, request=None, obj=None, form=None):
        
        for form_label in self.custom_form_labels:
            if form_label.field in form.base_fields:
                label = form_label.get_form_label(
                    request=request, obj=obj, model=self.model, form=form
                )
                if label:
                    form.base_fields[form_label.field].label = mark_safe(label)
        return form
777658
def pb2dict(obj):
    
    adict = {}
    if not obj.IsInitialized():
        return None
    for field in obj.DESCRIPTOR.fields:
        if not getattr(obj, field.name):
            continue
        if not field.label == FD.LABEL_REPEATED:
            if not field.type == FD.TYPE_MESSAGE:
                adict[field.name] = getattr(obj, field.name)
            else:
                value = pb2dict(getattr(obj, field.name))
                if value:
                    adict[field.name] = value
        else:
            if field.type == FD.TYPE_MESSAGE:
                adict[field.name] = \
                    [pb2dict(v) for v in getattr(obj, field.name)]
            else:
                adict[field.name] = [v for v in getattr(obj, field.name)]
    return adict
75112
def alter_object(self, obj):
        
        for attname, field, replacer in self.replacers:
            currentval = getattr(obj, attname)
            replacement = replacer(self, obj, field, currentval)
            setattr(obj, attname, replacement)
77255
static Object getLabel(FacesContext context, 
                                        UIComponent component) {
                                        
        Object o = component.getAttributes().get("label");
        if (o == null || (o instanceof String && ((String) o).length() == 0)) {
            o = component.getValueExpression("label");
        }
        // Use the "clientId" if there was no label specified.
        if (o == null) {
            o = component.getClientId(context);
        }
        return o;
    }