Count instances of testchar at end of teststr.
189059
def count_end(teststr, testchar):
    """"""
    count = 0
    x = len(teststr) - 1
    while x >= 0 and teststr[x] == testchar:
        count += 1
        x -= 1
    return count
668121
def text_till(self, strings, keep_index=False):
        """"""
        if isinstance(strings, str):
            strings = [strings]

        original_index = self.index

        text = ""
        matched_string = ""

        while self.more:
            test_against = self.characters(len(max(strings, key=len)))
            for string in strings:
                if string.startswith("^"):
                    if test_against[0] in (" ", "\t", "\n", ")", "(") and test_against[1:].startswith(string[1:]):
                        matched_string = string
                        break
                if test_against.startswith(string):
                    matched_string = string
                    break

            if matched_string:
                break

            text += self.pop()

        self += 1

        if keep_index:
            self.index = original_index

        return (text, matched_string)
251350
function instancesFromMatches(word, text, selector) {
  var match, ret = [];
  var re = new RegExp('\\b'+utils.escapeRegex(word)+'\\b', 'gi');
  var instance = 1;
  while ((match = re.exec(text)) !== null) {
    GLOBAL.debug(text.length, text.substring(0, 10), word, match.index, text.substr(match.index, word.length));
    // It's not in a tag
    if (text.indexOf('<' < 0) || (text.indexOf('>', match.index) > text.indexOf('<'.match.index))) {
      ret.push(annoLib.createInstance({exact: text.substr(match.index, word.length), instance: instance, selector: selector}));
    }
    instance++;
  }
  return ret;
}
1231245
private static int findMinimumLeadingSpaces(String line, int count) {
        int length = line.length();
        int index = 0;
        while (index < length && index < count && Character.isWhitespace(line.charAt(index))) index++;
        return index;
    }
202478
public final void getChars(int start, int end, char[] dest, int off) {
        mText.getChars(start, end, dest, off);
    }
665299
def count(cls, name):
        """"""
        counter = cls.collection.find_one({'name': name}) or {}
        return counter.get('seq', 0)
254176
public static String repeatChars(final char ch, final int count) {
        return CharBuffer.allocate(count).toString().replace('\0', ch);
    }
1337618
public static int findLastNotOf(String container, String charSeq, int end){
        for (int i = end; i < container.length() && i >= 0; --i){
            if (!charSeq.contains("" + container.charAt(i)))
                return i;        
        }
        return -1;
    }
419464
private int countInstances(HeaderElement root) {
        int count = 0;
        HeaderElement elem = root;
        while (null != elem) {
            if (!elem.wasRemoved()) {
                count++;
            }
            elem = elem.nextInstance;
        }
        return count;
    }
1263316
def number_of_statements(self, n):
        """"""
        stmt_type = n.type
        if stmt_type == syms.compound_stmt:
            return 1
        elif stmt_type == syms.stmt:
            return self.number_of_statements(n.children[0])
        elif stmt_type == syms.simple_stmt:
            # Divide to remove semi-colons.
            return len(n.children) // 2
        else:
            raise AssertionError("non-statement node")
141619
def dump_junit(self):
        """"""
        testsuites = ElementTree.Element('testsuites', name='therapist', time=str(round(self.execution_time, 2)),
                                         tests=str(self.count()), failures=str(self.count(status=Result.FAILURE)),
                                         errors=str(self.count(status=Result.ERROR)))

        for result in self.objects:
            failures = '1' if result.is_failure else '0'
            errors = '1' if result.is_error else '0'

            testsuite = ElementTree.SubElement(testsuites, 'testsuite', id=result.process.name,
                                               name=str(result.process), time=str(round(result.execution_time, 2)),
                                               tests='1', failures=failures, errors=errors)

            testcase = ElementTree.SubElement(testsuite, 'testcase', time=str(round(result.execution_time, 2)))
            testcase.attrib['name'] = result.process.name

            if result.is_failure or result.is_error:
                if result.is_failure:
                    element = ElementTree.SubElement(testcase, 'failure', type='failure')
                else:
                    element = ElementTree.SubElement(testcase, 'error', type='error')

                if result.error:
                    element.text = result.error
                else:
                    element.text = result.output if result.output else ''

        xmlstr = ElementTree.tostring(testsuites, encoding='utf-8').decode('utf-8')
        return '<?xml version="1.0" encoding="UTF-8"?>\n{}'.format(xmlstr)
724892
function characterOccurance(stringToTest) {
    var chars = {},
        allowedOccurancy,
        valid = true;

    stringToTest = _.toString(stringToTest);
    allowedOccurancy = stringToTest.length / 2;

    // Loop through string and accumulate character counts
    _.each(stringToTest, function (char) {
        if (!chars[char]) {
            chars[char] = 1;
        } else {
            chars[char] += 1;
        }
    });

    // check if any of the accumulated chars exceed the allowed occurancy
    // of 50% of the words' length.
    _.forIn(chars, function (charCount) {
        if (charCount >= allowedOccurancy) {
            valid = false;
        }
    });

    return valid;
}
399689
public static int countChar(String s, char c) {

        int counter = 0;
        for (int i = 0; i < s.length(); i++) {
            if (s.charAt(i) == c) {
                counter++;
            }
        }
        return counter;
    }
846310
def _counter(self):
        """"""
        count = int(self._client.kv[self._counter_path])
        count += 1
        count_str = str(count).zfill(self._COUNTER_FILL)
        self._client.kv[self._counter_path] = count_str
        return count_str
1346417
public static int countChar(String string, CharPredicate predicate)
    {
        int count = 0;
        int size = string.length();
        for (int i = 0; i < size; i++)
        {
            if (predicate.accept(string.charAt(i)))
            {
                count++;
            }
        }
        return count;
    }
426449
def _fill_out_err(result, testcase):
        """"""
        if result.get("stdout"):
            system_out = etree.SubElement(testcase, "system-out")
            system_out.text = utils.get_unicode_str(result["stdout"])

        if result.get("stderr"):
            system_err = etree.SubElement(testcase, "system-err")
            system_err.text = utils.get_unicode_str(result["stderr"])
558674
private static int countSpaces(String str) {
    int counter = 0;
    for (char c : str.toCharArray()) {
      if (c == ' ') {
        counter++;
      }
    }
    return counter;
  }