class RandIP(RandString): def __init__(self, iptemplate="0.0.0.0/0"): RandString.__init__(self) self.ip = Net(iptemplate) def _fix(self): return self.ip.choice()
class RandIP(RandString): _DEFAULT_IPTEMPLATE = "0.0.0.0/0" def __init__(self, iptemplate=_DEFAULT_IPTEMPLATE): RandString.__init__(self) self.ip = Net(iptemplate) def _command_args(self): if self.ip.repr == self._DEFAULT_IPTEMPLATE: return "" return "iptemplate=%r" % self.ip.repr def _fix(self): return self.ip.choice()
class RandIP(_RandString[str]): _DEFAULT_IPTEMPLATE = "0.0.0.0/0" def __init__(self, iptemplate=_DEFAULT_IPTEMPLATE): # type: (str) -> None super(RandIP, self).__init__() self.ip = Net(iptemplate) def _command_args(self): # type: () -> str rep = "%s/%s" % (self.ip.net, self.ip.mask) if rep == self._DEFAULT_IPTEMPLATE: return "" return "iptemplate=%r" % rep def _fix(self): # type: () -> str return self.ip.choice()
class RandIP(RandString): def __init__(self, iptemplate="0.0.0.0/0"): self.ip = Net(iptemplate) def _fix(self): return self.ip.choice()