def from_json_str(cls, json_str: str, instruction_set: InstructionSet): """Create a PushSolution from a JSON string.""" solution_dict = json.loads(json_str) return cls( CodeBlock.from_json_str( json.dumps(solution_dict["program"], separators=(',', ':')), instruction_set), solution_dict["output_types"])
def from_json_str(cls, json_str: str, instruction_set: InstructionSet): """Create a PushSolution from a JSON string.""" solution_dict = json.loads(json_str) return cls( CodeBlock.from_json_str( json.dumps(solution_dict["program"], separators=(',', ':')), instruction_set ), solution_dict["output_types"] )
def load_program(name: str) -> CodeBlock: with open("tests/resources/programs/" + name + ".json") as f: return CodeBlock.from_json_str(f.read(), i_set)
def load_program(name, interpreter) -> CodeBlock: with open("tests/resources/programs/" + name + ".json") as f: return CodeBlock.from_json_str(f.read(), interpreter.instruction_set)