def __init__(self, filename): self.userhosts = {} self.masks = {} self.compiled = {} Persist.__init__(self, filename) if not self.data: self.data = [] for i in self.data: for j in i.userhosts: self.adduserhost(j, i)
def __init__(self, filename): Persist.__init__(self, filename) if not self.data: return for key in self.data.keys(): todoos = self.data[key] for (k, v) in todoos.data.items(): v.num = k newd = Todolist() for i in todoos: newd.append(i) self.data[key] = newd
def __init__(self): self.__basename__ = self.__class__.__name__ self.plugname = calledfrom(sys._getframe()) Persist.__init__(self, os.path.join(datadir, "%s-config" % self.plugname), {}) self.__callbacks = {} cmndname = "%s-cfg" % self.plugname logging.info("added command %s (%s)" % (cmndname, self.plugname)) cmnds[cmndname] = Command(self.cmnd_cfg, "OPER", self.plugname, threaded=True) examples.add(cmndname, "plugin configuration", cmndname) cmndnamesave = cmndname + "save" cmnds[cmndnamesave] = Command(self.cmnd_cfgsave, "OPER", self.plugname, threaded=True) examples.add(cmndnamesave, "save plugin configuration", cmndnamesave)
def syncold(self, filename, remove=False): """ sync with old config data """ if os.path.isfile(filename): synckey = "persistconfig-syncold" oldconfig = Persist(filename) if not oldconfig.data.has_key(synckey): logging.warn("syncing old config %s with persistconfig" % filename) for i, j in oldconfig.data.iteritems(): if i == synckey: continue if j and not self.get(i): self.set(i, oldconfig.data[i]) oldconfig.data[synckey] = time.localtime() oldconfig.save() del oldconfig if remove: os.unlink(filename)
def save(self): Persist.save(self)
def __init__(self, filename): Persist.__init__(self, filename) if not self.data: self.data = {}