def parse_tag(self, dtype, count, offset_buf):
try:<EOL><INDENT>fmt = self.datatype2fmt[dtype][<NUM_LIT:0>] * count<EOL>payload_size = self.datatype2fmt[dtype][<NUM_LIT:1>] * count<EOL><DEDENT>except KeyError:<EOL><INDENT>msg = '<STR_LIT>'.format(dtype)<EOL>raise IOError(msg)<EOL><DEDENT>if payload_size <= <NUM_LIT:4>:<EOL><INDENT>target_buffer = offset_buf[:payload_size]<EOL><DEDENT>else:<EOL><INDENT>offset, = struct.unpack(self.endian + '<STR_LIT:I>', offset_buf)<EOL>target_buffer = self.read_buffer[offset:offset + payload_size]<EOL><DEDENT>if dtype == <NUM_LIT:2>:<EOL><INDENT>payload = target_buffer.decode('<STR_LIT:utf-8>').rstrip('<STR_LIT:\x00>')<EOL><DEDENT>else:<EOL><INDENT>payload = struct.unpack(self.endian + fmt, target_buffer)<EOL>if dtype == <NUM_LIT:5> or dtype == <NUM_LIT:10>:<EOL><INDENT>rational_payload = []<EOL>for j in range(count):<EOL><INDENT>value = float(payload[j * <NUM_LIT:2>]) / float(payload[j * <NUM_LIT:2> + <NUM_LIT:1>])<EOL>rational_payload.append(value)<EOL><DEDENT>payload = rational_payload<EOL><DEDENT>if count == <NUM_LIT:1>:<EOL><INDENT>payload = payload[<NUM_LIT:0>]<EOL><DEDENT><DEDENT>return payload<EOL>
Interpret an Exif image tag data payload.