parameters: (self)
docstring: Transfer from raw queue to cooked queue.
  
          Set self.eof when connection is closed.  Don't block unless in
          the midst of an IAC sequence.
docstring_summary: Transfer from raw queue to cooked queue.
docstring_tokens: Transfer from raw queue to cooked queue .
function: def process_rawq(self):
          """Transfer from raw queue to cooked queue.
  
          Set self.eof when connection is closed.  Don't block unless in
          the midst of an IAC sequence.
  
          """
          buf = ['', '']
          try:
              while self.rawq:
                  c = self.rawq_getchar()
                  if not self.iacseq:
                      if c == theNULL:
                          continue
                      if c == "\021":
                          continue
                      if c != IAC:
                          buf[self.sb] = buf[self.sb] + c
                          continue
                      else:
                          self.iacseq += c
                  elif len(self.iacseq) == 1:
                      # 'IAC: IAC CMD [OPTION only for WILL/WONT/DO/DONT]'
                      if c in (DO, DONT, WILL, WONT):
                          self.iacseq += c
                          continue
  
                      self.iacseq = ''
                      if c == IAC:
                          buf[self.sb] = buf[self.sb] + c
                      else:
                          if c == SB: # SB ... SE start.
                              self.sb = 1
                              self.sbdataq = ''
                          elif c == SE:
                              self.sb = 0
                              self.sbdataq = self.sbdataq + buf[1]
                              buf[1] = ''
                          if self.option_callback:
                              # Callback is supposed to look into
                              # the sbdataq
                              self.option_callback(self.sock, c, NOOPT)
                          else:
                              # We can't offer automatic processing of
                              # suboptions. Alas, we should not get any
                              # unless we did a WILL/DO before.
                              self.msg('IAC %d not recognized' % ord(c))
                  elif len(self.iacseq) == 2:
                      cmd = self.iacseq[1]
                      self.iacseq = ''
                      opt = c
                      if cmd in (DO, DONT):
                          self.msg('IAC %s %d',
                              cmd == DO and 'DO' or 'DONT', ord(opt))
                          if self.option_callback:
                              self.option_callback(self.sock, cmd, opt)
                          else:
                              self.sock.sendall(IAC + WONT + opt)
                      elif cmd in (WILL, WONT):
                          self.msg('IAC %s %d',
                              cmd == WILL and 'WILL' or 'WONT', ord(opt))
                          if self.option_callback:
                              self.option_callback(self.sock, cmd, opt)
                          else:
                              self.sock.sendall(IAC + DONT + opt)
          except EOFError: # raised by self.rawq_getchar()
              self.iacseq = '' # Reset on EOF
              self.sb = 0
              pass
          self.cookedq = self.cookedq + buf[0]
          self.sbdataq = self.sbdataq + buf[1]
function_tokens: def process_rawq ( self ) : buf = [ '' , '' ] try : while self . rawq : c = self . rawq_getchar ( ) if not self . iacseq : if c == theNULL : continue if c == "\021" : continue if c != IAC : buf [ self . sb ] = buf [ self . sb ] + c continue else : self . iacseq += c elif len ( self . iacseq ) == 1 : # 'IAC: IAC CMD [OPTION only for WILL/WONT/DO/DONT]' if c in ( DO , DONT , WILL , WONT ) : self . iacseq += c continue self . iacseq = '' if c == IAC : buf [ self . sb ] = buf [ self . sb ] + c else : if c == SB : # SB ... SE start. self . sb = 1 self . sbdataq = '' elif c == SE : self . sb = 0 self . sbdataq = self . sbdataq + buf [ 1 ] buf [ 1 ] = '' if self . option_callback : # Callback is supposed to look into # the sbdataq self . option_callback ( self . sock , c , NOOPT ) else : # We can't offer automatic processing of # suboptions. Alas, we should not get any # unless we did a WILL/DO before. self . msg ( 'IAC %d not recognized' % ord ( c ) ) elif len ( self . iacseq ) == 2 : cmd = self . iacseq [ 1 ] self . iacseq = '' opt = c if cmd in ( DO , DONT ) : self . msg ( 'IAC %s %d' , cmd == DO and 'DO' or 'DONT' , ord ( opt ) ) if self . option_callback : self . option_callback ( self . sock , cmd , opt ) else : self . sock . sendall ( IAC + WONT + opt ) elif cmd in ( WILL , WONT ) : self . msg ( 'IAC %s %d' , cmd == WILL and 'WILL' or 'WONT' , ord ( opt ) ) if self . option_callback : self . option_callback ( self . sock , cmd , opt ) else : self . sock . sendall ( IAC + DONT + opt ) except EOFError : # raised by self.rawq_getchar() self . iacseq = '' # Reset on EOF self . sb = 0 pass self . cookedq = self . cookedq + buf [ 0 ] self . sbdataq = self . sbdataq + buf [ 1 ]