Crc64Result   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 34
Duplicated Lines 0 %

Importance

Changes 5
Bugs 0 Features 0
Metric Value
c 5
b 0
f 0
dl 0
loc 34
rs 10
wmc 6

6 Methods

Rating   Name   Duplication   Size   Complexity  
A __ne__() 0 2 1
A high_bytes() 0 6 1
A low_bytes() 0 6 1
A __eq__() 0 2 1
A __init__() 0 2 1
A __str__() 0 2 1
1
"""Implements the Crc64Result class.
2
"""
3
4
5
from __future__ import unicode_literals
6
7
8
class Crc64Result(object):
9
    """Implements a class that represents the result of a 64-bit Cyclic Redundancy Check checksum.
10
    """
11
12
    def __init__(self, crc64):
13
        self._crc64 = crc64
14
15
16
    @property
17
    def high_bytes(self):
18
        """Returns the topmost 4 bytes of the checksum formatted as a lowercase hex string.
19
        """
20
21
        return format(self._crc64 >> 32, "08x")
22
23
24
    @property
25
    def low_bytes(self):
26
        """Returns the bottommost 4 bytes of the checksum formatted as a lowercase hex string.
27
        """
28
29
        return format(self._crc64 & 0xffffffff, "08x")
30
31
32
    def __eq__(self, other):
33
        return self._crc64 == other._crc64 # pylint: disable=locally-disabled, protected-access
34
35
36
    def __ne__(self, other):
37
        return not self.__eq__(other)
38
39
40
    def __str__(self):
41
        return format(self._crc64, "016x")
42