// Attr returns the object's attribute value for the provided attr,
// or the empty string if unset.  To distinguish between unset,
// an empty string, or multiple attribute values, use Attrs.
193096
func (o *Object) Attr(attr string) string {
	o.mu.RLock()
	defer o.mu.RUnlock()
	if v := o.attr[attr]; len(v) > 0 {
		return v[0]
	}
	return ""
}
646426
func GetAttr(e Markup, f string) (*Attribute, error) {
	for _, as := range e.Attributes() {
		if as.Name == f {
			return as, nil
		}
	}
	return nil, ErrNotFound
}
1019308
func (iamRes *IAMResourceBuilder) Attr(resName string, propName string, delimiter ...string) *IAMResourceBuilder {
	iamRes.resourceParts = append(iamRes.resourceParts,
		gocf.GetAtt(resName, propName))
	for _, eachDelimiter := range delimiter {
		iamRes.resourceParts = append(iamRes.resourceParts,
			gocf.String(eachDelimiter))
	}
	return iamRes
}
141225
func getAttributeValue(attrName string, n *html.Node) (val string, exists bool) {
	if a := getAttributePtr(attrName, n); a != nil {
		val = a.Val
		exists = true
	}
	return
}
40812
func (s *Selection) Attr(attrName string) (val string, exists bool) {
	if len(s.Nodes) == 0 {
		return
	}
	return getAttributeValue(attrName, s.Nodes[0])
}
964158
func (f *SpecialReadFile) Attr(ctx context.Context, a *fuse.Attr) error {
	data, t, err := f.read(ctx)
	if err != nil {
		return err
	}

	// Have a low non-zero value for Valid to avoid being swamped
	// with requests, while still keeping the size up to date.
	a.Valid = 1 * time.Second
	// Some apps (e.g., Chrome) get confused if we use a 0 size
	// here, as is usual for pseudofiles. So return the actual
	// size, even though it may be racy.
	a.Size = uint64(len(data))
	a.Mtime = t
	a.Ctime = t
	a.Mode = 0444
	return nil
}
261685
func (a *Attribute) GoString() string {
	if a == nil {
		return "nil attribute"
	}

	var b strings.Builder
	if a.Float != nil {
		b.WriteString(fmt.Sprintf("%v", *a.Float))
	} else if a.Int != nil {
		b.WriteString(fmt.Sprintf("%v", *a.Int))
	} else if a.Bool != nil {
		b.WriteString(fmt.Sprintf("%v", *a.Bool))
	} else if a.String != nil {
		b.WriteString(*a.String)
	}

	if a.Unit != "" {
		b.WriteString(a.Unit)
	}

	return b.String()
}
311090
func (v Values) GetStr(key interface{}) interface{} {
	if v == nil { return "" }
	
	val := v.Get(key)
	if val == nil { return "" }

	str, ok := val.(string)
	if !ok { return "" }
	return str
}
502258
func (s *Struct) Attr(name string) (skylark.Value, error) {
	// Binary search the entries.
	// This implementation is a specialization of
	// sort.Search that avoids dynamic dispatch.
	n := len(s.entries)
	i, j := 0, n
	for i < j {
		h := int(uint(i+j) >> 1)
		if s.entries[h].name < name {
			i = h + 1
		} else {
			j = h
		}
	}
	if i < n && s.entries[i].name == name {
		return s.entries[i].value, nil
	}

	// TODO(adonovan): there may be a nice feature for core
	// skylark.Value here, especially for JSON, but the current
	// features are incomplete and underspecified.
	//
	// to_{json,proto} are deprecated, appropriately; see Google issue b/36412967.
	switch name {
	case "to_json", "to_proto":
		return skylark.NewBuiltin(name, func(thread *skylark.Thread, fn *skylark.Builtin, args skylark.Tuple, kwargs []skylark.Tuple) (skylark.Value, error) {
			var buf bytes.Buffer
			var err error
			if name == "to_json" {
				err = writeJSON(&buf, s)
			} else {
				err = writeProtoStruct(&buf, 0, s)
			}
			if err != nil {
				// TODO(adonovan): improve error error messages
				// to show the path through the object graph.
				return nil, err
			}
			return skylark.String(buf.String()), nil
		}), nil
	}

	var ctor string
	if s.constructor != Default {
		ctor = s.constructor.String() + " "
	}
	return nil, fmt.Errorf("%sstruct has no .%s attribute", ctor, name)
}
1052380
func getAttr(fr *Frame, x Value, name string) (Value, error) {
	// field or method?
	if x, ok := x.(HasAttrs); ok {
		if v, err := x.Attr(name); v != nil || err != nil {
			return v, err
		}
	}

	return nil, fmt.Errorf("%s has no .%s field or method", x.Type(), name)
}
29286
func (xmlNode *XmlNode) Attribute(name string) (attribute *AttributeNode) {
	if xmlNode.NodeType() != XML_ELEMENT_NODE {
		return
	}
	nameBytes := GetCString([]byte(name))
	namePtr := unsafe.Pointer(&nameBytes[0])
	attrPtr := C.xmlHasNsProp(xmlNode.Ptr, (*C.xmlChar)(namePtr), nil)
	if attrPtr == nil {
		return
	} else {
		node := NewNode(unsafe.Pointer(attrPtr), xmlNode.Document)
		if node, ok := node.(*AttributeNode); ok {
			attribute = node
		}
	}
	return
}
1110075
func (n *Closure) Attributes() map[string]interface{} {
	return map[string]interface{}{
		"ReturnsRef":    n.ReturnsRef,
		"Static":        n.Static,
		"PhpDocComment": n.PhpDocComment,
	}
}
746080
func (m *Message) Attr(name string) (starlark.Value, error) {
	// The field was already set?
	val, ok := m.fields[name]
	if ok {
		return val, nil
	}

	// The field wasn't set, but it is defined by the proto schema? Need to
	// generate and return the default value then, except for oneof alternatives
	// that do not have defaults. This is needed to make sure callers are
	// explicitly picking a oneof alternative by assigning a value to it, rather
	// than have it picked implicitly be reading an attribute (which is weird).
	if fd, ok := m.typ.fields[name]; ok {
		if !fd.defaultable {
			return starlark.None, nil
		}
		def, err := newDefaultValue(fd.typ)
		if err != nil {
			return nil, err
		}
		// Lazy initialization of fields is an implementation detail. From the
		// caller's point of view, all fields had their default values even before
		// the object was frozen. Lazy-initialize the field, even if we are frozen,
		// but make sure it is frozen itself too.
		//
		// TODO(vadimsh): This is not thread safe and should be improved if a frozen
		// *Message is shared between goroutines. Generally frozen values are
		// assumed to be safe for cross-goroutine use, which is not the case here.
		// If this becomes important, we can force-initialize and freeze all default
		// fields in Freeze().
		if m.frozen {
			def.Freeze()
		}
		m.fields[name] = def
		return def, nil
	}

	return nil, fmt.Errorf("proto message %q has no field %q", m.Type(), name)
}
641827
func (*Alias) Attr(ctx context.Context, a *fuse.Attr) error {
	a.Mode = os.ModeSymlink | 0777
	// Aliases can't be moved, so let bazil generate an inode.
	return nil
}
1192225
func GetAttr(v Value, attr Value, args ...Value) (Value, error) {
	r := reflect.Indirect(reflect.ValueOf(v))
	if !r.IsValid() {
		return nil, fmt.Errorf("getattr: value does not support attribute lookup: %v", v)
	}
	var retval reflect.Value
	switch r.Kind() {
	case reflect.Struct:
		strval := CoerceString(attr)
		retval = r.FieldByName(strval)
		if !retval.IsValid() {
			var err error
			retval, err = getMethod(v, strval)
			if err != nil {
				return nil, err
			}
		}
	case reflect.Map:
		retval = r.MapIndex(reflect.ValueOf(attr))
	case reflect.Slice, reflect.Array:
		index := int(CoerceNumber(attr))
		if index >= 0 && index < r.Len() {
			retval = r.Index(index)
		}
	}
	if !retval.IsValid() {
		return nil, fmt.Errorf("getattr: unable to locate attribute \"%s\" on \"%v\"", attr, v)
	}
	if retval.Kind() == reflect.Func {
		t := retval.Type()
		if t.NumOut() > 1 {
			return nil, fmt.Errorf("getattr: multiple return values unsupported, called method \"%s\" on \"%v\"", attr, v)
		}
		rargs := make([]reflect.Value, len(args))
		for k, v := range args {
			rargs[k] = reflect.ValueOf(v)
		}
		if t.NumIn() != len(rargs) {
			return nil, fmt.Errorf("getattr: method \"%s\" on \"%v\" expects %d parameter(s), %d given", attr, v, t.NumIn(), len(rargs))
		}
		res := retval.Call(rargs)
		if len(res) == 0 {
			return nil, nil
		}
		retval = res[0]
	}
	return retval.Interface(), nil
}
356716
func Attr(selectorName string, ifAddrsRaw interface{}) (string, error) {
	switch v := ifAddrsRaw.(type) {
	case sockaddr.IfAddr:
		return sockaddr.IfAttr(selectorName, v)
	case sockaddr.IfAddrs:
		return sockaddr.IfAttrs(selectorName, v)
	default:
		return "", fmt.Errorf("unable to obtain attribute %s from type %T (%v)", selectorName, ifAddrsRaw, ifAddrsRaw)
	}
}
1132143
func (ae *AttributeEncoder) String(typ uint16, s string) {
	if ae.err != nil {
		return
	}

	ae.attrs = append(ae.attrs, Attribute{
		Type: typ,
		Data: nlenc.Bytes(s),
	})
}