(convmap, start_idx, skip)
return start_i, start_o, count
Scan for a range of continuous case conversion with a certain 'skip'.
Scan for a range of continuous case conversion with a certain 'skip'.
Scan for a range of continuous case conversion with a certain skip .
def scan_range_with_skip(convmap, start_idx, skip):
    """Scan for a range of continuous case conversion with a certain 'skip'."""

    conv_i = start_idx
    if not convmap.has_key(conv_i):
        return None, None, None
    elif len(convmap[conv_i]) > 1:
        return None, None, None
    else:
        conv_o = ord(convmap[conv_i])

    start_i = conv_i
    start_o = conv_o

    while True:
        new_i = conv_i + skip
        new_o = conv_o + skip

        if not convmap.has_key(new_i):
            break
        if len(convmap[new_i]) > 1:
            break
        if ord(convmap[new_i]) != new_o:
            break

        conv_i = new_i
        conv_o = new_o

    # [start_i,conv_i] maps to [start_o,conv_o], ignore ranges of 1 char.
    count = (conv_i - start_i) / skip + 1
    if count <= 1:
        return None, None, None

    # We have an acceptable range, remove them from the convmap here.
    for i in xrange(start_i, conv_i + skip, skip):
        del convmap[i]

    return start_i, start_o, count
def scan_range_with_skip ( convmap , start_idx , skip ) : conv_i = start_idx if not convmap . has_key ( conv_i ) : return None , None , None elif len ( convmap [ conv_i ] ) > 1 : return None , None , None else : conv_o = ord ( convmap [ conv_i ] ) start_i = conv_i start_o = conv_o while True : new_i = conv_i + skip new_o = conv_o + skip if not convmap . has_key ( new_i ) : break if len ( convmap [ new_i ] ) > 1 : break if ord ( convmap [ new_i ] ) != new_o : break conv_i = new_i conv_o = new_o # [start_i,conv_i] maps to [start_o,conv_o], ignore ranges of 1 char. count = ( conv_i - start_i ) / skip + 1 if count <= 1 : return None , None , None # We have an acceptable range, remove them from the convmap here. for i in xrange ( start_i , conv_i + skip , skip ) : del convmap [ i ] return start_i , start_o , count