GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Completed
Push — master ( 650a9f...3802bb )
by Benjamin
01:03
created

Message.__init__()   A

Complexity

Conditions 1

Size

Total Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 3
rs 10
cc 1
1
from libAnt.constants import MESSAGE_TX_SYNC
2
3
4
class Message:
5
    def __init__(self, type: int, content: bytearray):
6
        self._type = type
7
        self._content = content
8
9
    def __len__(self):
10
        return len(self._content)
11
12
    def __iter__(self):
13
        return self._content
14
15
    def __str__(self):
16
        return '({:02X}): '.format(self._type) + ' '.join('{:02X}'.format(x) for x in self._content)
17
18
    def checksum(self) -> int:
19
        chk = MESSAGE_TX_SYNC ^ len(self) ^ self._type
20
        for b in self._content:
21
            chk ^= b
22
        return chk
23
24
    def encode(self) -> bytearray:
25
        b = bytearray()
26
        b.append(MESSAGE_TX_SYNC)
27
        b.append(len(self))
28
        b.append(self._type)
29
        b.extend(self._content)
30
        b.append(self.checksum())
31
        return b
32
33
    @property
34
    def type(self) -> int:
35
        return self._type
36
37
    @property
38
    def content(self) -> bytearray:
39
        return self._content
40