Returns a callable that looks up the given attribute from a
    passed object with the rules of the environment.  Dots are allowed
    to access attributes of attributes.  Integer parts in paths are
    looked up as integers.
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
752095
def visit_Attribute(self, node: ast.Attribute) -> Any:
        """"""
        value = self.visit(node=node.value)
        if not isinstance(node.ctx, ast.Load):
            raise NotImplementedError(
                "Can only compute a value of Load on the attribute {}, but got context: {}".format(node.attr, node.ctx))

        result = getattr(value, node.attr)

        self.recomputed_values[node] = result
        return result
1289662
def infer_attribute(self, context=None):
    """"""
    for owner in self.expr.infer(context):
        if owner is util.Uninferable:
            yield owner
            continue

        if context and context.boundnode:
            # This handles the situation where the attribute is accessed through a subclass
            # of a base class and the attribute is defined at the base class's level,
            # by taking in consideration a redefinition in the subclass.
            if isinstance(owner, bases.Instance) and isinstance(
                context.boundnode, bases.Instance
            ):
                try:
                    if helpers.is_subtype(
                        helpers.object_type(context.boundnode),
                        helpers.object_type(owner),
                    ):
                        owner = context.boundnode
                except exceptions._NonDeducibleTypeHierarchy:
                    # Can't determine anything useful.
                    pass

        try:
            context.boundnode = owner
            yield from owner.igetattr(self.attrname, context)
            context.boundnode = None
        except (exceptions.AttributeInferenceError, exceptions.InferenceError):
            context.boundnode = None
        except AttributeError:
            # XXX method / function
            context.boundnode = None
    return dict(node=self, context=context)
567132
def rules(cls, attr=None):
        
        try:
            if attr is None:
                attr = cls._rules_attr()
            return getattr(cls, attr).keys()
        except TypeError:
            return ()
1373847
def _metaclass_lookup_attribute(self, name, context):
        """"""
        attrs = set()
        implicit_meta = self.implicit_metaclass()
        metaclass = self.metaclass()
        for cls in {implicit_meta, metaclass}:
            if cls and cls != self and isinstance(cls, ClassDef):
                cls_attributes = self._get_attribute_from_metaclass(cls, name, context)
                attrs.update(set(cls_attributes))
        return attrs
1189542
def lookup_obj_attribute(self, obj, field):
        
        curr_field = field.encode('ascii', 'ignore').decode("utf-8")
        rest = None

        if field.find('.') >= 0:
            curr_field = field.split('.')[0]
            rest = '.'.join(field.split('.')[1:])

        # next up is the object itself
        obj_field = getattr(obj, curr_field, None)

        # if it is callable, do so
        if obj_field and getattr(obj_field, '__call__', None):
            obj_field = obj_field()

        if obj_field and rest:
            return self.lookup_obj_attribute(obj_field, rest)
        else:
            return obj_field
245201
def attrgetter_atom_handle(loc, tokens):
    """"""
    name, args = attrgetter_atom_split(tokens)
    if args is None:
        return '_coconut.operator.attrgetter("' + name + '")'
    elif "." in name:
        raise CoconutDeferredSyntaxError("cannot have attribute access in implicit methodcaller partial", loc)
    elif args == "":
        return '_coconut.operator.methodcaller("' + tokens[0] + '")'
    else:
        return '_coconut.operator.methodcaller("' + tokens[0] + '", ' + tokens[2] + ")"
741764
def _recursive_getattr(module, path):
  """"""
  if "." not in path:
    return getattr(module, path)
  else:
    first, rest = path.split(".", 1)
    return _recursive_getattr(getattr(module, first), rest)
821851
def getattribute(value, arg):
    """"""
    
    if callable(getattr(value, arg)):
        return str(getattr(value, arg)())
    elif hasattr(value, str(arg)):
        return getattr(value, arg)
    elif hasattr(value, 'has_key') and value.has_key(arg):
        return value[arg]
    elif numeric_test.match(str(arg)) and len(value) > int(arg):
        return value[int(arg)]
    elif arg in dir(value):
        return getattr(value, arg)()
    else:
        return settings.TEMPLATE_STRING_IF_INVALID
338518
def getattrdeep(obj, attr, *default):
    ''
    attrs = attr.split('.')
    if default:
        getattr_default = lambda o,a,d=default[0]: getattr(o, a, d)
    else:
        getattr_default = lambda o,a: getattr(o, a)

    for a in attrs[:-1]:
        obj = getattr_default(obj, a)

    return getattr_default(obj, attrs[-1])
315581
def _object_with_attr(self, name):
        
        for obj in self._objects:
            if hasattr(obj, name):
                return obj

        raise AttributeError("No object has attribute {!r}".format(name))
1319459
public PathImpl lookupNative(String name, Map<String,Object> attributes)
  {
    return getWrappedPath().lookupNative(name, attributes);
  }
891078
def get( self, instance, **kwargs ):
        
        target = instance
        for attr in self._path:
            target = getattr( target, attr )
        return target
218440
def lookup_object(spec):
    
    parts, target = spec.split(':') if ':' in spec else (spec, None)
    module = __import__(parts)

    for part in parts.split('.')[1:] + ([target] if target else []):
        module = getattr(module, part)

    return module
895118
def getAttribute(self, attribute):
        
        if type(attribute) in (list, tuple):
            if len(attribute) != 2:
                raise LookupError, 'To access attributes must use name or (namespace,name)'

            ns_dict = self.attributes.get(attribute[0])
            if ns_dict is None:
                return None

            return ns_dict.get(attribute[1])

        return self.attributes.get(attribute)
240330
def getAttr(self, node, name, nsuri=None, default=join):
        """"""
        if nsuri is None:
            result = node._attrs.get(name, None)
            if result is None:
                for item in node._attrsNS.keys():
                    if item[1] == name:
                        result = node._attrsNS[item]
                        break
        else:
            result = node._attrsNS.get((nsuri, name), None)
        if result is not None:
            return result.value
        if default is not join:
            return default
        return ''
1344617
function getAttribute(path, attrNode) {
    path.forEach(attrName => {
        if (!(attrNode.attributes && attrNode.attributes[attrName])) {
            throw new ImplementationError(`Result-Builder: Unknown attribute "${path.join('.')}"`);
        }
        attrNode = attrNode.attributes[attrName];
    });
    return attrNode;
}