aeidon.agents.SearchAgent

Source: aeidon/agents/search.py

Anchestors: aeidon.delegate.Delegate, builtins.object

class aeidon.agents.SearchAgent

Searching for and replacing text.

Searching is done with the help of an instance of aeidon.Finder. This agent provides for looping over the subtitles and their texts, feeding those texts to the finder and raising StopIteration when no more matches are found.

Methods

SearchAgent.__init__(master)

Initialize a SearchAgent instance.

SearchAgent.find_next(index=None, doc=None, pos=None)

Find the next match starting from given position.

index, doc and pos can be None to start from beginning. Raise StopIteration if no (more) matches exist. Return tuple of index, document, match span.

SearchAgent.find_previous(index=None, doc=None, pos=None)

Find the previous match starting from given position.

index, doc and pos can be None to start from end. Raise StopIteration if no (more) matches exist. Return tuple of index, document, match span.

SearchAgent.replace(register=-1)

Replace the current match of pattern.

Raise re.error if bad replacement.

SearchAgent.replace_all(register=-1)

Replace all matches of pattern and return amount of replacements made.

Raise re.error if bad replacement.

SearchAgent.set_search_regex(pattern, flags=24)

Set the regular expression pattern to find.

Raise re.error if bad pattern.

SearchAgent.set_search_replacement(replacement)

Set the replacement string.

SearchAgent.set_search_string(pattern, ignore_case=False)

Set the string pattern to find.

SearchAgent.set_search_target(indices=None, docs=None, wrap=True)

Set the targets to search in.

indices can be None to target all subtitles. docs can be None to target all documents.