Example #1
0
 def save(self):  #Method for saving a group and its data
     log.save("Saving:", self)
     log.debug("BOT HERE:", self.bot)
     with Files.SafeOpen(self.filePath, "w") as file:
         file.write(type(self).__name__ + "\n")
         self._save(file)
     return self
Example #2
0
def securityLoad():
  global _idDict
  try:
    with Files.SafeOpen(ID_FILE, "r") as file:
      log.save("Loading ID file")
      _idDict = json.load(file)
  except (FileNotFoundError, json.decoder.JSONDecodeError):
    log.save("ID file not found, using none")
Example #3
0
 def save(self):
     log.save.low("Saving",
                  type(self).__name__, "data for", self.ID
                  or self.getName())
     with Files.SafeOpen(self.getFileName(
     ), "w") as file:  #Will save data, first line being the class __name__
         Files.write(file, type(self).__name__)
         self._save(file)
     return self
Example #4
0
 def _save(self):
     if self._hasLoaded:  #If hasn't loaded, nothing has changed yet (can't, hasn't been loaded)
         log.save.low("Saving", self)
         with Files.SafeOpen(self.fileName, "w") as file:
             try:
                 Files.write(file, self.group.parent.groupID)
             except AttributeError:
                 Files.write(file,
                             "0")  #In any case where there is no parent
             #Then write all messages
             json.dump(self._messageList, file)
Example #5
0
def securitySave():
  log.save("Saving ID file")
  with Files.SafeOpen(ID_FILE, "w") as file:
    json.dump(_idDict, file)