If the given node has an attribute, visits the attribute, and
    otherwise returns None.
777435
def _visit_or_none(node, attr, visitor, parent, visit="visit", **kws):
    
    value = getattr(node, attr, None)
    if value:
        return getattr(visitor, visit)(value, parent, **kws)

    return None
735918
def visit_attribute(self, node, parent):
        """"""
        context = self._get_context(node)
        if context == astroid.Del:
            # FIXME : maybe we should reintroduce and visit_delattr ?
            # for instance, deactivating assign_ctx
            newnode = nodes.DelAttr(node.attr, node.lineno, node.col_offset, parent)
        elif context == astroid.Store:
            newnode = nodes.AssignAttr(node.attr, node.lineno, node.col_offset, parent)
            # Prohibit a local save if we are in an ExceptHandler.
            if not isinstance(parent, astroid.ExceptHandler):
                self._delayed_assattr.append(newnode)
        else:
            newnode = nodes.Attribute(node.attr, node.lineno, node.col_offset, parent)
        newnode.postinit(self.visit(node.value, newnode))
        return newnode
285956
def _attribute_is_magic(node, attrs, parents):
    """"""
    if node.attrname not in attrs:
        return False
    if not node.last_child():
        return False

    try:
        for cls in node.last_child().inferred():
            if isinstance(cls, Super):
                cls = cls._self_class  # pylint: disable=protected-access
            if node_is_subclass(cls, *parents) or cls.qname() in parents:
                return True
    except InferenceError:
        pass
    return False
669751
def get_optional_attribute(self, element, attribute):
    """"""
    try:
      return self.get_attribute(element, attribute)
    except self.XmlError:
      return None
1024679
def is_not_none(entity, prop, name):
    ""
    return is_not_empty(entity, prop, name) and name in entity._data and getattr(entity, name) is not None
1172428
def has_attribute(module_name, attribute_name):
    """"""
    init_file = '%s/__init__.py' % module_name
    return any(
        [attribute_name in init_line for init_line in open(init_file).readlines()]
    )
1063488
def has(self, name):
        
        for attr in self.attributes:
            if attr.name == name.strip():
                return True
        return False
153493
def get_attribute_by_id(attr_id, **kwargs):
    

    try:
        attr_i = db.DBSession.query(Attr).filter(Attr.id==attr_id).one()
        return attr_i
    except NoResultFound:
        return None
402338
private static boolean isAttributeIgnored(Node receivedElement, Node receivedAttribute,
                                             Set<String> ignoreMessageElements, NamespaceContext namespaceContext) {
        if (CollectionUtils.isEmpty(ignoreMessageElements)) {
            return false;
        }

        /** This is the faster version, but then the ignoreValue name must be
         * the full path name like: Numbers.NumberItem.AreaCode
         */
        if (ignoreMessageElements.contains(XMLUtils.getNodesPathName(receivedElement) + "." + receivedAttribute.getNodeName())) {
            return true;
        }

        /** This is the slower version, but here the ignoreValues can be
         * the short path name like only: AreaCode
         *
         * If there are more nodes with the same short name,
         * the first one will match, eg. if there are:
         *      Numbers1.NumberItem.AreaCode
         *      Numbers2.NumberItem.AreaCode
         * And ignoreValues contains just: AreaCode
         * the only first Node: Numbers1.NumberItem.AreaCode will be ignored.
         */
        for (String expression : ignoreMessageElements) {
            Node foundAttributeNode = XMLUtils.findNodeByName(receivedElement.getOwnerDocument(), expression);

            if (foundAttributeNode != null && receivedAttribute.isSameNode(foundAttributeNode)) {
                return true;
            }
        }

        /** This is the XPath version using XPath expressions in
         * ignoreValues to identify nodes to be ignored
         */
        for (String expression : ignoreMessageElements) {
            if (XPathUtils.isXPathExpression(expression)) {
                Node foundAttributeNode = XPathUtils.evaluateAsNode(receivedElement.getOwnerDocument(),
                        expression,
                        namespaceContext);
                if (foundAttributeNode != null && foundAttributeNode.isSameNode(receivedAttribute)) {
                    return true;
                }
            }
        }

        return false;
    }
719453
def _get_attribute_value_for_node(self, record):
        
        
        # Abort if this node has not get split on an attribute. 
        if self.attr_name is None:
            return
        
        # Otherwise, lookup the attribute value for this node in the
        # given record.
        attr = self.attr_name
        attr_value = record[attr]
        attr_values = self.get_values(attr)
        if attr_value in attr_values:
            return attr_value
        else:
            # The value of the attribute in the given record does not directly
            # map to any previously known values, so apply a missing value
            # policy.
            policy = self.tree.missing_value_policy.get(attr)
            assert policy, \
                ("No missing value policy specified for attribute %s.") \
                % (attr,)
            if policy == USE_NEAREST:
                # Use the value that the tree has seen that's also has the
                # smallest Euclidean distance to the actual value.
                assert self.tree.data.header_types[attr] \
                    in (ATTR_TYPE_DISCRETE, ATTR_TYPE_CONTINUOUS), \
                    "The use-nearest policy is invalid for nominal types."
                nearest = (1e999999, None)
                for _value in attr_values:
                    nearest = min(
                        nearest,
                        (abs(_value - attr_value), _value))
                _, nearest_value = nearest
                return nearest_value
            else:
                raise Exception("Unknown missing value policy: %s" % (policy,))
532181
def visit_If(self, node):
        """"""
        # do not optimize ifs that have a block inside so that it doesn't
        # break super().
        if node.find(nodes.Block) is not None:
            return self.generic_visit(node)
        try:
            val = self.visit(node.test).as_const()
        except nodes.Impossible:
            return self.generic_visit(node)
        if val:
            body = node.body
        else:
            body = node.else_
        result = []
        for node in body:
            result.extend(self.visit_list(node))
        return result
1302537
private boolean nodeAttribute(Node node, String attributeName, boolean defaultValue) {
        boolean value = defaultValue;
        if (node.hasAttributes()) {
            Node attribute = node.getAttributes().getNamedItem(attributeName);
            if (attribute != null) {
                value = Boolean.valueOf(attribute.getNodeValue());
            }
        }
        return value;
    }
1053749
def compare(self, node, prev_value=None, prev_index=None):
        
        if prev_value is not None and node.value != prev_value or \
           prev_index is not None and node.index != prev_index:
            raise TestFailed(index=self.index)
142492
def visit(self, node):
        """"""
        method = 'visit_' + type(node).__name__
        return getattr(self, method, self.fallback)(node)
1180391
def _document_by_attribute(self, kind, condition=None):
        
        doc = self.document
        if doc:
            for attr in doc.attributes:
                if isinstance(attr, kind):
                    if not condition or condition(attr):
                        return doc
                    return None
274346
def get_attribute_selected(self, attribute):
        
        items_list = self.get_options()
        return next(iter([item.get_attribute(attribute) for item in items_list if item.is_selected()]), None)
1000746
public boolean hasAttribute(String name)
  {
    return DTM.NULL != dtm.getAttributeNode(node,null,name);
  }