mine.models.timestamp.Timestamp.__ne__()   A
last analyzed

Complexity

Conditions 1

Size

Total Lines 2
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 1
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 2
nop 2
dl 0
loc 2
ccs 1
cts 1
cp 1
crap 1
rs 10
c 0
b 0
f 0
1
"""Data structures for timestamp information."""
2
3 1
import yorm
4
5 1
6
@yorm.attr(started=yorm.types.Integer)
7
@yorm.attr(stopped=yorm.types.Integer)
8 1
class Timestamp(yorm.types.AttributeDictionary):
9
    """Dictionary of last start and stop times."""
10
11 1
    def __init__(self, started=0, stopped=0):
12 1
        super().__init__()
13 1
        self.started = started
14
        self.stopped = stopped
15
16 1
    def __repr__(self):
17 1
        return "<timestamp {}>".format(self.latest)
18 1
19 1
    def __eq__(self, other):
20
        return self.latest == other.latest
21 1
22 1
    def __ne__(self, other):
23
        return not self.__eq__(other)
24 1
25 1
    def __lt__(self, other):
26
        return self.latest < other.latest
27 1
28 1
    @property
29
    def latest(self):
30 1
        """Get the latest timestamp."""
31 1
        return max((self.started, self.stopped))
32
33 1
    @property
34
    def active(self):
35
        """Determine if the timestamps indicate current activity."""
36 1
        if not self.started:
37
            return False
38 1
39
        if not self.stopped:
40
            return True
41 1
42
        return self.started > self.stopped
43