import json import os.path from AbstractFileHandler import AbstractFileHandler class IntermediateFile(AbstractFileHandler): def checkIfJsonExists(self, image_path): return os.path.isfile(super().changeFileExtension(image_path, "json")) def saveFileForCurrentImage(self, image_path, polygons): file_name = super().changeFileExtension(image_path, "json") with open(file_name, 'w') as file: json.dump(polygons, file) def loadFileForCurrentImage(self, image_path): file_name = super().changeFileExtension(image_path, "json") with open(file_name, 'r') as file: return json.load(file) def saveFile(self, filename, polygons): with open(filename, 'w') as file: json.dump(polygons, file) def loadFile(self, filename): with open(filename, 'w') as file: return json.load(file)