mine.models.timestamp   A
last analyzed

Complexity

Total Complexity 9

Size/Duplication

Total Lines 43
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
eloc 27
dl 0
loc 43
ccs 23
cts 23
cp 1
rs 10
c 0
b 0
f 0
wmc 9

7 Methods

Rating   Name   Duplication   Size   Complexity  
A Timestamp.__init__() 0 4 1
A Timestamp.__eq__() 0 2 1
A Timestamp.__ne__() 0 2 1
A Timestamp.__repr__() 0 2 1
A Timestamp.__lt__() 0 2 1
A Timestamp.latest() 0 4 1
A Timestamp.active() 0 10 3
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