def iter_subnets(self, prefixlen_diff=1, new_prefix=None):
        if self._prefixlen == self._max_prefixlen:
            yield self
            return

        if new_prefix is not None:
            if new_prefix < self._prefixlen:
                raise ValueError('new prefix must be longer')
            if prefixlen_diff != 1:
                raise ValueError('cannot set prefixlen_diff and new_prefix')
            prefixlen_diff = new_prefix - self._prefixlen

        if prefixlen_diff < 0:
            raise ValueError('prefix length diff must be > 0')
        new_prefixlen = self._prefixlen + prefixlen_diff

        if not self._is_valid_netmask(str(new_prefixlen)):
            raise ValueError(
                'prefix length diff %d is invalid for netblock %s' % (
                    new_prefixlen, str(self)))

        first = ip_network('%s/%s' % (str(self.network_address),
                                     str(self._prefixlen + prefixlen_diff)),
                         version=self._version)

        yield first
        current = first
        while True:
            broadcast = current.broadcast_address
            if broadcast == self.broadcast_address:
                return
            new_addr = ip_address(int(broadcast) + 1, version=self._version)
            current = ip_network('%s/%s' % (str(new_addr), str(new_prefixlen)),
                                version=self._version)

            yield current
Copy report to web
dataset/ETHPy150Open uwdata/termite-data-server/web2py/gluon/contrib/ipaddr.py/_BaseInterface.iter_subnets--crossover with--dataset/ETHPy150Open CGATOxford/cgat/obsolete/pipeline_species_conservation.py/publish_report