looptools.counter.Counter.__init__()   A
last analyzed

Complexity

Conditions 1

Size

Total Lines 8
Code Lines 3

Duplication

Lines 8
Ratio 100 %

Importance

Changes 0
Metric Value
eloc 3
dl 8
loc 8
rs 10
c 0
b 0
f 0
cc 1
nop 2
1 View Code Duplication
class Counter:
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.
Loading history...
2
    def __init__(self, length=0):
3
        """
4
        Counts number of iterations in a process.
5
        :param length: Minimum string length of a returned count. Example - with a length of 3 the first count would
6
        return '001'.
7
        """
8
        self.counter = 0
9
        self.length = length
10
11
    def __repr__(self):
12
        print(str(self.counter))
13
14
    def leading_zeros(self):
15
        if self.length == 3:
16
            if self.counter < 10:
17
                count = "00" + str(self.counter)
18
            elif 9 < self.counter < 100:
19
                count = "0" + str(self.counter)
20
            else:
21
                count = self.counter
22
        elif self.length == 2:
23
            if self.counter < 10:
24
                count = "0" + str(self.counter)
25
            else:
26
                count = self.counter
27
        else:
28
            count = self.counter
29
        return count
30
31
    @property
32
    def up(self):
33
        self.counter += 1
34
        count = self.leading_zeros()
35
        return str(count)
36
37
    @property
38
    def total(self):
39
        count = self.leading_zeros()
40
        return str(count)
41