Total Complexity | 4 |
Total Lines | 56 |
Duplicated Lines | 0 % |
Coverage | 80% |
Changes | 4 | ||
Bugs | 0 | Features | 1 |
1 | # coding: utf-8 |
||
13 | 1 | @zope.interface.implementer(INISerializable) |
|
14 | 1 | @zope.interface.implementer(DefaultProvider) |
|
15 | 1 | class Refly(Model): |
|
16 | enabled = BooleanType( |
||
17 | default=True, |
||
18 | required=True, |
||
19 | 1 | ) |
|
20 | death_penalty = IntType( |
||
21 | min_value=0, |
||
22 | default=0, |
||
23 | required=True, |
||
24 | 1 | ) |
|
25 | death_penalty_multiplier = FloatType( |
||
26 | min_value=0.0, |
||
27 | default=0.0, |
||
28 | required=True, |
||
29 | 1 | ) |
|
30 | death_limit = IntType( |
||
31 | min_value=1, |
||
32 | default=None, |
||
33 | required=False, |
||
34 | ) |
||
35 | 1 | ||
36 | @classmethod |
||
37 | def from_ini(cls, ini): |
||
38 | death_limit = field_from_ini( |
||
39 | cls.death_limit, ini, |
||
40 | 'NET', 'maxAllowedKIA', |
||
41 | ) |
||
42 | death_limit = ( |
||
43 | None |
||
44 | if death_limit == NO_DEATH_LIMIT_FLAG |
||
45 | else death_limit |
||
46 | ) |
||
47 | |||
48 | return cls({ |
||
49 | 'enabled': not field_from_ini( |
||
50 | cls.enabled, ini, |
||
51 | 'NET', 'reflyDisabled', |
||
52 | ), |
||
53 | 'death_penalty': field_from_ini( |
||
54 | cls.death_penalty, ini, |
||
55 | 'NET', 'reflyKIADelay', |
||
56 | 1 | ), |
|
57 | 'death_penalty_multiplier': field_from_ini( |
||
58 | cls.death_penalty_multiplier, ini, |
||
59 | 'NET', 'reflyKIADelayMultiplier', |
||
60 | ), |
||
61 | 'death_limit': death_limit, |
||
62 | }) |
||
63 | |||
64 | @classmethod |
||
65 | def default(cls): |
||
66 | return cls({ |
||
67 | field_name: field.default |
||
68 | for field_name, field in cls.fields.items() |
||
69 | }) |
||
70 |