Completed
Push — master ( b95acc...a5fbcd )
by Oleksandr
01:06
created

Belligerents   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 21
Duplicated Lines 0 %

Test Coverage

Coverage 83.33%

Importance

Changes 2
Bugs 0 Features 0
Metric Value
wmc 1
c 2
b 0
f 0
dl 0
loc 21
ccs 5
cts 6
cp 0.8333
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A from_ini() 0 10 1
1
# coding: utf-8
2
3 1
import zope.interface
4
5 1
from schematics.models import Model
6 1
from schematics.types import BooleanType
7 1
from schematics.types.compound import ModelType
8
9 1
from .interfaces import INISerializable
10
11
12 1 View Code Duplication
@zope.interface.implementer(INISerializable)
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.
Loading history...
13 1
class Users(Model):
14 1
    show_number = BooleanType(
15
        default=True,
16
        required=True,
17
    )
18 1
    show_ping = BooleanType(
19
        default=True,
20
        required=True,
21
    )
22 1
    show_name = BooleanType(
23
        default=True,
24
        required=True,
25
    )
26 1
    show_belligerent = BooleanType(
27
        default=True,
28
        required=True,
29
    )
30 1
    show_aircraft_designation = BooleanType(
31
        default=True,
32
        required=True,
33
    )
34 1
    show_aircraft_type = BooleanType(
35
        default=True,
36
        required=True,
37
    )
38 1
    show_score = BooleanType(
39
        default=True,
40
        required=True,
41
    )
42
43 1
    @classmethod
44
    def from_ini(cls, ini):
45
        return cls({
46
            'show_number': ini.getboolean(
47
                'NET', 'showPilotNumber',
48
                fallback=cls.show_number.default,
49
            ),
50
            'show_ping': ini.getboolean(
51
                'NET', 'showPilotPing',
52
                fallback=cls.show_ping.default,
53
            ),
54
            'show_name': ini.getboolean(
55
                'NET', 'showPilotName',
56
                fallback=cls.show_name.default,
57
            ),
58
            'show_belligerent': ini.getboolean(
59
                'NET', 'showPilotArmy',
60
                fallback=cls.show_belligerent.default,
61
            ),
62
            'show_aircraft_designation': ini.getboolean(
63
                'NET', 'showPilotACDesignation',
64
                fallback=cls.show_aircraft_designation.default,
65
            ),
66
            'show_aircraft_type': ini.getboolean(
67
                'NET', 'showPilotACType',
68
                fallback=cls.show_aircraft_type.default,
69
            ),
70
            'show_score': ini.getboolean(
71
                'NET', 'showPilotScore',
72
                fallback=cls.show_score.default,
73
            ),
74
        })
75
76
77 1
@zope.interface.implementer(INISerializable)
78 1
class Belligerents(Model):
79 1
    show_score = BooleanType(
80
        default=False,
81
        required=True,
82
    )
83 1
    accumulate_score = BooleanType(
84
        default=False,
85
        required=True,
86
    )
87
88 1
    @classmethod
89
    def from_ini(cls, ini):
90
        return cls({
91
            'show_score': ini.getboolean(
92
                'NET', 'showTeamScore',
93
                fallback=cls.show_score.default,
94
            ),
95
            'accumulate_score': ini.getboolean(
96
                'NET', 'cumulativeTeamScore',
97
                fallback=cls.accumulate_score.default,
98
            ),
99
        })
100
101
102 1
@zope.interface.implementer(INISerializable)
103 1
class Statistics(Model):
104 1
    is_disabled = BooleanType(
105
        default=False,
106
        required=True,
107
    )
108 1
    users = ModelType(
109
        model_spec=Users,
110
        required=True,
111
    )
112 1
    belligerents = ModelType(
113
        model_spec=Belligerents,
114
        required=True,
115
    )
116
117 1
    @classmethod
118
    def from_ini(cls, ini):
119
        return cls({
120
            'is_disabled': ini.getboolean(
121
                'NET', 'disableNetStatStatistics',
122
                fallback=cls.is_disabled.default,
123
            ),
124
            'users': Users.from_ini(ini),
125
            'belligerents': Belligerents.from_ini(ini),
126
        })
127