(self,string)
return
Fill self from binary string
Fill self from binary string
Fill self from binary string
def decode(self,string):
        'Fill self from binary string'
        index = 0
        while True:
            substr = string[index:index+6]
            index += 6
            typ,siz = struct.unpack('<H I',substr)
            self.order.append((typ,siz))

            substr = string[index:index+siz]
            index += siz
            buf = struct.unpack('<%ds'%siz,substr)[0]

            name,decenc = self.format[typ]
            if name is None: break
            try:
                value = decenc[0](buf)
            except struct.error,msg:
                msg = '%s, typ = %d[%d] -> %s buf = "%s"'%\
                    (msg,typ,siz,self.format[typ],buf)
                raise struct.error,msg

            self.__dict__[name] = value
            continue
        return
def decode ( self , string ) : index = 0 while True : substr = string [ index : index + 6 ] index += 6 typ , siz = struct . unpack ( '<H I' , substr ) self . order . append ( ( typ , siz ) ) substr = string [ index : index + siz ] index += siz buf = struct . unpack ( '<%ds' % siz , substr ) [ 0 ] name , decenc = self . format [ typ ] if name is None : break try : value = decenc [ 0 ] ( buf ) except struct . error , msg : msg = '%s, typ = %d[%d] -> %s buf = "%s"' % ( msg , typ , siz , self . format [ typ ] , buf ) raise struct . error , msg self . __dict__ [ name ] = value continue return