1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 """
18 =================
19 Setup utilities
20 =================
21
22 Setup utilities.
23 """
24 __author__ = u"Andr\xe9 Malo"
25 __docformat__ = "restructuredtext en"
26
27 from distutils import util as _util
28 try:
29
30 from ConfigParser import SafeConfigParser
31 except ImportError:
32 import ConfigParser as _config_parser
34 """ Safe config parser """
38
39 - def items(self, section):
40
41 return [(key, self.get(section, key))
42 for key in self.options(section)
43 ]
44
45
47 """
48 Determine human boolean value
49
50 :Parameters:
51 `name` : ``str``
52 The config key (used for error message)
53
54 `value` : ``str``
55 The config value
56
57 :Return: The boolean value
58 :Rtype: ``bool``
59
60 :Exceptions:
61 - `ValueError` : The value could not be recognized
62 """
63 try:
64 return _util.strtobool(str(value).strip().lower() or 'no')
65 except ValueError:
66 raise ValueError("Unrecognized config value: %s = %s" % (name, value))
67