class_docstr: Telnet interface class.
  
  An instance of this class represents a connection to a telnet
  server.  The instance is initially not connected; the open()
  method must be used to establish a connection.  Alternatively, the
  host name and optional port number can be passed to the
  constructor, too.
  
  Don't try to reopen an already connected instance.
  
  This class has many read_*() methods.  Note that some of them
  raise EOFError when the end of the connection is read, because
  they can return an empty string for other reasons.  See the
  individual doc strings.
  
  read_until(expected, [timeout])
      Read until the expected string has been seen, or a timeout is
      hit (default is no timeout); may block.
  
  read_all()
      Read all data until EOF; may block.
  
  read_some()
      Read at least one byte or EOF; may block.
  
  read_very_eager()
      Read all data available already queued or on the socket,
      without blocking.
  
  read_eager()
      Read either data already queued or some data available on the
      socket, without blocking.
  
  read_lazy()
      Read all data in the raw queue (processing it first), without
      doing any socket I/O.
  
  read_very_lazy()
      Reads all data in the cooked queue, without doing any socket
      I/O.
  
  read_sb_data()
      Reads available data between SB ... SE sequence. Don't block.
  
  set_option_negotiation_callback(callback)
      Each time a telnet option is read on the input flow, this callback
      (if set) is called with the following parameters :
      callback(telnet socket, command, option)
          option will be chr(0) when there is no option.
      No other action is done afterwards by telnetlib.
class_docstr_tok: ["Telnet","interface","class",".","An","instance","of","this","class","represents","a","connection","to","a","telnet","server",".","The","instance","is","initially","not","connected",";","the","open","(",")","method","must","be","used","to","establish","a","connection",".","Alternatively",",","the","host","name","and","optional","port","number","can","be","passed","to","the","constructor",",","too",".","Do","n't","try","to","reopen","an","already","connected","instance",".","This","class","has","many","read_","*","(",")","methods",".","Note","that","some","of","them","raise","EOFError","when","the","end","of","the","connection","is","read",",","because","they","can","return","an","empty","string","for","other","reasons",".","See","the","individual","doc","strings",".","read_until","(","expected",",","[","timeout","]",")","Read","until","the","expected","string","has","been","seen",",","or","a","timeout","is","hit","(","default","is","no","timeout",")",";","may","block",".","read_all","(",")","Read","all","data","until","EOF",";","may","block",".","read_some","(",")","Read","at","least","one","byte","or","EOF",";","may","block",".","read_very_eager","(",")","Read","all","data","available","already","queued","or","on","the","socket",",","without","blocking",".","read_eager","(",")","Read","either","data","already","queued","or","some","data","available","on","the","socket",",","without","blocking",".","read_lazy","(",")","Read","all","data","in","the","raw","queue","(","processing","it","first",")",",","without","doing","any","socket","I\/O",".","read_very_lazy","(",")","Reads","all","data","in","the","cooked","queue",",","without","doing","any","socket","I\/O",".","read_sb_data","(",")","Reads","available","data","between","SB","...","SE","sequence",".","Do","n't","block",".","set_option_negotiation_callback","(","callback",")","Each","time","a","telnet","option","is","read","on","the","input","flow",",","this","callback","(","if","set",")","is","called","with","the","following","parameters",":","callback","(","telnet","socket",",","command",",","option",")","option","will","be","chr","(","0",")","when","there","is","no","option",".","No","other","action","is","done","afterwards","by","telnetlib","."]
docstr: Read until one from a list of a regular expressions matches.
  
  The first argument is a list of regular expressions, either
  compiled (re.Pattern instances) or uncompiled (strings).
  The optional second argument is a timeout, in seconds; default
  is no timeout.
  
  Return a tuple of three items: the index in the list of the
  first regular expression that matches; the re.Match object
  returned; and the text read up till and including the match.
  
  If EOF is read and no text was read, raise EOFError.
  Otherwise, when nothing matches, return (-1, None, text) where
  text is the text received so far (may be the empty string if a
  timeout happened).
  
  If a regular expression ends with a greedy match (e.g. '.*')
  or if more than one expression can match the same input, the
  results are undeterministic, and may depend on the I/O timing.
docstr_tok: ["Read","until","one","from","a","list","of","a","regular","expressions","matches",".","The","first","argument","is","a","list","of","regular","expressions",",","either","compiled","(","re.Pattern","instances",")","or","uncompiled","(","strings",")",".","The","optional","second","argument","is","a","timeout",",","in","seconds",";","default","is","no","timeout",".","Return","a","tuple","of","three","items",":","the","index","in","the","list","of","the","first","regular","expression","that","matches",";","the","re.Match","object","returned",";","and","the","text","read","up","till","and","including","the","match",".","If","EOF","is","read","and","no","text","was","read",",","raise","EOFError",".","Otherwise",",","when","nothing","matches",",","return","(","-1",",","None",",","text",")","where","text","is","the","text","received","so","far","(","may","be","the","empty","string","if","a","timeout","happened",")",".","If","a","regular","expression","ends","with","a","greedy","match","(","e.g",".","'",".","*","'",")","or","if","more","than","one","expression","can","match","the","same","input",",","the","results","are","undeterministic",",","and","may","depend","on","the","I\/O","timing","."]
code: def expect(self, list, timeout=None):
      """Read until one from a list of a regular expressions matches.
  
      The first argument is a list of regular expressions, either
      compiled (re.Pattern instances) or uncompiled (strings).
      The optional second argument is a timeout, in seconds; default
      is no timeout.
  
      Return a tuple of three items: the index in the list of the
      first regular expression that matches; the re.Match object
      returned; and the text read up till and including the match.
  
      If EOF is read and no text was read, raise EOFError.
      Otherwise, when nothing matches, return (-1, None, text) where
      text is the text received so far (may be the empty string if a
      timeout happened).
  
      If a regular expression ends with a greedy match (e.g. '.*')
      or if more than one expression can match the same input, the
      results are undeterministic, and may depend on the I/O timing.
  
      """
      re = None
      list = list[:]
      indices = range(len(list))
      for i in indices:
          if not hasattr(list[i], "search"):
              if not re:
                  import re
              list[i] = re.compile(list[i])
      if timeout is not None:
          deadline = _time() + timeout
      with _TelnetSelector() as selector:
          selector.register(self, selectors.EVENT_READ)
          while not self.eof:
              self.process_rawq()
              for i in indices:
                  m = list[i].search(self.cookedq)
                  if m:
                      e = m.end()
                      text = self.cookedq[:e]
                      self.cookedq = self.cookedq[e:]
                      return (i, m, text)
              if timeout is not None:
                  ready = selector.select(timeout)
                  timeout = deadline - _time()
                  if not ready:
                      if timeout < 0:
                          break
                      else:
                          continue
              self.fill_rawq()
      text = self.read_very_lazy()
      if not text and self.eof:
          raise EOFError
      return (-1, None, text)
  
imports: import sys
  import socket
  import selectors
  from time import monotonic
  import warnings
label_desc: Use image node_id 26 for calling the Telnet obj's underlying member method code with example usage: obj.expect(list, timeout) and returns: unknown,  None,  text, i,  m,  text