'Write data, wrapping it in a pkt-line.'

def write(self, data):

    line = pkt_line(data)
    line_len = len(line)
    over = ((self._buflen + line_len) - self._bufsize)
    if (over >= 0):
        start = (line_len - over)
        self._wbuf.write(line[:start])
        self.flush()
    else:
        start = 0
    saved = line[start:]
    self._wbuf.write(saved)
    self._buflen += len(saved)
