(self,
pkt, # type: Optional[Packet]
x # type: Any # noqa: E501
)
| 3869 | raise FieldAttributeException("Unknown fmt") |
| 3870 | |
| 3871 | def any2i(self, |
| 3872 | pkt, # type: Optional[Packet] |
| 3873 | x # type: Any # noqa: E501 |
| 3874 | ): |
| 3875 | # type: (...) -> Optional[UUID] |
| 3876 | # Python's uuid doesn't handle bytearray, so convert to an immutable |
| 3877 | # type first. |
| 3878 | if isinstance(x, bytearray): |
| 3879 | x = bytes_encode(x) |
| 3880 | |
| 3881 | if isinstance(x, int): |
| 3882 | u = UUID(int=x) |
| 3883 | elif isinstance(x, tuple): |
| 3884 | if len(x) == 11: |
| 3885 | # For compatibility with dce_rpc: this packs into a tuple where |
| 3886 | # elements 7..10 are the 48-bit node ID. |
| 3887 | node = 0 |
| 3888 | for i in x[5:]: |
| 3889 | node = (node << 8) | i |
| 3890 | |
| 3891 | x = (x[0], x[1], x[2], x[3], x[4], node) |
| 3892 | |
| 3893 | u = UUID(fields=x) |
| 3894 | elif isinstance(x, (str, bytes)): |
| 3895 | if len(x) == 16: |
| 3896 | # Raw bytes |
| 3897 | u = self.m2i(pkt, bytes_encode(x)) |
| 3898 | else: |
| 3899 | u = UUID(plain_str(x)) |
| 3900 | elif isinstance(x, (UUID, RandUUID)): |
| 3901 | u = cast(UUID, x) |
| 3902 | else: |
| 3903 | return None |
| 3904 | return u |
| 3905 | |
| 3906 | @staticmethod |
| 3907 | def randval(): |
nothing calls this directly
no test coverage detected