def persist_pathways(self): ensure_dir(PATHWAY_FILE_PATH) try: f = open(PATHWAY_FILE_PATH, "w") # write mode to replace any old version of the file # TODO need to make sure that changes aren't going to be lost with multiple instances # overwriting each other. For now just stick to workflows that will prevent this. pickle.dump(self._pathways, f) f.close() except IOError: raise IOError("unable to save pathways")
def __init__(self): # Unpickle list of pathways if present ensure_dir(PATHWAY_FILE_PATH) try: f = open(PATHWAY_FILE_PATH, "r") self._pathways = pickle.load(f) f.close() except IOError: # file doesn't exist, use empty list self._pathways = []