Ejemplo n.º 1
0
    def save_or_retrieve(self):
        choice = input(
            "do you wish to save or retrieve data? (s/r, 0 to exit)\n")
        if choice == 0:
            return
        if choice.lower()[0] != "s" and choice.lower()[0] != "r":
            print("couldn't recognize response")
            return
        if choice.lower()[0] == "s":
            with open("manager.json", "w") as outfile:
                data = json.dumps(self.manager.__dict__())
                outfile.write(data)
                print("saved data")
        else:
            with open("manager.json", "r") as f:
                data = json.loads(f.read())

                m = Manager.from_json(data)
                Menu(m).run()