def _VarintDecoder(mask):
 local_ord = ord
 def DecodeVarint(buffer, pos):
  result = 0
  shift = 0
  while 1:
   b = local_ord(buffer[pos])
   result |= ((b & 127) << shift)
   pos += 1
   if (not (b & 128)):
    result &= mask
    return (result, pos)
   shift += 7
   if (shift >= 64):
    raise _DecodeError('Too many bytes when decoding varint.')
 return DecodeVarint

def _VarintDecoder ( mask ) : local_ord = ord def DecodeVarint ( buffer , pos ) : result = 0 shift = 0 while 1 : b = local_ord ( buffer [ pos ] ) result |= ( ( b & 127 ) << shift ) pos += 1 if ( not ( b & 128 ) ) : result &= mask return ( result , pos ) shift += 7 if ( shift >= 64 ) : raise _DecodeError ( 'Too many bytes when decoding varint.' ) return DecodeVarint
return an encoder for a basic varint value .