예제 #1
0
    def read(self, stream):
        """
        Read from `stream`. Returns:

        - 1 if read OK and more to go.
        - 0 if read OK and end of data.
        - -1 if end-of-file or read error.
        """
        #read title1
        #print  '  in Case.read.......'
        line = stream.readline()
        if not line:
            return False
        #print  ' First title line =', line
        self.title1 = line
        line = stream.readline()
        if not line:
            return False
        self.title2 = line
        #print  ' Second title line =', line

        #stage loop
        pos = stream.tell()
        line = stream.readline()
        while line and '&DATAIN' in line:
            stagein = Datain()
            if stagein.read(stream):
                stage_num = len(self._stages) + 1
                self.add('Stage%d' % stage_num, stagein)
                self._stages.append(stagein)
                #print ' stage_num  =', stage_num
                if stagein.endjob:
                    return 0
                if stagein.endstg:
                    return 1
            else:
                return -1
            pos = stream.tell()
            line = stream.readline()

        if line:
            stream.seek(os.SEEK_SET, pos)

        return 1
예제 #2
0
    def read (self, stream):
        """
        Read from `stream`. Returns:

        - 1 if read OK and more to go.
        - 0 if read OK and end of data.
        - -1 if end-of-file or read error.
        """
        #read title1
        #print  '  in Case.read.......'
        line = stream.readline()
        if not line:
            return False
        #print  ' First title line =', line
        self.title1 = line
        line = stream.readline()
        if not line:
            return False
        self.title2 = line
        #print  ' Second title line =', line

        #stage loop          
        pos = stream.tell()
        line = stream.readline()
        while line and '&DATAIN' in line:
            stagein = Datain()
            if stagein.read(stream):
                stage_num = len(self._stages) + 1
                self.add('Stage%d'%stage_num, stagein)
                self._stages.append(stagein)
                #print ' stage_num  =', stage_num
                if stagein.endjob:
                    return 0
                if stagein.endstg:
                    return 1
            else:
                return -1
            pos = stream.tell()
            line = stream.readline()

        if line:
            stream.seek(os.SEEK_SET, pos)

        return 1