Package duplicity :: Module pexpect :: Class searcher_string
[hide private]
[frames] | no frames]

Class searcher_string

source code


This is a plain string search helper for the spawn.expect_any() method.

Attributes:

    eof_index     - index of EOF, or -1
    timeout_index - index of TIMEOUT, or -1

After a successful match by the search() method the following attributes
are available:

    start - index into the buffer, first byte of match
    end   - index into the buffer, first byte after match
    match - the matching string itself

Instance Methods [hide private]
 
__init__(self, strings)
This creates an instance of searcher_string.
source code
 
__str__(self)
This returns a human-readable string that represents the state of the object.
source code
 
search(self, buffer, freshlen, searchwindowsize=None)
This searches 'buffer' for the first occurence of one of the search strings.
source code

Inherited from object: __delattr__, __format__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __repr__, __setattr__, __sizeof__, __subclasshook__

Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

__init__(self, strings)
(Constructor)

source code 

This creates an instance of searcher_string. This argument 'strings' may be a list; a sequence of strings; or the EOF or TIMEOUT types.

Overrides: object.__init__

__str__(self)
(Informal representation operator)

source code 

This returns a human-readable string that represents the state of the object.

Overrides: object.__str__

search(self, buffer, freshlen, searchwindowsize=None)

source code 

This searches 'buffer' for the first occurence of one of the search strings. 'freshlen' must indicate the number of bytes at the end of 'buffer' which have not been searched before. It helps to avoid searching the same, possibly big, buffer over and over again.

See class spawn for the 'searchwindowsize' argument.

If there is a match this returns the index of that string, and sets 'start', 'end' and 'match'. Otherwise, this returns -1.