Read version from the first line starting with digit
504818
def read_version():
    
    regex = re.compile('^(?P<number>\d.*?) .*$')

    with open('../CHANGELOG.rst') as f:
        for line in f:
            match = regex.match(line)
            if match:
                return match.group('number')
1079762
private int findFirst(CharSequence input, int beginIndex, int rewindIndex) {
        int first = -1;
        int digit = -1;
        for (int i = beginIndex; i >= rewindIndex; i--) {
            char c = input.charAt(i);
            if (Scanners.isAlpha(c)) {
                first = i;
            } else if (Scanners.isDigit(c)) {
                digit = i;
            } else if (!schemeSpecial(c)) {
                break;
            }
        }
        if (first > 0 && first - 1 == digit) {
            // We don't want to extract "abc://foo" out of "1abc://foo".
            // ".abc://foo" and others are ok though, as they feel more like separators.
            first = -1;
        }
        return first;
    }
428050
def read_token(fd):
    
    out = ''
    # Skip initial whitespace.

    while 1:
        ch = fd.read(1)
        if ch.isspace(): continue
        elif len(ch) == 0: return out
        else: break

    while not ch.isspace():
        out = out + ch
        ch = fd.read(1)
        if len(ch) == 0: break

    return out
1292638
def readline(options = {})
      suppress_warnings
      initialize_parms(options)
      MiniTerm.raw { @edit.edit_process }
    ensure
      restore_warnings
      puts
    end
1392
def _readoct(self, length, start):
        """"""
        if length % 3:
            raise InterpretError("Cannot convert to octal unambiguously - "
                                 "not multiple of 3 bits.")
        if not length:
            return ''
        # Get main octal bit by converting from int.
        # Strip starting 0 or 0o depending on Python version.
        end = oct(self._readuint(length, start))[LEADING_OCT_CHARS:]
        if end.endswith('L'):
            end = end[:-1]
        middle = '0' * (length // 3 - len(end))
        return middle + end
1365602
private Token scanNumber(int c) throws IOException {
        int startLine = mSource.getLineNumber();
        int startPos = mSource.getStartPosition();
        mWord.setLength(0);
        
        int errorPos = -1;

        // 0 is decimal int, 
        // 1 is hex int, 
        // 2 is decimal long, 
        // 3 is hex long, 
        // 4 is float, 
        // 5 is double,
        // 6 is auto-double by decimal
        // 7 is auto-double by exponent ('e' or 'E')
        int type = 0; 

        if (c == '0') {
            if (mSource.peek() == 'x' || mSource.peek() == 'X') {
                type = 1;
                mSource.read(); // absorb the 'x'
                c = mSource.read(); // get the first digit after the 'x'
            }
        }

        for (; c != -1; c = mSource.read()) {
            if (c == '.') {
                int peek = mSource.peek();
                if (peek == '.') {
                    mSource.unread();
                    break;
                }
                else {
                    if (peek < '0' || peek > '9') {
                        error("number.decimal.end");
                    }

                    mWord.append((char)c);

                    if (type == 0) {
                        type = 6;
                    }
                    else if (errorPos < 0) {
                        errorPos = mSource.getStartPosition();
                    }

                    continue;
                }
            }

            if (c >= '0' && c <= '9') {
                mWord.append((char)c);

                if (type == 2 || type == 3 || type == 4 || type == 5) {
                    if (errorPos < 0) {
                        errorPos = mSource.getStartPosition();
                    }
                }

                continue;
            }

            if ((c >= 'a' && c <= 'f') || (c >= 'A' && c <= 'F')) {
                if (type == 1) {
                    mWord.append((char)c);
                    continue;
                }

                if (c == 'f' || c == 'F') {
                    if (type == 0 || type == 6 || type == 7) {
                        type = 4;
                        continue;
                    }
                }
                else if (c == 'd' || c == 'D') {
                    if (type == 0 || type == 6 || type == 7) {
                        type = 5;
                        continue;
                    }
                }
                else if (c == 'e' || c == 'E') {
                    if (type == 0 || type == 6) {
                        mWord.append((char)c);
                        type = 7;
                        int peek = mSource.peek();
                        if (peek == '+' || peek == '-') {
                            mWord.append((char)mSource.read());
                        }
                        continue;
                    }
                }

                mWord.append((char)c);

                if (errorPos < 0) {
                    errorPos = mSource.getStartPosition();
                }

                continue;
            }

            if (c == 'l' || c == 'L') {
                if (type == 0) {
                    type = 2;
                }
                else if (type == 1) {
                    type = 3;
                }
                else {
                    mWord.append((char)c);
                    if (errorPos < 0) {
                        errorPos = mSource.getStartPosition();
                    }
                }

                continue;
            }

            if (Character.isLetterOrDigit((char)c)) {
                mWord.append((char)c);

                if (errorPos < 0) {
                    errorPos = mSource.getStartPosition();
                }
            }
            else {
                mSource.unread();
                break;
            }
        }
        
        String str = mWord.toString();
        int endPos = mSource.getEndPosition();
        Token token;

        if (errorPos >= 0) {
            token = new StringToken
                (startLine, startPos, endPos, errorPos, Token.NUMBER, str);
        }
        else {
            try {
                switch (type) {
                case 0:
                default:
                    try {
                        token = new IntToken
                            (startLine, startPos, endPos,
                             Integer.parseInt(str));
                    }
                    catch (NumberFormatException e) {
                        token = new LongToken
                            (startLine, startPos, endPos, Long.parseLong(str));
                    }
                    break;
                case 1:
                    try {
                        token = new IntToken
                            (startLine, startPos, endPos, parseHexInt(str));
                    }
                    catch (NumberFormatException e) {
                        token = new LongToken
                            (startLine, startPos, endPos, parseHexLong(str));
                    }
                    break;
                case 2:
                    token = new LongToken
                        (startLine, startPos, endPos, Long.parseLong(str));
                    break;
                case 3:
                    token = new LongToken
                        (startLine, startPos, endPos, parseHexLong(str));
                    break;
                case 4:
                    token = new FloatToken
                        (startLine, startPos, endPos, Float.parseFloat(str));
                    break;
                case 5:
                case 6:
                case 7:
                    token = new DoubleToken
                        (startLine, startPos, endPos, Double.parseDouble(str));
                    break;
                }
            }
            catch (NumberFormatException e) {
                token = new IntToken(startLine, startPos, endPos, 0);
                error("number.range", token.getSourceInfo());
            }
        }

        return token;
    }
1260861
def _split_version_specifier(spec):
    """"""
    m = re.search(r'([<>=]?=?)?\s*([0-9.a-zA-Z]+)', spec)
    return m.group(2), m.group(1)
570878
private int skipDigits() {
        char ch;
        int i = 0;

        while (index < format.length()) {
            if (Character.isDigit(ch = format.charAt(index))) {
                index++;
                i = i * 10 + Character.digit(ch, 10);
            } else {
                break;
            }
        }
        return i;
    }
934924
private static String parseVersionNumber(String line) {
        StringTokenizer tokenizer = new StringTokenizer(line, " \t");

        if (!expect(tokenizer, "sourceInfo") || !expect(tokenizer, "version") || !tokenizer.hasMoreTokens()) {
            return null;
        }

        return tokenizer.nextToken();
    }
27046
def get_line_number (s, index):
    """
    i = 0
    if index < 0:
        return 0
    line = 1
    while i < index:
        if s[i] == '\n':
            line += 1
        i += 1
    return line
996493
def _get_version():
    """"""
    with open("../waliki/__init__.py") as fh:
        for line in fh:
            if line.startswith("__version__ = "):
                return line.split("=")[-1].strip().strip("'").strip('"')
78957
def get_version_string(check_name):
    
    version = VERSION.search(read_version_file(check_name))
    if version:
        return version.group(1)
489145
def _revint(self, version):
        '''
        
        '''
        intrev = 0
        vsplit = version.split('.')
        for c in range(len(vsplit)):
            item = int(vsplit[c]) * (10 ** (((len(vsplit) - c - 1) * 2)))
            intrev += item
        return intrev
291963
def intversion(text=None):
    
    try:
        s = text

        if not s:
            s = version()

        s = s.split('ubuntu')[0]
        s = s.split(':')[-1]
        s = s.split('+')[0]

        # <100
        if s.startswith('00'):
            i = int(s[0:4])
        # >=100
        elif '.' in s:
            ls = s.split('.')
            ls += [0, 0, 0]
            i = int(ls[0]) * 100 + int(ls[1]) * 10 + int(ls[2])
    except ValueError:
        print ('Can not parse version: %s' % text)
        raise
    return i
23302
def parse_number(self, s):
        """"""
        start = 1 if s[0] in ["-","+"] else 0

        all_digits = lambda x: all(map(lambda c: c.isdigit(), x))
        ishex = lambda c: c.isdigit() or ord(c.lower()) in range(ord("a"), ord("f"))
        all_hex = lambda x: all(map(ishex, x))

        if all_digits(s[start:]):
            try:
                return (Tokenizer.INTEGER, int(s))
            except ValueError:
                raise ParseError("%d:%d: Invalid integer '%s'" % (self.lineno,
                    self.column, s))

        if s[start:].startswith("0x") and all_hex(s[start+2:]):
            try:
                return (Tokenizer.INTEGER, int(s, base=16))
            except ValueError:
                raise ParseError("%d:%d: Invalid hexadecimal integer '%s'" %
                        (self.lineno, self.column, s))

        if any(map(lambda c: c==".", s)) or any(map(lambda c: c=="e", s)):
            try:
                return (Tokenizer.FLOAT, float(s))
            except ValueError:
                raise ParseError("%d:%d: Invalid float '%s'" % (self.lineno,
                    self.column, s))

        raise ParseError("%d:%d: Invalid number '%s'" % (self.lineno,
            self.column, s))
965811
def split_version(version):
    
    if re.match("^[^0-9].*", version):
        return [version]
    return [int(i) for i in version.split(".")]
74711
def read_release_version():
    """"""
    import re
    dirname = os.path.abspath(os.path.dirname(__file__))

    try:
        f = open(os.path.join(dirname, "_version.py"), "rt")
        for line in f.readlines():

            m = re.match("__version__ = '([^']+)'", line)
            if m:
                ver = m.group(1)
                return ver

    except:
        return None

    return None