X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=sfa%2Futil%2Fconfig.py;h=32b95b98bdf0871675fadc6210018cabac5357a9;hb=de281c102f90bf628b08cadf8490cf11c40fa812;hp=272e49e1324e6d353c706b42d52d60d8a9b4b517;hpb=d35bea58b9365b9b651ca86c5d982c6524d249b1;p=sfa.git diff --git a/sfa/util/config.py b/sfa/util/config.py index 272e49e1..32b95b98 100644 --- a/sfa/util/config.py +++ b/sfa/util/config.py @@ -12,6 +12,12 @@ default_config = \ """ """ +def isbool(v): + return v.lower() in ("true", "false") + +def str2bool(v): + return v.lower() in ("true", "1") + class Config: def __init__(self, config_file='/etc/sfa/sfa_config'): @@ -107,7 +113,6 @@ DO NOT EDIT. This file was automatically generated at for item in self.config.items(section): name = "%s_%s" % (section, item[0]) value = item[1] - if setattr(self, name, value) setattr(self, name.upper(), value) @@ -163,7 +168,9 @@ DO NOT EDIT. This file was automatically generated at # bash does not have the concept of NULL if value: option = "%s_%s" % (section.upper(), name.upper()) - if not isinstance(value, bool) and not value.isdigit(): + if isbool(value): + value = str(str2bool(value)) + elif not value.isdigit(): value = '"%s"' % value buf.write(option + "=" + value + os.linesep) return buf.getvalue()