def range2nets(rng):
 (start, stop) = rng
 if (type(start) is str):
  start = ip2int(start)
 if (type(stop) is str):
  stop = ip2int(stop)
 if (stop < start):
  raise ValueError()
 res = []
 cur = start
 maskint = 32
 mask = int2mask(maskint)
 while True:
  while (((cur & mask) == cur) and ((cur | ((~ mask) & 4294967295)) <= stop)):
   maskint -= 1
   mask = int2mask(maskint)
  res.append(('%s/%d' % (int2ip(cur), (maskint + 1))))
  mask = int2mask((maskint + 1))
  if ((stop & mask) == cur):
   return res
  cur = ((cur | ((~ mask) & 4294967295)) + 1)
  maskint = 32
  mask = int2mask(maskint)

def range2nets ( rng ) : ( start , stop ) = rng if ( type ( start ) is str ) : start = ip2int ( start ) if ( type ( stop ) is str ) : stop = ip2int ( stop ) if ( stop < start ) : raise ValueError ( ) res = [ ] cur = start maskint = 32 mask = int2mask ( maskint ) while True : while ( ( ( cur & mask ) == cur ) and ( ( cur | ( ( ~ mask ) & 4294967295 ) ) <= stop ) ) : maskint -= 1 mask = int2mask ( maskint ) res . append ( ( '%s/%d' % ( int2ip ( cur ) , ( maskint + 1 ) ) ) ) mask = int2mask ( ( maskint + 1 ) ) if ( ( stop & mask ) == cur ) : return res cur = ( ( cur | ( ( ~ mask ) & 4294967295 ) ) + 1 ) maskint = 32 mask = int2mask ( maskint )
converts a tuple to a list of networks .