def __makeInStream(self): """ If FileInputStream is closed or None, a new FileInputStream will be opened. :return: current FileInputStream """ if self.__input is None or self.__input.file.closed or not ( self.__path == self.__input.path): self.__input = FileInputStream.open(self.__path) return self.__input
def open(path, mode: [], knownTypes: []): """ Create a new skill file based on argument path and mode. """ actualMode = ActualMode(mode) try: if actualMode.openMode == Mode.Create: strings = StringPool(None) types = [] annotation = Annotation(types) return SkillState({}, strings, annotation, types, FileInputStream.open(path), actualMode.closeMode, knownTypes) elif actualMode.openMode == Mode.Read: p = Parser(FileInputStream.open(path), knownTypes) return p.read(SkillState, actualMode.closeMode, knownTypes) else: raise Exception("should never happen") except SkillException as e: raise e except Exception as e: raise SkillException(e)