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

About.from_ini()   A

Complexity

Conditions 1

Size

Total Lines 10

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 1
CRAP Score 1.125

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 10
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 StringType
7
8 1
from .interfaces import INISerializable
9
10
11 1
@zope.interface.implementer(INISerializable)
12 1
class About(Model):
13 1
    name = StringType(
14
        default="",
15
        required=True,
16
    )
17 1
    description = StringType(
18
        default="",
19
        required=True,
20
    )
21
22 1
    @classmethod
23
    def from_ini(cls, ini):
24
        return cls({
25
            'name': ini.get(
26
                'NET', 'serverName',
27
                fallback=cls.name.default,
28
            ),
29
            'description': ini.get(
30
                'NET', 'serverDescription',
31
                fallback=cls.description.default,
32
            ),
33
        })
34