return an astroid node for a python value
976964
def const_factory(value):
    """"""
    # XXX we should probably be stricter here and only consider stuff in
    # CONST_CLS or do better treatment: in case where value is not in CONST_CLS,
    # we should rather recall the builder on this value than returning an empty
    # node (another option being that const_factory shouldn't be called with something
    # not in CONST_CLS)
    assert not isinstance(value, NodeNG)

    # Hack for ignoring elements of a sequence
    # or a mapping, in order to avoid transforming
    # each element to an AST. This is fixed in 2.0
    # and this approach is a temporary hack.
    if isinstance(value, (list, set, tuple, dict)):
        elts = []
    else:
        elts = value

    try:
        initializer_cls = CONST_CLS[value.__class__]
        initializer = _CONST_CLS_CONSTRUCTORS[initializer_cls]
        return initializer(initializer_cls, elts)
    except (KeyError, AttributeError):
        node = EmptyNode()
        node.object = value
        return node
763548
def into(self, val: str) -> Union['ApiNode', 'ApiEndpoint']:
        """"""
        if val in self.paths:
            return self.paths[val]
        if self.param:
            return self.param
        raise IndexError(_("Value {} is missing from api").format(val))
1110688
def node_to_object(self, node, object):
        ""

        attribute = self.to_lower(node.tag)

        # Yield is a protected keyword in Python, so let's rename it
        attribute = "_yield" if attribute == "yield" else attribute

        try:
            valueString = node.text or ""
            value = float(valueString)
        except ValueError:
            value = node.text

        try:
            setattr(object, attribute, value)
        except AttributeError():
            sys.stderr.write("Attribute <%s> not supported." % attribute)
750144
def visit_Attribute(self, node: AST, dfltChaining: bool = True) -> str:
        """"""
        return '.'.join((self.visit(node.value), node.attr))
71999
def visit_subscript(self, node, parent):
        """"""
        context = self._get_context(node)
        newnode = nodes.Subscript(
            ctx=context, lineno=node.lineno, col_offset=node.col_offset, parent=parent
        )
        newnode.postinit(
            self.visit(node.value, newnode), self.visit(node.slice, newnode)
        )
        return newnode
136780
def _value(obj):
    
    # TODO: this is ugly and makes everything ugly
    # can we handle this with a clean decorator or just requiring that only floats be passed??
    if hasattr(obj, 'value'):
        return obj.value
    elif isinstance(obj, np.ndarray):
        return np.array([o.value for o in obj])
    elif hasattr(obj, '__iter__'):
        return [_value(o) for o in obj]
    return obj
423954
def infer_subscript(self, context=None):
    

    found_one = False
    for value in self.value.infer(context):
        if value is util.Uninferable:
            yield util.Uninferable
            return None
        for index in self.slice.infer(context):
            if index is util.Uninferable:
                yield util.Uninferable
                return None

            # Try to deduce the index value.
            index_value = _SUBSCRIPT_SENTINEL
            if value.__class__ == bases.Instance:
                index_value = index
            else:
                if index.__class__ == bases.Instance:
                    instance_as_index = helpers.class_instance_as_index(index)
                    if instance_as_index:
                        index_value = instance_as_index
                else:
                    index_value = index
            if index_value is _SUBSCRIPT_SENTINEL:
                raise exceptions.InferenceError(node=self, context=context)

            try:
                assigned = value.getitem(index_value, context)
            except (
                exceptions.AstroidTypeError,
                exceptions.AstroidIndexError,
                exceptions.AttributeInferenceError,
                AttributeError,
            ) as exc:
                raise exceptions.InferenceError(node=self, context=context) from exc

            # Prevent inferring if the inferred subscript
            # is the same as the original subscripted object.
            if self is assigned or assigned is util.Uninferable:
                yield util.Uninferable
                return None
            yield from assigned.infer(context)
            found_one = True

    if found_one:
        return dict(node=self, context=context)
    return None
390491
def infer_len(node, context=None):
    
    call = arguments.CallSite.from_call(node)
    if call.keyword_arguments:
        raise UseInferenceDefault("TypeError: len() must take no keyword arguments")
    if len(call.positional_arguments) != 1:
        raise UseInferenceDefault(
            "TypeError: len() must take exactly one argument "
            "({len}) given".format(len=len(call.positional_arguments))
        )
    [argument_node] = call.positional_arguments
    try:
        return nodes.Const(helpers.object_len(argument_node, context=context))
    except (AstroidTypeError, InferenceError) as exc:
        raise UseInferenceDefault(str(exc)) from exc
174738
def _get_go2pydotnode(self):
        """"""
        go2node = {}
        go2obj = self.gosubdag.go2obj
        get_node = self.pydotnodego.get_node
        for goid in self.get_goids_plt():
            goobj = go2obj[goid]
            node = get_node(goid, goobj)
            go2node[goid] = node
            if goid != goobj.id: # goid is an alias for goobj
                go2node[goobj.id] = node
        return go2node
555148
async def getNodeByNdef(self, ndef):
        '''
        
        '''
        buid = s_common.buid(ndef)
        return await self.getNodeByBuid(buid)
702521
def _node_set(self) -> List["InstanceNode"]:
        """"""
        return list(self) if isinstance(self.value, ArrayValue) else [self]
88859
def get_b(self):
        

        try:

            return self.b.value

        except AttributeError:

            # Transform from L,B to R.A., Dec

            return self.sky_coord.transform_to('galactic').b.value
1269226
def python_value(self, value):
        
        value = super(ArrowDateTimeField, self).python_value(value)

        if (isinstance(value, (datetime.datetime, datetime.date,
                               string_types))):
            return arrow.get(value)

        return value
1057480
def visit_return(self, node, parent):
        """"""
        newnode = nodes.Return(node.lineno, node.col_offset, parent)
        if node.value is not None:
            newnode.postinit(self.visit(node.value, newnode))
        return newnode
445177
def as_node(cls, obj):
        
        if isinstance(obj, cls):
            return obj
        elif is_string(obj):
            # Assume filepath.
            return FileNode(obj)
        elif obj is None:
            return obj
        else:
            raise TypeError("Don't know how to convert %s to Node instance." % obj)
367927
def __get_attribute(node, name, default_value=''):
    
    if node.hasAttribute(name):
        return node.attributes[name].value.strip()
    else:
        return default_value
886682
def get_node(self, key):
    """"""
    if key in self.names:
      return self.values.get_member_node(key) if hasattr(self.values, 'get_member_node') else None
    return self.parent.get_node(key)