def getOneMessage ( self ):
( mbytes, hbytes ) = self._findMessageBytes ( self.buffer )<EOL>if not mbytes:<EOL><INDENT>return None<EOL><DEDENT>msgdata = self.buffer[:mbytes]<EOL>self.buffer = self.buffer[mbytes:]<EOL>hdata = msgdata[:hbytes]<EOL>elems = hdata.split ( '<STR_LIT:\n>' )<EOL>cmd     = elems.pop ( <NUM_LIT:0> )<EOL>headers = {}<EOL>for e in elems:<EOL><INDENT>try:<EOL><INDENT>i = e.find ( '<STR_LIT::>' )<EOL><DEDENT>except ValueError:<EOL><INDENT>continue<EOL><DEDENT>k = e[:i].strip()<EOL>v = e[i+<NUM_LIT:1>:].strip()<EOL>headers [ k ] = v<EOL><DEDENT>body = msgdata[hbytes+<NUM_LIT:2>:-<NUM_LIT:2>]<EOL>msg = { '<STR_LIT>'     : cmd,<EOL>'<STR_LIT>' : headers,<EOL>'<STR_LIT:body>'    : body,<EOL>}<EOL>return msg<EOL>
I pull one complete message off the buffer and return it decoded
as a dict. If there is no complete message in the buffer, I
return None.

Note that the buffer can contain more than once message. You
should therefore call me in a loop until I return None.