diff -r 6c0609395889 -r dbf49689af0d configfile.py --- a/configfile.py Mon Jan 12 10:55:45 2015 +0200 +++ b/configfile.py Thu Jan 15 19:06:14 2015 +0200 @@ -26,12 +26,19 @@ def set_value (self, key, value): self.obj[key] = value self.save() + + def append_value (self, key, value): + if key not in self.obj: + self.obj[key] = [] + + self.obj[key].append (value) + self.save() def get_node (self, key): return ConfigNode (obj=self.get_value (key, {}), name=self.keyname (key), parent=self) - def get_nodelist (self, key): - data = self.get_value (key) + def get_nodelist (self, key, default=None): + data = self.get_value (key, default) result = [] for entry in data: @@ -39,9 +46,12 @@ result.append (node) return result + + def has_node (self, key): + return key in self.obj def append_nodelist (self, key): - data = self.get_value (key) + data = self.get_value (key, []) obj = {} data.append (obj) return ConfigNode (obj=obj, name=self.keyname (key), parent=self) @@ -76,4 +86,4 @@ global Config Config = ConfigNode (jsondata, name=None, parent=None) -init() \ No newline at end of file +init()