1
2
3
4
5 import ConfigParser
6
9 """@param cfg: configuration file."""
10 config = ConfigParser.ConfigParser(allow_no_value=True)
11 config.read(cfg)
12
13 for section in config.sections():
14 for name, raw_value in config.items(section):
15 if name == "file_name":
16 value = config.get(section, name)
17 else:
18 try:
19 value = config.getboolean(section, name)
20 except ValueError:
21 try:
22 value = config.getint(section, name)
23 except ValueError:
24 value = config.get(section, name)
25 setattr(self, name, value)
26
28 """Get analysis options.
29 @return: options dict.
30 """
31
32
33
34
35
36
37 options = {}
38 if hasattr(self, "options"):
39 try:
40
41 fields = self.options.split(",")
42 except ValueError as e:
43 pass
44 else:
45 for field in fields:
46
47 try:
48 key, value = field.split("=", 1)
49 except ValueError as e:
50 pass
51 else:
52
53
54 options[key.strip()] = value.strip()
55
56 return options
57