discovers items (disco#items) of an entity
 can optionally specify a node to discover
180499
def discover_items(node=nil)
      iq = connection.iq_stanza({'to'=>jid.to_s}, x('query', 'xmlns' => Namespaces::DiscoverItems))
      send_iq_stanza_fibered iq
    end
1304090
def _find_toc_node(toc, ref_id, objtype):
    
    for check_node in toc.traverse(nodes.reference):
        if objtype == nodes.section and (
            check_node.attributes["refuri"] == ref_id
            or check_node.attributes["anchorname"] == "#" + ref_id
        ):
            return check_node
        if (
            objtype == addnodes.desc
            and check_node.attributes["anchorname"] == "#" + ref_id
        ):
            return check_node
    return None
518603
def _handle_nodes(nodes: MaybeNodeList) -> List[BaseEntity]:
    """"""
    if isinstance(nodes, BaseEntity):
        return [nodes]

    return [
        (
            parse_result_to_dsl(node)
            if not isinstance(node, BaseEntity) else
            node
        )
        for node in nodes
    ]
221433
private Object getEntityWithAssociationFromNode(EntityMetadata m, Node node)
    {
        Map<String, Object> relationMap = new HashMap<String, Object>();

        /**
         * Map containing Node ID as key and Entity object as value. Helps cache
         * entity objects found earlier for faster lookup and prevents repeated
         * processing
         */
        Map<Long, Object> nodeIdToEntityMap = new HashMap<Long, Object>();

        Object entity = mapper.getEntityFromNode(node, m);

        nodeIdToEntityMap.put(node.getId(), entity);
        populateRelations(m, entity, relationMap, node, nodeIdToEntityMap);

        nodeIdToEntityMap.clear();

        if (!relationMap.isEmpty() && entity != null)
        {
            return new EnhanceEntity(entity, PropertyAccessorHelper.getId(entity, m), relationMap);
        }
        else
        {
            return entity;
        }

    }
848835
private DBObject parseObject(TableDefinition tableDef, UNode docNode) {
        assert tableDef != null;
        assert docNode != null;
        assert docNode.getName().equals("doc");
        
        // Create the DBObject that we will return and parse the child nodes into it.
        DBObject dbObj = new DBObject();
        for (UNode childNode: docNode.getMemberList()) {
            // Extract field name and characterize what we expect.
            String fieldName = childNode.getName();
            FieldDefinition fieldDef = tableDef.getFieldDef(fieldName);
            boolean isLinkField = fieldDef == null ? false : fieldDef.isLinkField();
            boolean isGroupField = fieldDef == null ? false : fieldDef.isGroupField();
            boolean isCollection = fieldDef == null ? false : fieldDef.isCollection();
            Utils.require(!isGroupField,    // we currently don't expect group fields in query results
                          "Unexpected group field in query results: " + fieldName);
            
            // Parse value based on what we expect.
            if (isLinkField) {
                parseLinkValue(dbObj, childNode, fieldDef);
            } else if (isCollection) {
                parseMVScalarValue(dbObj, childNode, fieldDef);
            } else {
                // Simple SV scalar value.
                Utils.require(childNode.isValue(),
                              "Value of an SV scalar must be a value: " + childNode);
                dbObj.addFieldValue(fieldName, childNode.getValue());
            }
        }
        
        // Our object is complete
        return dbObj;
    }
1301145
function findNode(firstNode, predicate) {
    let curNode = firstNode;
    while (curNode != null) {
        if (predicate(curNode.value))
            return curNode;
        curNode = curNode.next;
    }
}
21634
def find(self, path, mode='node'):
        
        path = path.split('.') if isinstance(path, str) else list(path)
        item = self

        for child in path:
            escaped_child = sanitize_identifier(child, escape=False)
            matching_children = [c for c in item.children
                                 if child.endswith(c) or escaped_child.endswith(c)]
            matching_children = sorted(matching_children, key=lambda x: -len(x))
            if matching_children:
                item = item[matching_children[0]]
            else:
                continue
        return item if mode == 'node' else item.path
1297558
def relations_of(self, target, include_object=False):
        '''  '''
        relations = (target if isinstance(target, RamGraphDBNode) else self._get_item_node(target)).outgoing
        if include_object:
            for k in relations:
                for v in relations[k]:
                    if hasattr(v, 'obj'): # filter dead links
                        yield k, v.obj
        else:
            yield from relations
1109257
def find_by(cls, **kwargs) -> 'Entity':
        
        logger.debug(f'Lookup `{cls.__name__}` object with values '
                     f'{kwargs}')

        # Find this item in the repository or raise Error
        results = cls.query.filter(**kwargs).limit(1).all()

        if not results:
            raise ObjectNotFoundError(
                f'`{cls.__name__}` object with values {[item for item in kwargs.items()]} '
                f'does not exist.')

        # Return the first result
        return results.first
259902
private Pair<Integer, AdditionalItemsLoadable> findAdditionalItems(String categoryName,
      List<FeedItem> items) {
    int size = items.size();
    for (int i = 0; i < size; i++) {
      FeedItem item = items.get(i);
      if (item instanceof AdditionalItemsLoadable
          && ((AdditionalItemsLoadable) item).getCategoryName().equals(categoryName)) {
        return Pair.create(i, (AdditionalItemsLoadable) item);
      }
    }

    throw new RuntimeException("No "
        + AdditionalItemsLoadable.class.getSimpleName()
        + " has been found for category = "
        + categoryName);
  }
57033
public final Node buildNode(Object entity, PersistenceDelegator pd, Object entityId, NodeState nodeState)
    {
        String nodeId = ObjectGraphUtils.getNodeId(entityId, entity.getClass());

        Node node = this.graph.getNode(nodeId);

        // If this node is already there in graph (may happen for bidirectional
        // relationship, do nothing and return null)
        // return node in case has already been traversed.

        if (node != null)
        {
            if (this.generator.traversedNodes.contains(node))
            {
                return node;
            }

            return null;
        }

        node = new NodeBuilder().assignState(nodeState).buildNode(entity, pd, entityId, nodeId).node;
        this.graph.addNode(node.getNodeId(), node);
        return node;

    }
31082
function(jid, node, success, error, timeout)
    {
        var attrs = {xmlns: Strophe.NS.DISCO_ITEMS};
        if (node)
            attrs.node = node;

        var items = $iq({from:this._connection.jid,
                         to:jid, type:'get'}).c('query', attrs);
        this._connection.sendIQ(items, success, error, timeout);
    }
464970
def add_node_from_data(self, node: BaseEntity) -> BaseEntity:
        """"""
        assert isinstance(node, BaseEntity)

        if node in self:
            return node

        self.add_node(node)

        if VARIANTS in node:
            self.add_has_variant(node.get_parent(), node)

        elif MEMBERS in node:
            for member in node[MEMBERS]:
                self.add_has_component(node, member)

        elif PRODUCTS in node and REACTANTS in node:
            for reactant_tokens in node[REACTANTS]:
                self.add_has_reactant(node, reactant_tokens)
            for product_tokens in node[PRODUCTS]:
                self.add_has_product(node, product_tokens)

        return node
195350
function(collection, options, cb) {
    var ids = [];
    var keys = _.isFunction(collection.url) ? collection.url() : collection.url;
    keys += options.keys;
    debug('findKeys', keys);
    this.store().getItem(keys, function(err, data) {
      if (data) ids.push(keys);
      cb(null, ids);
    });
  }
73379
function discover(pattern, callback) {
    glob(pattern, function (err, filepaths) {
      if (err) callback(err);
      callback(null, filepaths);
    });
  }
686536
@Override
    public Object find(Class entityClass, Object key)
    {
        GraphDatabaseService graphDb = null;
        if (resource != null)
        {
            graphDb = getConnection();
        }

        if (graphDb == null)
            graphDb = factory.getConnection();

        EntityMetadata m = KunderaMetadataManager.getEntityMetadata(kunderaMetadata, entityClass);

        Object entity = null;
        Node node = mapper.searchNode(key, m, graphDb, true);

        if (node != null && !((Neo4JTransaction) resource).containsNodeId(node.getId()))

        {
            entity = getEntityWithAssociationFromNode(m, node);
        }

        return entity;
    }
621469
protected EnhanceEntity findById(Object primaryKey, EntityMetadata m, Client client)
    {
        try
        {
            Object o = client.find(m.getEntityClazz(), primaryKey);

            if (o == null)
            {
                // No entity found
                return null;
            }
            else
            {
                return o instanceof EnhanceEntity ? (EnhanceEntity) o : new EnhanceEntity(o, getId(o, m), null);
            }
        }
        catch (Exception e)
        {
            throw new EntityReaderException(e);
        }
    }