예제 #1
0
 def readOne(self):
     try:
         data = self.fp.read(RECORD_STRUCT.size)
         record = RECORD_STRUCT.unpack(data)
     except Exception, e:
         if self.fp.tell() >= self._record2pos(self.length):
             raise ScidException('End of file reached')
         else:
             raise e
예제 #2
0
 def readOne(self):
     try:
         data = self.fp.read(RECORD_STRUCT.size)
         record = RECORD_STRUCT.unpack(data)
     except Exception, e:
         if self.fp.tell() >= self._record2pos(self.length):
             raise ScidException("End of file reached")
         else:
             raise e
예제 #3
0
    def readIter(self, limit=None):
        batch = 1000
        remain = self.length - self.tell()
        record_struct_size = RECORD_STRUCT.size
        i = 0
        while True:
            if batch > remain:
                batch = remain

            if limit and limit <= i or batch == 0:
                return

            remain -= batch
            i += batch

            data = self.fp.read(record_struct_size * batch)
            for x in range(batch):
                #yield ScidRecord.from_struct()
                yield RECORD_STRUCT.unpack_from(data, x * record_struct_size)
예제 #4
0
    def readIter(self, limit=None):
        batch = 1000
        remain = self.length - self.tell()
        record_struct_size = RECORD_STRUCT.size
        i = 0
        while True:
            if batch > remain:
                batch = remain

            if limit and limit <= i or batch == 0:
                return

            remain -= batch
            i += batch

            data = self.fp.read(record_struct_size * batch)
            for x in range(batch):
                # yield ScidRecord.from_struct()
                yield RECORD_STRUCT.unpack_from(data, x * record_struct_size)
예제 #5
0
 def write(self, record):
     self.fp.write(RECORD_STRUCT.pack(*record))
예제 #6
0
 def write(self, record):
     self.fp.write(RECORD_STRUCT.pack(*record))