MCPcopy Create free account
hub / github.com/pexpect/pexpect / expect_list

Method expect_list

pexpect/spawnbase.py:357–383  ·  view source on GitHub ↗

This takes a list of compiled regular expressions and returns the index into the pattern_list that matched the child output. The list may also contain EOF or TIMEOUT(which are not compiled regular expressions). This method is similar to the expect() method except that

(self, pattern_list, timeout=-1, searchwindowsize=-1,
                    async_=False, **kw)

Source from the content-addressed store, hash-verified

355 timeout, searchwindowsize, async_)
356
357 def expect_list(self, pattern_list, timeout=-1, searchwindowsize=-1,
358 async_=False, **kw):
359 '''This takes a list of compiled regular expressions and returns the
360 index into the pattern_list that matched the child output. The list may
361 also contain EOF or TIMEOUT(which are not compiled regular
362 expressions). This method is similar to the expect() method except that
363 expect_list() does not recompile the pattern list on every call. This
364 may help if you are trying to optimize for speed, otherwise just use
365 the expect() method. This is called by expect().
366
367
368 Like :meth:`expect`, passing ``async_=True`` will make this return an
369 asyncio coroutine.
370 '''
371 if timeout == -1:
372 timeout = self.timeout
373 if 'async' in kw:
374 async_ = kw.pop('async')
375 if kw:
376 raise TypeError("Unknown keyword arguments: {}".format(kw))
377
378 exp = Expecter(self, searcher_re(pattern_list), searchwindowsize)
379 if async_:
380 from ._async import expect_async
381 return expect_async(exp, timeout)
382 else:
383 return exp.expect_loop(timeout)
384
385 def expect_exact(self, pattern_list, timeout=-1, searchwindowsize=-1,
386 async_=False, **kw):

Callers 1

expectMethod · 0.95

Calls 4

expect_loopMethod · 0.95
ExpecterClass · 0.85
searcher_reClass · 0.85
expect_asyncFunction · 0.70

Tested by

no test coverage detected