Passed
Pull Request — master (#559)
by Konstantin
02:09
created

ocrd_models.ocrd_config.OcrdConfig.dump()   A

Complexity

Conditions 2

Size

Total Lines 5
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 5
dl 0
loc 5
rs 10
c 0
b 0
f 0
cc 2
nop 1
1
"""
2
Configuration file
3
"""
4
import json
5
6
DEFAULT_CONFIG = {
7
    'resource_location': 'virtualenv'
8
}
9
10
class OcrdConfig():
11
12
    __slots__ = DEFAULT_CONFIG.keys()
13
14
    def __str__(self):
15
        return 'OcrdConfig %s' % json.dumps(self.__dict__)
16
17
    def dump(self):
18
        ret = {}
19
        for k in DEFAULT_CONFIG.keys():
20
            ret[k] = getattr(self, k)
21
        return ret
22
23
    def __init__(self, obj):
24
        for k, v in obj.items():
25
            setattr(self, k, v)
26