def _ellipsis_match(want, got):
if want.find(ELLIPSIS_MARKER)==-<NUM_LIT:1>:<EOL><INDENT>return want == got<EOL><DEDENT>ws = want.split(ELLIPSIS_MARKER)<EOL>assert len(ws) >= <NUM_LIT:2><EOL>startpos, endpos = <NUM_LIT:0>, len(got)<EOL>w = ws[<NUM_LIT:0>]<EOL>if w:   <EOL><INDENT>if got.startswith(w):<EOL><INDENT>startpos = len(w)<EOL>del ws[<NUM_LIT:0>]<EOL><DEDENT>else:<EOL><INDENT>return False<EOL><DEDENT><DEDENT>w = ws[-<NUM_LIT:1>]<EOL>if w:   <EOL><INDENT>if got.endswith(w):<EOL><INDENT>endpos -= len(w)<EOL>del ws[-<NUM_LIT:1>]<EOL><DEDENT>else:<EOL><INDENT>return False<EOL><DEDENT><DEDENT>if startpos > endpos:<EOL><INDENT>return False<EOL><DEDENT>for w in ws:<EOL><INDENT>startpos = got.find(w, startpos, endpos)<EOL>if startpos < <NUM_LIT:0>:<EOL><INDENT>return False<EOL><DEDENT>startpos += len(w)<EOL><DEDENT>return True<EOL>
Essentially the only subtle case:
>>> _ellipsis_match('aa...aa', 'aaa')
False