Completed
Push — master ( 9d3bc0...b059cb )
by Oleksandr
01:07
created

HUD.from_ini()   A

Complexity

Conditions 1

Size

Total Lines 14

Duplication

Lines 14
Ratio 100 %

Code Coverage

Tests 1
CRAP Score 1.125

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 14
loc 14
ccs 1
cts 2
cp 0.5
rs 9.4285
cc 1
crap 1.125
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
8 1
from .interfaces import INISerializable, DefaultProvider
9 1
from .helpers import field_from_ini
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
@zope.interface.implementer(DefaultProvider)
14 1
class HUD(Model):
15 1
    no_mission_info = BooleanType(
16
        default=False,
17
        required=True,
18
    )
19 1
    no_kill_info = BooleanType(
20
        default=False,
21
        required=True,
22
    )
23 1
    display_at_bottom = BooleanType(
24
        default=False,
25
        required=True,
26
    )
27
28 1
    @classmethod
29
    def from_ini(cls, ini):
30
        return cls({
31
            'no_mission_info': field_from_ini(
32
                cls.no_mission_info, ini,
33
                'game', 'NoMissionInfoHud',
34
            ),
35
            'no_kill_info': field_from_ini(
36
                cls.no_kill_info, ini,
37
                'game', 'noKillInfoHud',
38
            ),
39
            'display_at_bottom': field_from_ini(
40
                cls.display_at_bottom, ini,
41
                'game', 'lowInfoHud',
42
            ),
43
        })
44
45 1
    @classmethod
46
    def default(cls):
47
        return cls({
48
            field_name: field.default
49
            for field_name, field in cls.fields.items()
50
        })
51