1 '''
2 module that provides configuration file functionality
3 '''
4
5
6
7 import logging, abc
8 from ConfigParser import SafeConfigParser
9
10
11 logging.getLogger(__name__)
12 log = logging.getLogger()
16 """abstract class with factory method from a config file
17
18 to subclass, need to define
19
20 _types: types for properties
21 _section: section on the confifg file"""
22
23 __metaclass__ = abc.ABCMeta
24
26 self.cfg = SafeConfigParser()
27 if not len(self.cfg.read([path])):
28 raise ValueError("cannot load %s" % path)
29 log.info("loaded settings from %s", path)
30 self._config_check()
31
33 return self.cfg.get(self._section, attr)
34
36 return self.cfg.set(self._section, attr, val)
37
38 @abc.abstractmethod
40 "check as much as you can that values of params make sense"
41
42 raise NotImplemented
43