def save(self): self.log('** Saving user data...') self.save_groups() file = open(self.file, 'w') file.write(export_struct(self.map)) file.close() self.log('** User data saved.')
def c_read(self, cmd, dAmn): sub_command = cmd.arguments(1).lower() if not sub_command in ('flat', 'json'): dAmn.say(cmd.ns, cmd.user+': Choose whether to read the data in the <b>flat</b> or json</b> file.') return data = None if sub_command == 'flat': data = self.flattext if sub_command == 'json': data = self.jsonf dAmn.say(cmd.ns, 'data in file:<br/><bcode>'+export_struct(data))
def save(self): data = { 'info': { 'username': self.info.username, 'password': self.info.password, 'owner': self.info.owner, 'trigger': self.info.trigger }, 'autojoin': self.autojoin, 'token': self.token, 'cookie': self.cookie } file = open(self.file, 'w') file.write(export_struct(data)) file.close()
def _dumps(self, file, data, pretty=True): """Write an object to a file as JSON.""" f = open(file, 'w') f.write(json.dumps if not pretty else export_struct(data)) f.close()