+# a dict with some useful additional getters which can convert types and handle one-element lists like their single member
+class ConfigDict(dict):
+ def getstr(self, name, default = None):
+ if not name in self: return default
+ val = self[name]
+ if isinstance(val, list):
+ if len(val) != 1: raise Exception('%s is a list, but it should not' % name)
+ return val[0]
+ else:
+ return val
+
+ def getint(self, name, default = None):
+ return int(self.getstr(name, default))
+
+ def getbool(self, name, default = None):
+ val = self.getstr(name, default)
+ if isinstance(val, bool): return val # already a bool
+ return val.lower() in ('true', 'yes', 'on', '1')
+
+# create a safe-to-call shell command from the array