]> jfr.im git - erebus.git/commitdiff
changes to config
authorzonidjan <redacted>
Mon, 16 Sep 2019 02:20:50 +0000 (21:20 -0500)
committerzonidjan <redacted>
Mon, 16 Sep 2019 02:20:50 +0000 (21:20 -0500)
- add getint
- add a section when using set, if it doesn't exist

config.py

index e0c604748948656b1d6a75e7efbcbbdf8a60af64..c1f61b4cb152b4eee008aae37296324cea990904 100644 (file)
--- a/config.py
+++ b/config.py
@@ -40,14 +40,21 @@ class Config(object):
                        return self.config.get(section, key)
                except:
                        return default
-       def getboolean(self, section, key):
-               val = self.get(section, key, False)
+       def getint(self, section, key, default=0):
+               try:
+                       return int(self.config.get(section, key))
+               except:
+                       return default
+       def getboolean(self, section, key, default=False):
+               val = self.get(section, key, default)
                if val == False or val == "0" or val.lower() == "false":
                        return False
                else:
                        return True
 
        def set(self, section, key, value):
+               if not self.config.has_section(section):
+                       self.config.add_section(section)
                self.config.set(section, key, value)
                if self.writeout: self.write()