Helper function for the resource, action and environment methods
to get an attribute.
182822
private EvaluationResult getGenericAttributes(URI type, URI id, URI issuer,
                                                  Map<String, List<Attribute>> map, URI category,
                                                  int designatorType) {
        // try to find the id
        List<Attribute> attrList = (List)(map.get(id.toString()));
        if (attrList == null) {
            // the request didn't have an attribute with that id, so we should
            // try asking the wrapped context
            Attribute contextValue = checkContext(type, id, issuer, category, designatorType);
            if (contextValue != null) {
                attrList = Collections.singletonList(contextValue);
                // cache the context values
                map.put(id.toString(), attrList);
            } else {
            // the context didn't have an attribute with that id, so we should
            // try asking the attribute finder
                attrList = Collections.emptyList();
            }
        }

        // now go through each, considering each Attribute object
        final List<AttributeValue> attributes;
        Attribute attr = null;
        switch (attrList.size()) {
            case 0:
                attributes = Collections.emptyList();
                break;
            case 1:
                attr = attrList.get(0);
                // make sure the type and issuer are correct
                if ((attr.getType().equals(type)) &&
                        ((issuer == null) ||
                                ((attr.getIssuer() != null) &&
                                        (attr.getIssuer().equals(issuer.toString()))))) {
                    attributes = new ArrayList<AttributeValue>(attrList.get(0).getValues());
                } else {
                    attributes = Collections.emptyList();
                }
                break;
            default:
                Iterator it = attrList.iterator();
                attributes = new ArrayList<AttributeValue>();
                while (it.hasNext()) {
                    attr = (Attribute)(it.next());
    
                    // make sure the type and issuer are correct
                    if ((attr.getType().equals(type)) &&
                            ((issuer == null) ||
                                    ((attr.getIssuer() != null) &&
                                            (attr.getIssuer().equals(issuer.toString()))))) {
    
                        // if we got here, then we found a match, so we want to pull
                        // out the values and put them in out list
                        attributes.addAll(attr.getValues());
                    }
                }
        }

        // see if we found any acceptable attributes
        if (attributes.size() == 0) {
            // we failed to find any that matched the type/issuer, or all the
            // Attribute types were empty...so ask the finder
                logger.debug("Attribute not in request: {} ... querying AttributeFinder",
                        id);

            return callHelper(type, id, issuer, category, designatorType);
        } else {
            // if we got here, then we found at least one useful AttributeValue
            return new EvaluationResult(new BagAttribute(type, attributes));
        }
                
    }
1057336
def get_attr(obj, string_rep, default=_get_attr_raise_on_attribute_error, separator="."):
    
    attribute_chain = string_rep.split(separator)

    current_obj = obj

    for attr in attribute_chain:
        try:
            current_obj = getattr(current_obj, attr)
        except AttributeError:
            if default is _get_attr_raise_on_attribute_error:
                raise AttributeError(
                    "Bad attribute \"{}\" in chain: \"{}\"".format(attr, string_rep)
                )
            return default

    return current_obj
824453
def get_attr(self, method_name):
        """"""
        return self.attrs.get(method_name) or self.get_callable_attr(method_name)
277698
def get_all_resource_attributes_in_network(attr_id, network_id, **kwargs):
    

    user_id = kwargs.get('user_id')

    try:
        a = db.DBSession.query(Attr).filter(Attr.id == attr_id).one()
    except NoResultFound:
        raise HydraError("Attribute %s not found"%(attr_id,))

    ra_qry = db.DBSession.query(ResourceAttr).filter(
                ResourceAttr.attr_id==attr_id,
                or_(Network.id == network_id,
                Node.network_id==network_id,
                Link.network_id==network_id,
                ResourceGroup.network_id==network_id)
            ).outerjoin('node')\
             .outerjoin('link')\
             .outerjoin('network')\
             .outerjoin('resourcegroup')\
             .options(joinedload_all('node'))\
             .options(joinedload_all('link'))\
             .options(joinedload_all('resourcegroup'))\
             .options(joinedload_all('network'))

    resourceattrs = ra_qry.all()

    json_ra = []
    #Load the metadata too
    for ra in resourceattrs:
        ra_j = JSONObject(ra, extras={'node':JSONObject(ra.node) if ra.node else None,
                                               'link':JSONObject(ra.link) if ra.link else None,
                                               'resourcegroup':JSONObject(ra.resourcegroup) if ra.resourcegroup else None,
                                               'network':JSONObject(ra.network) if ra.network else None})
        
        if ra_j.node is not None:
            ra_j.resource = ra_j.node
        elif ra_j.link is not None:
            ra_j.resource = ra_j.link
        elif ra_j.resourcegroup is not None:
            ra_j.resource = ra_j.resourcegroup
        elif ra.network is not None:
            ra_j.resource = ra_j.network
        
        json_ra.append(ra_j)

    return json_ra
1119554
def get_attribute_at(config, target_path, key, default_value=None):
    
    for target in target_path:
        config = config[target]
    return config[key] if key in config else default_value
1020862
def get(self, attr: FetchAttribute) -> MaybeBytes:
        
        attr_name = attr.value.decode('ascii')
        method = getattr(self, '_get_' + attr_name.replace('.', '_'))
        return method(attr)
1254137
def value_getattr():
    

    def value_getattr(value, context, **_params):
        value = getattr(value, context["key"])
        return _attr(value)

    return source_getattr
556171
def get_attribute_by_name(el, name, default=None):
        """"""

        value = default
        if el._is_xml:
            try:
                value = el.attrs[name]
            except KeyError:
                pass
        else:
            for k, v in el.attrs.items():
                if util.lower(k) == name:
                    value = v
                    break
        return value
616010
def resource_attribute(resource, name)
      raise ArgumentError, "Attribute name cannot be empty" if name.empty?
      resource_attributes(resource)[name.to_s]
    end
422670
def is_resource_class_resource_attribute(rc, attr_name):
    
    attr = get_resource_class_attribute(rc, attr_name)
    return attr != RESOURCE_ATTRIBUTE_KINDS.TERMINAL
60622
@SuppressWarnings("unchecked")
    public <T> T getAttribute( String attrName, Class<T> adaptee ) {
        if (attrName == null) {
            return null;
        }
        if (adaptee == null) {
            adaptee = (Class<T>) String.class;
        }

        Object attribute = feature.getAttribute(attrName);
        if (attribute == null) {
            return null;
        }
        if (attribute instanceof Number) {
            Number num = (Number) attribute;
            if (adaptee.isAssignableFrom(Double.class)) {
                return adaptee.cast(num.doubleValue());
            } else if (adaptee.isAssignableFrom(Float.class)) {
                return adaptee.cast(num.floatValue());
            } else if (adaptee.isAssignableFrom(Integer.class)) {
                return adaptee.cast(num.intValue());
            } else if (adaptee.isAssignableFrom(Long.class)) {
                return adaptee.cast(num.longValue());
            } else if (adaptee.isAssignableFrom(String.class)) {
                return adaptee.cast(num.toString());
            } else {
                throw new IllegalArgumentException();
            }
        } else if (attribute instanceof String) {
            if (adaptee.isAssignableFrom(Double.class)) {
                try {
                    Double parsed = Double.parseDouble((String) attribute);
                    return adaptee.cast(parsed);
                } catch (Exception e) {
                    return null;
                }
            } else if (adaptee.isAssignableFrom(Float.class)) {
                try {
                    Float parsed = Float.parseFloat((String) attribute);
                    return adaptee.cast(parsed);
                } catch (Exception e) {
                    return null;
                }
            } else if (adaptee.isAssignableFrom(Integer.class)) {
                try {
                    Integer parsed = Integer.parseInt((String) attribute);
                    return adaptee.cast(parsed);
                } catch (Exception e) {
                    return null;
                }
            } else if (adaptee.isAssignableFrom(String.class)) {
                return adaptee.cast(attribute);
            } else {
                throw new IllegalArgumentException();
            }
        } else if (attribute instanceof Geometry) {
            return null;
        } else {
            throw new IllegalArgumentException("Can't adapt attribute of type: " + attribute.getClass().getCanonicalName());
        }
    }
168170
def make_attrgetter(environment, attribute, postprocess=None):
    
    if attribute is None:
        attribute = []
    elif isinstance(attribute, string_types):
        attribute = [int(x) if x.isdigit() else x for x in attribute.split('.')]
    else:
        attribute = [attribute]

    def attrgetter(item):
        for part in attribute:
            item = environment.getitem(item, part)

        if postprocess is not None:
            item = postprocess(item)

        return item

    return attrgetter
444798
public Object getAttribute(String name)
    {
        if (_attributes==null)
            return null;
        return _attributes.get(name);
    }
975812
private ProcessAttributes getAttributes() {
    return new ProcessAttributes(
          getCommand(),
          getDirectory(),
          new LinkedHashMap<String, String>(environment),
          allowedExitValues == null ? null : new HashSet<Integer>(allowedExitValues));
  }
95805
def get_attribute(self, attribute):
        

        # Check that the attribute exists.
        try:
            attr = attributes.AttributesByID[attribute]
        except KeyError:
            return 0, constants.StatusCode.error_nonsupported_attribute

        # Check that the attribute is valid for this session type.
        if not attr.in_resource(self.session_type):
            return 0, constants.StatusCode.error_nonsupported_attribute

        # Check that the attribute is readable.
        if not attr.read:
            raise Exception('Do not now how to handle write only attributes.')

        # Return the current value of the default according the VISA spec
        return self.attrs.setdefault(attribute, attr.default), constants.StatusCode.success
416874
def attribute_response(resource, name, value):
    
    if _get_acceptable_response_type() == JSON:
        return _single_attribute_json_response(name, value)
    else:
        return _single_attribute_html_response(resource, name, value)
950266
def action_attr(attr_name):
    

    def action_attr(_value, context, **_params):
        value = getattr(context["action"], attr_name)
        return _attr(value)

    return action_attr