def _str_get_serial(text):
    # We already know it's in valid format.
    isSOA = False
    done = False
    for raw_line in text.readlines():
        if done:
            break

        line = raw_line.strip()
        ll = LexLine(line)
        if isSOA:
            # If we made it here, this should be the serial.
            serial = _lex_word(ll)
            if serial.isdigit():
                return serial
            else:
                return None

        if not line or line[0] == '$' or line[0] == ';':
            continue

        # name        ttl class rr    name-server email-addr  (sn ref ret ex min)
        # 1           2   3     4     5           6            7  8   9   10 11
        # Everything up through 6 needs to be on the same line.
        _lex_word(ll)  # name
        _lex_ws(ll)

        c = ll.pop()
        if c.isdigit():
            _lex_word(ll)  # ttl
            _lex_ws(ll)
        else:
            ll.unpop()

        _lex_word(ll)  # class
        _lex_ws(ll)

        rr = _lex_word(ll)
        if rr.upper() != 'SOA':
            continue # It's not an soa, keep going.

        isSOA = True
        _lex_ws(ll)

        _lex_word(ll)  # ns
        _lex_ws(ll)

        email = _lex_word(ll)  # email
        if email[-1:] == '(':
            _lex_ws(ll)
        else:
            _lex_ws(ll)
            next = ll.peek()
            if next == '(':
                ll.pop()

        # We are into the numbers.
        _lex_ws(ll)
        serial = _lex_word(ll)
        if not serial:
            # The serial must be on the next line
            continue

        if serial.isdigit():
            return serial
        else:
            return None
Simulates the DQN policy
dataset/ETHPy150Open mozilla/inventory/migrate_dns/utils.py/_str_get_serial--crossover with--dataset/ETHPy150Open sisl/Chimp/chimp/agents/dqn_agent.py/DQNAgent.simulate