Show all nodes which have assigned a given tag
343508
def list_nodes_with_tag(tag):
    """"""
    lib.print_nodes(lib.get_nodes_with_tag(tag, env.chef_environment,
                                           littlechef.include_guests))
262313
function tag(node, tagName){
    var element = get(node) || document;

    if (tagName == '*' && element.all)
      return arrayFrom(element.all);
    else
      return arrayFrom(element.getElementsByTagName(tagName || '*'));
  }
256963
function ListNode (children) {
    for(var i = 0; i < children.length; i++)
        this[i] = children[i];
    this.length = children.length;
}
113265
def view_all_tags(ctx, param, value):
    
    # To make sure this function executed only when the flag was called
    if not value or ctx.resilient_parsing:
        return
    avail_tags = dict()
    print("\nMultiQC Available module tag groups:\n")
    for mod_dict in filter(lambda mod:isinstance(mod, dict), config.module_order):
        mod_key, mod_val = list(mod_dict.items())[0]
        tags = list(mod_val.get('module_tag', []))
        for t in tags:
            if t not in avail_tags:
                avail_tags[t] = []
            avail_tags[t].append(mod_key)
    for t in sorted(avail_tags.keys(), key=lambda s: s.lower()):
        print (" - {}:".format(t))
        for ttgs in avail_tags[t]:
            print ("   - {}".format(ttgs))
    ctx.exit()
231463
def nodes(self):
        """"""
        getnode = self._nodes.__getitem__
        return [getnode(nid) for nid in self._nodeids]
878397
@SuppressWarnings("unchecked")
    private <T extends DomElement> List<T> allByTagName(String tagName) {
        return (List<T>) htmlPage.getElementsByTagName(tagName);
    }
343043
def nodes_in(self, name) -> iter:
        """"""
        yield from (node for node in self.all_in(name) if self.is_node(node))
1072027
def get_nodes_by_tag(self, graph, tag_name):
        
        for node, real_node in self.parsed_nodes(graph):
            if tag_name in real_node.tags:
                yield node
1150421
def get_fields(node, fields_tag="field_list"):
    
    fields_nodes = [c for c in node.children if c.tagname == fields_tag]
    if len(fields_nodes) == 0:
        return {}
    assert len(fields_nodes) == 1, "multiple nodes with tag " + fields_tag
    fields_node = fields_nodes[0]
    fields = [
        {f.tagname: f.rawsource.strip() for f in n.children}
        for n in fields_node.children
        if n.tagname == "field"
    ]
    return {f["field_name"]: f["field_body"] for f in fields}
857750
def node_labels(self):
        """"""
        assert list(self.node_indices)[0] == 0
        labels = list("m{}".format(i) for i in self.node_indices)
        return NodeLabels(labels, self.node_indices)
665183
def nodes_with_tag(tag):
    """"""
    nodes = lib.get_nodes_with_tag(tag, env.chef_environment,
                                   littlechef.include_guests)
    nodes = [n['name'] for n in nodes]
    if not len(nodes):
        print("No nodes found with tag '{0}'".format(tag))
        sys.exit(0)
    return node(*nodes)
704127
def get_tags(self):
        """"""
        res = self.get_request('/tag')
        return [Tag(cloud_manager=self, **tag) for tag in res['tags']['tag']]
518428
def get_top_tags(self, limit=None):
        """"""

        doc = self._request(self.ws_prefix + ".getTopTags", True)

        elements = doc.getElementsByTagName("tag")
        seq = []

        for element in elements:
            tag_name = _extract(element, "name")
            tagcount = _extract(element, "count")

            seq.append(TopItem(Tag(tag_name, self.network), tagcount))

        if limit:
            seq = seq[:limit]

        return seq
358804
function findNestedBlocks (ast) {
  var tagged = [];
  traverse.traverse(ast, {
    enter: function (node, parent) {
      if (node.type === 'BlockStatement' && parent && parent.type === 'BlockStatement') {
        tagged.push([node, parent]);
      }
    }
  });
  return tagged;
}
315904
def __get_tag_ids(self, tags):
        """"""

        db_tags = self.fetchall("select * from tags where name in (%s)"
                                            % ",".join(["?"] * len(tags)), tags) # bit of magic here - using sqlites bind variables

        changes = False

        # check if any of tags needs resurrection
        set_complete = [str(tag["id"]) for tag in db_tags if tag["autocomplete"] == "false"]
        if set_complete:
            changes = True
            self.execute("update tags set autocomplete='true' where id in (%s)" % ", ".join(set_complete))


        found_tags = [tag["name"] for tag in db_tags]

        add = set(tags) - set(found_tags)
        if add:
            statement = "insert into tags(name) values(?)"

            self.execute([statement] * len(add), [(tag,) for tag in add])

            return self.__get_tag_ids(tags)[0], True # all done, recurse
        else:
            return db_tags, changes
611235
def get_nodes_with_tag(tag, environment=None, include_guests=False):
    """"""
    nodes = get_nodes(environment)
    nodes_mapping = dict((n['name'], n) for n in nodes)
    for n in nodes:
        if tag in n.get('tags', []):
            # Remove from node mapping so it doesn't get added twice by
            # guest walking below
            try:
                del nodes_mapping[n['fqdn']]
            except KeyError:
                pass
            yield n
            # Walk guest if it is a host
            if include_guests and n.get('virtualization', {}).get('role') == 'host':
                for guest in n['virtualization'].get('guests', []):
                    try:
                        yield nodes_mapping[guest['fqdn']]
                    except KeyError:
                        # we ignore guests which are not in the same
                        # chef environments than their hosts for now
                        pass
579985
def tag_list(self):
        """"""
        tags = [tag.strip() for tag in self.tag_string.split(",")]
        return sorted(filter(None, tags))