def func(self): ch = self.caller dump_ground = pathlib.Path( __file__).parent.parent / "resources" / "json" from evennia.utils.dbserialize import deserialize #zones zonedb = deserialize(GLOBAL_SCRIPTS.zonedb.vnum) objdb = deserialize(GLOBAL_SCRIPTS.objdb.vnum) roomdb = deserialize(GLOBAL_SCRIPTS.roomdb.vnum) books = [] objs = {'zones': zonedb, 'rooms': roomdb, 'objs': objdb} for fname, obj in sorted(objs.items()): if fname == 'objs': # remove books from dict for vnum, obj_value in tuple(obj.items()): if obj_value['type'] == 'book': book_details = dict() for x in ('key', 'sdesc', 'ldesc', 'extra'): book_details[x] = obj_value[x] books.append(book_details.copy()) del obj[vnum] with open(dump_ground / f"{fname}.json", "w") as f: js = json.dumps(obj, indent=2) f.write(js) ch.msg(f"Wrote {fname} to file.") # store books now with open(dump_ground / "books.json", 'w') as f: js = json.dumps(books, indent=2) f.write(js) ch.msg("Wrote books to file")
def prototype(self): "Make sure to decouple from db!" return dbserialize.deserialize(self.attributes.get('prototype', {}))