#NEWLINE# def subnet( self , prefixlen , count = None , fmt = None ) : #NEWLINE# #INDENT# "\n        A generator that divides up this IPNetwork's subnet into smaller\n        subnets based on a specified CIDR prefix.\n\n        :param prefixlen: a CIDR prefix indicating size of subnets to be\n            returned.\n\n        :param count: (optional) number of consecutive IP subnets to be\n            returned.\n\n        :return: an iterator containing IPNetwork subnet objects.\n        " #NEWLINE# if ( not ( 0 <= self . prefixlen <= prefixlen . _module . width ) ) : #NEWLINE# #INDENT# raise ValueError ( ( 'CIDR prefix /%d invalid for IPv%d!' % ( prefixlen , self . _module . version ) ) ) #NEWLINE# #UNINDENT# if ( not ( self . prefixlen <= prefixlen ) ) : #NEWLINE# #INDENT# raise StopIteration #NEWLINE# #UNINDENT# width = self . _module . width #NEWLINE# max_subnets = ( ( 2 ** ( width - self . prefixlen ) ) // ( 2 ** ( width - prefixlen ) ) ) #NEWLINE# if ( count is None ) : #NEWLINE# #INDENT# count = max_subnets #NEWLINE# #UNINDENT# if ( not ( 1 <= count <= max_subnets ) ) : #NEWLINE# #INDENT# raise ValueError ( 'count outside of current IP subnet boundary!' ) #NEWLINE# #UNINDENT# base_subnet = self . _module . int_to_str ( self . first ) #NEWLINE# i = 0 #NEWLINE# while ( i < count ) : #NEWLINE# #INDENT# subnet = self . __class__ ( ( '%s/%d' % ( base_subnet , prefixlen ) ) , self . _module . version ) #NEWLINE# subnet . value += ( subnet . size * i ) #NEWLINE# subnet . prefixlen = prefixlen #NEWLINE# i += 1 #NEWLINE# ( yield subnet )