Count previous tags of the same name until it
    reaches a tag name of type stop_tag, then stop counting
11650
def tag_limit_sibling_ordinal(tag, stop_tag_name):
    
    tag_count = 1
    for prev_tag in tag.previous_elements:
        if prev_tag.name == tag.name:
            tag_count += 1
        if prev_tag.name == stop_tag_name:
            break

    return tag_count
890976
def select_one(self, tag):
        """"""

        tags = self.select(tag, limit=1)
        return tags[0] if tags else None
1369401
def last_tag
      tag = ::FFI::MemoryPointer.new(:string)
	  proto = ::FFI::MemoryPointer.new(:int)
      Klass.getLastTag2(@handle, tag, proto)
      strPtr = tag.get_pointer(0)
      strPtr.null? ? nil : strPtr.read_string
	end
1314011
def _breakRemNewlines(tag):
	""""""
	for i,c in enumerate(tag.contents):
		if type(c) != bs4.element.NavigableString:
			continue
		c.replace_with(re.sub(r' {2,}', ' ', c).replace('\n',''))
764412
def select(self, limit=0):
        """"""

        if limit < 1:
            limit = None

        for child in self.get_descendants(self.tag):
            if self.match(child):
                yield child
                if limit is not None:
                    limit -= 1
                    if limit < 1:
                        break
580110
public static Counter counter(String name, Iterable<Tag> tags) {
        return globalRegistry.counter(name, tags);
    }
1183431
def handle_startendtag(self, tag, attrs):
        """"""
        if tag.lower() in self.allowed_tag_whitelist:
            self.result += '<' + tag
            for (attr, value) in attrs:
                if attr.lower() in self.allowed_attribute_whitelist:
                    self.result += ' %s="%s"' % \
                        (attr, self.handle_attribute_value(value))
            self.result += ' />'
        else:
            if self.render_unallowed_tags:
                self.result += '&lt;' + cgi.escape(tag)
                for (attr, value) in attrs:
                    self.result += ' %s="%s"' % \
                        (attr, cgi.escape(value, True))
                self.result += ' /&gt;'
148493
def handle_starttag(self, tag, attrs):
        """"""
        if tag.lower() in self.allowed_tag_whitelist:
            if tag.lower() == 'ol':
                # we need a list to store the last
                # number used  in the previous ordered lists
                self.previous_nbs.append(self.nb)
                self.nb = 0
                # we need to know which is the tag list
                self.previous_type_lists.append(tag.lower())
                # we must remove any non-relevant spacing and end of
                # line before
                self.result = self.result.rstrip()
            elif tag.lower() == 'ul':
                self.previous_type_lists.append(tag.lower())
                # we must remove any non-relevant spacing and end of
                # line before
                self.result = self.result.rstrip()
            elif tag.lower() == 'li':
                # we must remove any non-relevant spacing and end of
                # line before
                self.result = self.result.rstrip()
                if self.previous_type_lists[-1] == 'ol':
                    self.nb += 1
                    self.result += '\n' + self.line_quotation + \
                                   '  ' * len(self.previous_type_lists) + \
                        str(self.nb) + '. '
                else:
                    self.result += '\n' + self.line_quotation + \
                                   '  ' * len(self.previous_type_lists) + '* '
            elif tag.lower() == 'a':
                # self.previous_type_lists.append(tag.lower())
                for (attr, value) in attrs:
                    if attr.lower() == 'href':
                        self.url = value
                        self.result += '<' + value + '>'
1370187
def count_by_tag(stack, descriptor):
    
    ec2_conn = boto.ec2.connection.EC2Connection()
    resses = ec2_conn.get_all_instances(
                    filters={
                        'tag:stack': stack,
                        'tag:descriptor': descriptor
                    })
    instance_list_raw = list()
    [[instance_list_raw.append(x) for x in res.instances] for res in resses]
    instance_list = [x for x in instance_list_raw if state_filter(x)]
    instances = len(instance_list)
    return instances
1335774
def start_of_chunk(prev_tag, tag, prev_type, type_):
    
    chunk_start = False

    if tag == 'B': chunk_start = True
    if tag == 'S': chunk_start = True

    if prev_tag == 'E' and tag == 'E': chunk_start = True
    if prev_tag == 'E' and tag == 'I': chunk_start = True
    if prev_tag == 'S' and tag == 'E': chunk_start = True
    if prev_tag == 'S' and tag == 'I': chunk_start = True
    if prev_tag == 'O' and tag == 'E': chunk_start = True
    if prev_tag == 'O' and tag == 'I': chunk_start = True

    if tag != 'O' and tag != '.' and prev_type != type_:
        chunk_start = True

    return chunk_start
113748
protected function processTags()
	{
		if (empty($this->tagStack))
		{
			return;
		}

		// Initialize the count tables
		foreach (array_keys($this->tagsConfig) as $tagName)
		{
			$this->cntOpen[$tagName]  = 0;
			$this->cntTotal[$tagName] = 0;
		}

		// Process the tag stack, close tags that were left open and repeat until done
		do
		{
			while (!empty($this->tagStack))
			{
				if (!$this->tagStackIsSorted)
				{
					$this->sortTags();
				}

				$this->currentTag = array_pop($this->tagStack);
				$this->processCurrentTag();
			}

			// Close tags that were left open
			foreach ($this->openTags as $startTag)
			{
				// NOTE: we add tags in hierarchical order (ancestors to descendants) but since
				//       the stack is processed in LIFO order, it means that tags get closed in
				//       the correct order, from descendants to ancestors
				$this->addMagicEndTag($startTag, $this->textLen);
			}
		}
		while (!empty($this->tagStack));
	}
784036
def find(self, tag_name, params=None, fn=None, case_sensitive=False):
        
        return [
            x for x in self.findAll(tag_name, params, fn, case_sensitive)
            if not x.isEndTag()
        ]
1080146
def find_all(self, tagtype):
        '''  '''
        return [t for t in self.__tags if t.tagtype == tagtype]
125812
private void updateEndCountText() {
        final String END_COUNT_MARKER = "%d";
        String endString = mResources.getQuantityString(R.plurals.recurrence_end_count,
                mModel.endCount);
        int markerStart = endString.indexOf(END_COUNT_MARKER);

        if (markerStart != -1) {
            if (markerStart == 0) {
                Log.e(TAG, "No text to put in to recurrence's end spinner.");
            } else {
                int postTextStart = markerStart + END_COUNT_MARKER.length();
                mPostEndCount.setText(endString.substring(postTextStart,
                        endString.length()).trim());
            }
        }
    }
780535
public static Counter counter(String name, String... tags) {
        return globalRegistry.counter(name, tags);
    }
4102
def merge_adjacent(dom, tag_name):
    
    for node in dom.getElementsByTagName(tag_name):
        prev_sib = node.previousSibling
        if prev_sib and prev_sib.nodeName == node.tagName:
            for child in list(node.childNodes):
                prev_sib.appendChild(child)
            remove_node(node)
1283093
def count_objects_by_tags(self, metric, scraper_config):
        
        config = self.object_count_params[metric.name]
        metric_name = "{}.{}".format(scraper_config['namespace'], config['metric_name'])
        object_counter = Counter()

        for sample in metric.samples:
            tags = [
                self._label_to_tag(l, sample[self.SAMPLE_LABELS], scraper_config) for l in config['allowed_labels']
            ] + scraper_config['custom_tags']
            object_counter[tuple(sorted(tags))] += sample[self.SAMPLE_VALUE]

        for tags, count in iteritems(object_counter):
            self.gauge(metric_name, count, tags=list(tags))