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

Morse.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
9
10
11 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...
12 1
class Morse(Model):
13 1
    allow_morse_as_text = BooleanType(
14
        default=True,
15
        required=True,
16
    )
17 1
    show_morse_as_text = BooleanType(
18
        default=False,
19
        required=True,
20
    )
21 1
    block_morse_chat = BooleanType(
22
        default=False,
23
        required=True,
24
    )
25
26 1
    @classmethod
27
    def from_ini(cls, ini):
28
        return cls({
29
            'allow_morse_as_text': ini.getboolean(
30
                'NET', 'allowMorseAsText',
31
                fallback=cls.allow_morse_as_text.default,
32
            ),
33
            'show_morse_as_text': ini.getboolean(
34
                'game', 'ShowMorseAsText',
35
                fallback=cls.show_morse_as_text.default,
36
            ),
37
            'block_morse_chat': ini.getboolean(
38
                'game', 'BlockMorseChat',
39
                fallback=cls.block_morse_chat.default,
40
            ),
41
        })
42