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

ServerConfig.from_ini()   A

Complexity

Conditions 2

Size

Total Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 1
CRAP Score 2.5

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 5
ccs 1
cts 2
cp 0.5
rs 9.4285
cc 2
crap 2.5
1
# coding: utf-8
2
3 1
import zope.interface
4
5 1
from schematics.models import Model
6 1
from schematics.types.compound import ModelType
7
8 1
from .interfaces import INISerializable
9 1
from .about import About
10 1
from .anticheat import Anticheat
11 1
from .connection import Connection
12 1
from .console import Console
13 1
from .device_link import DeviceLink
14 1
from .events import Events
15 1
from .hud import HUD
16 1
from .morse import Morse
17 1
from .other import Other
18 1
from .refly import Refly
19 1
from .statistics import Statistics
20
21
22 1
@zope.interface.implementer(INISerializable)
23 1
class ServerConfig(Model):
24 1
    about = ModelType(
25
        model_spec=About,
26
        required=True,
27
    )
28 1
    anticheat = ModelType(
29
        model_spec=Anticheat,
30
        required=True,
31
    )
32 1
    connection = ModelType(
33
        model_spec=Connection,
34
        required=True,
35
    )
36 1
    console = ModelType(
37
        model_spec=Console,
38
        required=True,
39
    )
40 1
    device_link = ModelType(
41
        model_spec=DeviceLink,
42
        required=True,
43
    )
44 1
    events = ModelType(
45
        model_spec=Events,
46
        required=True,
47
    )
48 1
    hud = ModelType(
49
        model_spec=HUD,
50
        required=True,
51
    )
52 1
    morse = ModelType(
53
        model_spec=Morse,
54
        required=True,
55
    )
56 1
    refly = ModelType(
57
        model_spec=Refly,
58
        required=True,
59
    )
60 1
    statistics = ModelType(
61
        model_spec=Statistics,
62
        required=True,
63
    )
64 1
    other = ModelType(
65
        model_spec=Other,
66
        required=True,
67
    )
68
69 1
    @classmethod
70
    def from_ini(cls, ini):
71
        return cls({
72
            field_name: model_type.model_class.from_ini(ini)
73
            for field_name, model_type in cls.fields.items()
74
        })
75