| 610 | |
| 611 | |
| 612 | class RandMAC(_RandString[str]): |
| 613 | def __init__(self, _template="*"): |
| 614 | # type: (str) -> None |
| 615 | super(RandMAC, self).__init__() |
| 616 | self._template = _template |
| 617 | _template += ":*:*:*:*:*" |
| 618 | template = _template.split(":") |
| 619 | self.mac = () # type: Tuple[Union[int, RandNum], ...] |
| 620 | for i in range(6): |
| 621 | v = 0 # type: Union[int, RandNum] |
| 622 | if template[i] == "*": |
| 623 | v = RandByte() |
| 624 | elif "-" in template[i]: |
| 625 | x, y = template[i].split("-") |
| 626 | v = RandNum(int(x, 16), int(y, 16)) |
| 627 | else: |
| 628 | v = int(template[i], 16) |
| 629 | self.mac += (v,) |
| 630 | |
| 631 | def _command_args(self): |
| 632 | # type: () -> str |
| 633 | if self._template == "*": |
| 634 | return "" |
| 635 | return "template=%r" % self._template |
| 636 | |
| 637 | def _fix(self): |
| 638 | # type: () -> str |
| 639 | return "%02x:%02x:%02x:%02x:%02x:%02x" % self.mac # type: ignore |
| 640 | |
| 641 | |
| 642 | class RandIP6(_RandString[str]): |
no outgoing calls
no test coverage detected