raster_stats/__main__.py
def _read_score_index_from_disk(score_file_path, datatype_id):
        """Create generator of float/int value from the given filenames.

        Reads a buffer of `buffer_size` big before to avoid keeping the
        file open between generations.

        score_file_path (string): a path to a file that has 32 bit data
            packed consecutively

        Yields:
            next (score, index) tuple in the given score and index files.

        """
        try:
            score_buffer = ''
            file_offset = 0
            buffer_offset = 0  # initialize to 0 to trigger the first load

            # ensure buffer size that is not a perfect multiple of 4
            read_buffer_size = int(math.sqrt(_BLOCK_SIZE))
            read_buffer_size = read_buffer_size - read_buffer_size % 4

            while True:
                if buffer_offset == len(score_buffer):
                    score_file = open(score_file_path, 'rb')
                    score_file.seek(file_offset)

                    score_buffer = score_file.read(read_buffer_size)
                    score_file.close()

                    file_offset += read_buffer_size
                    buffer_offset = 0
                packed_score = score_buffer[buffer_offset:buffer_offset+4]
                buffer_offset += 4
                if not packed_score:
                    break
                yield struct.unpack(datatype_id, packed_score)[0]
        finally:
            # deletes the files when generator goes out of scope or ends
            os.remove(score_file_path)
Create generator of float/int value from the given filenames.

        Reads a buffer of `buffer_size` big before to avoid keeping the
        file open between generations.

        score_file_path (string): a path to a file that has 32 bit data
            packed consecutively

        Yields:
            next (score, index) tuple in the given score and index files.

        
Create generator of float/int value from the given filenames.
Reads a buffer of `buffer_size` big before to avoid keeping the
file open between generations.

score_file_path (string): a path to a file that has 32 bit data
packed consecutively
Create generator of float / int value from the given filenames . Reads a buffer of ` buffer_size ` big before to avoid keeping the file open between generations . score_file_path ( string ) : a path to a file that has 32 bit data packed consecutively
def _read_score_index_from_disk(score_file_path, datatype_id):
        try:
            score_buffer = ''
            file_offset = 0
            buffer_offset = 0  
            read_buffer_size = int(math.sqrt(_BLOCK_SIZE))
            read_buffer_size = read_buffer_size - read_buffer_size % 4
            while True:
                if buffer_offset == len(score_buffer):
                    score_file = open(score_file_path, 'rb')
                    score_file.seek(file_offset)
                    score_buffer = score_file.read(read_buffer_size)
                    score_file.close()
                    file_offset += read_buffer_size
                    buffer_offset = 0
                packed_score = score_buffer[buffer_offset:buffer_offset+4]
                buffer_offset += 4
                if not packed_score:
                    break
                yield struct.unpack(datatype_id, packed_score)[0]
        finally:
            os.remove(score_file_path)
def _read_score_index_from_disk ( score_file_path , datatype_id ) : try : score_buffer = '' file_offset = 0 buffer_offset = 0 read_buffer_size = int ( math . sqrt ( _BLOCK_SIZE ) ) read_buffer_size = read_buffer_size - read_buffer_size % 4 while True : if buffer_offset == len ( score_buffer ) : score_file = open ( score_file_path , 'rb' ) score_file . seek ( file_offset ) score_buffer = score_file . read ( read_buffer_size ) score_file . close ( ) file_offset += read_buffer_size buffer_offset = 0 packed_score = score_buffer [ buffer_offset : buffer_offset + 4 ] buffer_offset += 4 if not packed_score : break yield struct . unpack ( datatype_id , packed_score ) [ 0 ] finally : os . remove ( score_file_path )
Create generator of float/int value from the given filenames.
Create generator of float / int value from the given filenames .
"""Create generator of float/int value from the given filenames.

        Reads a buffer of `buffer_size` big before to avoid keeping the
        file open between generations.

        score_file_path (string): a path to a file that has 32 bit data
            packed consecutively

        Yields:
            next (score, index) tuple in the given score and index files.

        """ # initialize to 0 to trigger the first load
 # ensure buffer size that is not a perfect multiple of 4
 # deletes the files when generator goes out of scope or ends

next (score, index) tuple in the given score and index files.
next ( score index ) tuple in the given score and index files .
score_file_path
datatype_id