def writeToJSONFile(fileName, data): pprint(data) filePath = getFilePath(fileName) lockfile = QLockFile(getLockfileName(fileName)) lockfile.lock() with open(filePath, 'w') as f: json.dump(data, f) lockfile.unlock()
def loadFromFile(file): lockfile = QLockFile(getLockfileName(file)) lockfile.lock() if not QFileInfo(file).exists(): return with open(file) as f: data = json.load(f) return data