Esempio n. 1
0
 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
Esempio n. 2
0
 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)
Esempio n. 3
0
    def __init__(self, inStream: FileInputStream, knownTypes):
        """
        Parses a binary SKilL file
        :param inStream: FileInputStream
        :param knownTypes: classes from the specification
        """
        self.blockCounter = 0
        self.seenTypes = set()
        self.blockIDBarrier = 0
        self.poolByName = dict()
        self.localFields = []
        self.fieldDataQueue = []
        self.offset = 0
        self.types = []
        self.inStream = inStream
        self.strings = StringPool(self.inStream)
        self.annotation = Annotation(self.types)

        self.knownTypes = knownTypes

        while not inStream.eof():
            self.stringBlock()
            self.typeBlock()
Esempio n. 4
0
 def readSingleField(self, instream: FileInputStream):
     return instream.f64()