Code Duplication    Length = 34-34 lines in 2 locations

il2fb/config/ds/schemas/statistics.py 1 location

@@ 95-128 (lines=34) @@
92
        })
93
94
95
@zope.interface.implementer(INISerializable)
96
@zope.interface.implementer(DefaultProvider)
97
class Belligerents(Model):
98
    show_score = BooleanType(
99
        default=False,
100
        required=True,
101
    )
102
    accumulate_score = BooleanType(
103
        default=False,
104
        required=True,
105
    )
106
107
    @classmethod
108
    def from_ini(cls, ini):
109
        return cls({
110
            'show_score': field_from_ini(
111
                cls.show_score, ini,
112
                'NET', 'showTeamScore',
113
            ),
114
            'accumulate_score': field_from_ini(
115
                cls.accumulate_score, ini,
116
                'NET', 'cumulativeTeamScore',
117
            ),
118
        })
119
120
    def to_ini(self, ini):
121
        field_to_ini(self.show_score, ini, 'NET', 'showTeamScore')
122
        field_to_ini(self.accumulate_score, ini, 'NET', 'cumulativeTeamScore')
123
124
    @classmethod
125
    def default(cls):
126
        return cls({
127
            field_name: field.default
128
            for field_name, field in cls.fields.items()
129
        })
130
131

il2fb/config/ds/schemas/about.py 1 location

@@ 12-45 (lines=34) @@
9
from .helpers import field_from_ini, field_to_ini
10
11
12
@zope.interface.implementer(INISerializable)
13
@zope.interface.implementer(DefaultProvider)
14
class About(Model):
15
    name = StringType(
16
        default="",
17
        required=True,
18
    )
19
    description = StringType(
20
        default="",
21
        required=True,
22
    )
23
24
    @classmethod
25
    def from_ini(cls, ini):
26
        return cls({
27
            'name': field_from_ini(
28
                cls.name, ini,
29
                'NET', 'serverName',
30
            ),
31
            'description': field_from_ini(
32
                cls.description, ini,
33
                'NET', 'serverDescription',
34
            ),
35
        })
36
37
    def to_ini(self, ini):
38
        field_to_ini(self.name, ini, 'NET', 'serverName')
39
        field_to_ini(self.description, ini, 'NET', 'serverDescription')
40
41
    @classmethod
42
    def default(cls):
43
        return cls({
44
            field_name: field.default
45
            for field_name, field in cls.fields.items()
46
        })
47