Lines Matching full:x
58 return ''.join('%02x' % b for b in self)
64 return ':'.join('%02x' % b for b in self)
71 return ':'.join('%04x' % (self[i] * 256 + self[i + 1]) for i in range(0, len(self), 2))
90 return bytearray(int(x, 16) for x in s.split(':'))
101 return bytearray(int(x[i:i + 2], 16) for x in s.split(':') for i in (0, 2))
112 x = super().__getitem__(item)
113 if isinstance(x, bytearray):
114 return Bytes(x)
116 return x
134 x = Bytes(b"\x01\x02\x03\x04") variable
135 … assert eval(repr(x)) == x, repr(x) # representation of Bytes should be able to be evaluated back
136 assert x == str(x), (x, str(x))
138 assert x.format_compact() == "01020304", x.format_compact()
139 assert x.format_octets() == "01:02:03:04", x.format_octets()
140 assert x.format_hextets() == "0102:0304", x.format_hextets()
143 assert Bytes._parse_compact('01020304') == x
146 assert Bytes._parse_octets('01:02:03:04') == x
149 assert Bytes._parse_hextets('0102:0304') == x
151 assert isinstance(x[:2], Bytes)
152 assert isinstance(x[-2:], Bytes)
153 assert x[:2] == Bytes(b'\x01\x02')
154 assert x[-2:] == Bytes(b'\x03\x04')