#NEWLINE# def tokenize( msg ) : #NEWLINE# #INDENT# '\n    A generator which returning unpacked\n    packets from the given string of concatinated\n    packet strings.\n    ' #NEWLINE# while True : #NEWLINE# #INDENT# ( pid , length , data ) = unpack ( msg ) #NEWLINE# if ( pid or pid ) : #NEWLINE# #INDENT# ( yield ( pid , length , msg [ 4 : ( length + 4 ) ] ) ) #NEWLINE# msg = msg [ ( length + 4 ) : ] #NEWLINE# if ( len ( msg ) < 4 ) : #NEWLINE# #INDENT# break #NEWLINE# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# break