python-streamexpect
                                
                                
                                
                                    python-streamexpect copied to clipboard
                            
                            
                            
                        Provide convenience function to SearcherCollection
Right now accessing SearcherCollection to expect on a list of multiple patterns is clunky:
pat1 = RegexSearcher('pattern 1')
pat2 = RegexSearcher('pattern 2')
search = SearcherCollection([pat1, pat2])
with streamexpect.wrap(buf) as stream:
    match = stream.expect(search)
if match.searcher is pat1:
    # do stuff
else:
    pass
Instead, the expect_regex and expect_text functions could be extended to automatically add a SearcherCollection when they are passed a collection (list, tuple, etc):
pat1 = 'pattern 1'
pat2 = 'pattern 2'
with streamexpect.wrap(buf) as stream:
    match = stream.expect_regex([pat1, pat2])
if match.searcher is pat1:
    # do stuff
else:
    pass