Back to index

moin  1.9.0~rc2
Public Member Functions | Private Attributes
MoinMoin.support.xappy.indexerconnection.PrefixedTermIter Class Reference

List of all members.

Public Member Functions

def __init__
def __iter__
def next

Private Attributes

 _started
 _prefix
 _prefixlen
 _termiter

Detailed Description

Iterate through all the terms with a given prefix.

Definition at line 711 of file indexerconnection.py.


Constructor & Destructor Documentation

def MoinMoin.support.xappy.indexerconnection.PrefixedTermIter.__init__ (   self,
  prefix,
  termiter 
)
Initialise the prefixed term iterator.

- `prefix` is the prefix to return terms for.
- `termiter` is a xapian TermIterator, which should be at its start.

Definition at line 715 of file indexerconnection.py.

00715 
00716     def __init__(self, prefix, termiter):
00717         """Initialise the prefixed term iterator.
00718 
00719         - `prefix` is the prefix to return terms for.
00720         - `termiter` is a xapian TermIterator, which should be at its start.
00721 
00722         """
00723 
00724         # The algorithm used in next() currently only works for single
00725         # character prefixes, so assert that the prefix is single character.
00726         # To deal with multicharacter prefixes, we need to check for terms
00727         # which have a starting prefix equal to that given, but then have a
00728         # following uppercase alphabetic character, indicating that the actual
00729         # prefix is longer than the target prefix.  We then need to skip over
00730         # these.  Not too hard to implement, but we don't need it yet.
00731         assert(len(prefix) == 1)
00732 
00733         self._started = False
00734         self._prefix = prefix
00735         self._prefixlen = len(prefix)
00736         self._termiter = termiter


Member Function Documentation

Definition at line 737 of file indexerconnection.py.

00737 
00738     def __iter__(self):
00739         return self

Get the next term with the specified prefix.

Definition at line 740 of file indexerconnection.py.

00740 
00741     def next(self):
00742         """Get the next term with the specified prefix.
00743 
00744         """
00745         if not self._started:
00746             term = self._termiter.skip_to(self._prefix).term
00747             self._started = True
00748         else:
00749             term = self._termiter.next().term
00750         if len(term) < self._prefixlen or term[:self._prefixlen] != self._prefix:
00751             raise StopIteration
00752         return term[self._prefixlen:]
00753 

Here is the caller graph for this function:


Member Data Documentation

Definition at line 733 of file indexerconnection.py.

Definition at line 734 of file indexerconnection.py.

Definition at line 732 of file indexerconnection.py.

Definition at line 735 of file indexerconnection.py.


The documentation for this class was generated from the following file: