Completed
Push — master ( 675894...94f961 )
by Michael
18:15
created

AbstractResponseData.convert()   A

Complexity

Conditions 5

Size

Total Lines 10
Code Lines 10

Duplication

Lines 10
Ratio 100 %

Importance

Changes 0
Metric Value
eloc 10
dl 10
loc 10
rs 9.3333
c 0
b 0
f 0
cc 5
nop 2
1
import abc
2
import six
3
4
5 View Code Duplication
class AbstractResponseData(six.with_metaclass(abc.ABCMeta, object)):
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.
Loading history...
Unused Code introduced by
The variable __class__ seems to be unused.
Loading history...
6
    @abc.abstractmethod
7
    def __init__(self):
8
        self.time = None
9
        self.level = None
10
        self.locationName = None
11
        self.attributes = None
12
13
    def getTime(self):
14
        return self.time
15
16
    def setTime(self, time):
17
        self.time = time
18
19
    def getLevel(self):
20
        return self.level
21
22
    def setLevel(self, level):
23
        self.level = level
24
25
    def getLocationName(self):
26
        if six.PY2:
27
            return self.locationName
28
        if self.locationName is not None:
29
            return self.locationName.decode('utf-8')
30
        return self.locationName
31
32
    def setLocationName(self, locationName):
33
        self.locationName = locationName
34
35
    def getAttributes(self):
36
        if six.PY2:
0 ignored issues
show
unused-code introduced by
Unnecessary "else" after "return"
Loading history...
37
            return self.attributes
38
        else:
39
            return self.convert(self.attributes)
40
41
    def setAttributes(self, attributes):
42
        self.attributes = attributes
43
44
    def convert(self, data):
45
        if isinstance(data, dict):
46
            return dict(map(self.convert, data.items()))
47
        if isinstance(data, bytes):
48
            return data.decode('utf-8')
49
        if isinstance(data, tuple):
50
            return tuple(map(self.convert, data))
51
        if isinstance(data, list):
52
            return list(map(self.convert, data))
53
        return data
54