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

Refly   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 49
Duplicated Lines 0 %

Test Coverage

Coverage 81.82%

Importance

Changes 3
Bugs 0 Features 1
Metric Value
wmc 3
c 3
b 0
f 1
dl 0
loc 49
ccs 9
cts 11
cp 0.8182
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A default() 0 5 2
A from_ini() 0 18 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, IntType, FloatType
7
8 1
from .interfaces import INISerializable, DefaultProvider
9 1
from .helpers import field_from_ini
10
11
12 1
@zope.interface.implementer(INISerializable)
13 1
@zope.interface.implementer(DefaultProvider)
14 1
class Refly(Model):
15 1
    is_disabled = BooleanType(
16
        default=False,
17
        required=True,
18
    )
19 1
    kia_delay = IntType(
20
        min_value=0,
21
        default=0,
22
        required=True,
23
    )
24 1
    kia_delay_multiplier = FloatType(
25
        min_value=0.0,
26
        default=0.0,
27
        required=True,
28
    )
29 1
    max_kia = IntType(
30
        min_value=-1,
31
        default=-1,
32
        required=True,
33
    )
34
35 1
    @classmethod
36
    def from_ini(cls, ini):
37
        return cls({
38
            'is_disabled': field_from_ini(
39
                cls.is_disabled, ini,
40
                'NET', 'reflyDisabled',
41
            ),
42
            'kia_delay': field_from_ini(
43
                cls.kia_delay, ini,
44
                'NET', 'reflyKIADelay',
45
            ),
46
            'kia_delay_multiplier': field_from_ini(
47
                cls.kia_delay_multiplier, ini,
48
                'NET', 'reflyKIADelayMultiplier',
49
            ),
50
            'max_kia': field_from_ini(
51
                cls.max_kia, ini,
52
                'NET', 'maxAllowedKIA',
53
            ),
54
        })
55
56 1
    @classmethod
57
    def default(cls):
58
        return cls({
59
            field_name: field.default
60
            for field_name, field in cls.fields.items()
61
        })
62