unpacks the given struct from the underlying buffer and returns
        the results. Will raise an UnpackException if there is not
        enough data to satisfy the format of the structure
343650
def unpack_struct(self, struct):
        

        size = struct.size

        offset = self.offset
        if self.data:
            avail = len(self.data) - offset
        else:
            avail = 0

        if avail < size:
            raise UnpackException(struct.format, size, avail)

        self.offset = offset + size
        return struct.unpack_from(self.data, offset)
302761
def unpack(value):
    """"""
    if not isinstance(value, tuple):
        return value, 200, {}

    try:
        data, code, headers = value
        return data, code, headers
    except ValueError:
        pass

    try:
        data, code = value
        return data, code, {}
    except ValueError:
        pass

    return value, 200, {}
964726
def deserialize(self, data, fields=None):
        
        # TODO: it can be that we returned data by `get_lines`, that is already deserialized
        if not isinstance(data, (bytes, bytearray)):
            return data
        return msgpack.unpackb(data, encoding='utf-8', object_pairs_hook=decode_to_sorted)
576189
def unpack(fmt, arg):
    """"""

    if isinstance(arg, bytearray) and not (sys.version_info >= (2, 7, 5)):
        return struct.unpack(fmt, str(arg))

    return struct.unpack(fmt, arg)
206858
def unpack_header(data)
      struct_header_len = MAGIC_STRING.size
      magic_message = data[0, struct_header_len]
      len, type = data[struct_header_len..-1].unpack("LL")
      [magic_message, len, type]
    end
360671
def _StructPackDecoder(wire_type, format):
  

  value_size = struct.calcsize(format)
  local_unpack = struct.unpack

  # Reusing _SimpleDecoder is slightly slower than copying a bunch of code, but
  # not enough to make a significant difference.

  # Note that we expect someone up-stack to catch struct.error and convert
  # it to _DecodeError -- this way we don't have to set up exception-
  # handling blocks every time we parse one value.

  def InnerDecode(buffer, pos):
    new_pos = pos + value_size
    result = local_unpack(format, buffer[pos:new_pos])[0]
    return (result, new_pos)
  return _SimpleDecoder(wire_type, InnerDecode)
454625
def parse(self, buf):
        ''''''
        try:
            t = struct.unpack(self.pack_string, buf)
        except struct.error as msg:
            raise fgFDMError('unable to parse - %s' % msg)
        self.values = list(t)
899326
def struct_from_value( cls, name, volume,
			channel_list=None, mute=False, device=None ):
		''
		chan_map = c.PA_CHANNEL_MAP()
		if not channel_list: c.pa.channel_map_init_mono(chan_map)
		else:
			if not is_str(channel_list):
				channel_list = b','.join(map(c.force_bytes, channel_list))
			c.pa.channel_map_parse(chan_map, channel_list)
		if not isinstance(volume, PulseVolumeInfo):
			volume = PulseVolumeInfo(volume, chan_map.channels)
		struct = c.PA_EXT_STREAM_RESTORE_INFO(
			name=c.force_bytes(name),
			mute=int(bool(mute)), device=c.force_bytes(device),
			channel_map=chan_map, volume=volume.to_struct() )
		return struct
342503
def int(self, *args):
        
        data = self.bytes(*args)
        if data is not None:
            if len(data) == 1:
                return struct.unpack("<B", data)[0]
            if len(data) == 2:
                return struct.unpack("<H", data)[0]
            if len(data) == 4:
                return struct.unpack("<L", data)[0]
            if len(data) == 8:
                return struct.unpack("<Q", data)[0]
            print("can't get int from %s" % hexdump(data))
44065
def _unpack_annotation_val(unpacker, cpool):
    

    tag, = unpacker.unpack_struct(_B)
    tag = chr(tag)

    if tag in 'BCDFIJSZs':
        data, = unpacker.unpack_struct(_H)

    elif tag == 'e':
        data = unpacker.unpack_struct(_HH)

    elif tag == 'c':
        data, = unpacker.unpack_struct(_H)

    elif tag == '@':
        data = JavaAnnotation(cpool)
        data.unpack(unpacker)

    elif tag == '[':
        data = list()
        count, = unpacker.unpack_struct(_H)
        for _i in range(0, count):
            data.append(_unpack_annotation_val(unpacker, cpool))

    else:
        raise Unimplemented("Unknown tag {}".format(tag))

    return tag, data
728640
def read_octet(self, unpacker=Struct('B').unpack_from,
                   size=Struct('B').size):
        
        # Technically should look at unpacker.size, but skipping that is way
        # faster and this method is the most-called of the readers
        if self._pos >= self._end_pos:
            raise self.BufferUnderflow()
        rval = unpacker(self._input, self._pos)[0]
        self._pos += size
        return rval
804640
def unpack(cls, data):
        
        size = struct.calcsize(APPHeader.fmt_header)
        (
            version, msg_type, payload_len,
            timestamp, device_id, flags,
        ), payload = struct.unpack(
            APPHeader.fmt_header, data[:size]
        ), data[size:]
        ack_sequence_number = None
        sequence_number = None

        if flags & Flag.ACKSEQ:
            size = struct.calcsize(APPHeader.fmt_seq_ack)
            (ack_sequence_number,), payload = struct.unpack(
                APPHeader.fmt_seq_ack, payload[:size]
            ), payload[size:]
        if flags & Flag.SEQ:
            size = struct.calcsize(APPHeader.fmt_seq)
            (sequence_number,), payload = struct.unpack(
                APPHeader.fmt_seq, payload[:size]
            ), payload[size:]
        return cls(
            message_type=msg_type,
            version_major=version >> 4,
            version_minor=version & 0xf,
            payload_length=payload_len,
            device_id=device_id,
            sequence_number=sequence_number,
            flags=flags,
            timestamp=timestamp,
            ack_sequence_number=ack_sequence_number
        ), payload
1213682
def unpack(cls, data):
        
        header, data = APPHeader.unpack(data)

        if len(data) < header.payload_length:
            raise ProtocolViolation("Payload too small")
        payload = data[:header.payload_length]
        body = cls()
        body._header = header
        body._payload = payload
        return body, data[header.payload_length:]
679981
def _unpack_header(self, data):
        
        return struct.unpack(self._struct_header,
                             data[:self._struct_header_size])
371066
def _unpack_wide(bc, offset):
    

    code = ord(bc[offset])

    if code == OP_iinc:
        return _unpack(_struct_BHh, bc, offset)

    elif code in (OP_iload, OP_fload, OP_aload, OP_lload, OP_dload,
                  OP_istore, OP_fstore, OP_astore, OP_lstore,
                  OP_dstore, OP_ret):

        return _unpack(_struct_BH, bc, offset)

    else:
        # no other opcodes are valid, so shouldn't have fallen through
        # to here.
        assert False
1144669
def unpack(self, unpacker):
        

        (a, b, c) = unpacker.unpack_struct(_HHI)

        self.max_stack = a
        self.max_locals = b
        self.code = unpacker.read(c)

        uobjs = unpacker.unpack_objects
        self.exceptions = tuple(uobjs(JavaExceptionInfo, self))

        self.attribs.unpack(unpacker)
550504
def read_short(self, unpacker=Struct('>H').unpack_from,
                   size=Struct('>H').size):
        
        self._check_underflow(size)
        rval = unpacker(self._input, self._pos)[0]
        self._pos += size
        return rval