class _PartialMessage(object):
    """
    Helper class to build up a multi-frame method.

    """
    def __init__(self, method_sig, args):
        self.method_sig = method_sig
        self.args = args
        self.msg = Message()
        self.body_parts = []
        self.body_received = 0
        self.body_size = None
        self.complete = False


    def add_header(self, payload):
        class_id, weight, self.body_size = unpack('>HHQ', payload[:12])
        self.msg._load_properties(payload[12:])
        self.complete = (self.body_size == 0)


    def add_payload(self, payload):
        self.body_parts.append(payload)
        self.body_received += len(payload)

        if self.body_received == self.body_size:
            self.msg.body = bytes().join(self.body_parts)
            self.complete = True
class _PartialMessage(object):
    """
    Helper class to build up a multi-frame method.

    """
    def __init__(self, method_sig, args):
        self.method_sig = method_sig
        self.args = args
        self.msg = Message()
        self.body_parts = []
        self.body_received = 0
        self.body_size = None
        self.complete = False

    def add_header(self, payload):
        class_id, weight, self.body_size = unpack('>HHQ', payload[:12])
        self.msg._load_properties(payload[12:])
        self.complete = (self.body_size == 0)

    def add_payload(self, payload):
        self.body_parts.append(payload)
        self.body_received += len(payload)

        if self.body_received == self.body_size:
            self.msg.body = ''.join(self.body_parts)
            self.complete = True
 def __init__(self, method_sig, args):
     self.method_sig = method_sig
     self.args = args
     self.msg = Message()
     self.body_parts = []
     self.body_received = 0
     self.body_size = None
     self.complete = False
 def __init__(self, method_sig, args):
     self.method_sig = method_sig
     self.args = args
     self.msg = Message()
     self.body_parts = []
     self.body_received = 0
     self.body_size = None
     self.complete = False