Back to index

enigmail  1.4.3
Public Member Functions | Public Attributes
utils.pushback_iter Class Reference

List of all members.

Public Member Functions

def __init__
def __iter__
def __nonzero__
def next
def pushback

Public Attributes

 it
 pushed_back

Detailed Description

Utility iterator that can deal with pushed back elements.

This behaves like a regular iterable, just that you can call
  iter.pushback(item)
to get the givem item as next item in the iteration.

Definition at line 122 of file utils.py.


Constructor & Destructor Documentation

def utils.pushback_iter.__init__ (   self,
  iterable 
)

Definition at line 129 of file utils.py.

00129 
00130   def __init__(self, iterable):
00131     self.it = iter(iterable)
00132     self.pushed_back = []


Member Function Documentation

Definition at line 133 of file utils.py.

00133 
00134   def __iter__(self):
00135     return self

Definition at line 136 of file utils.py.

00136 
00137   def __nonzero__(self):
00138     if self.pushed_back:
00139       return True
00140 
00141     try:
00142       self.pushed_back.insert(0, self.it.next())
00143     except StopIteration:
00144       return False
00145     else:
00146       return True

def utils.pushback_iter.next (   self)

Definition at line 147 of file utils.py.

00147 
00148   def next(self):
00149     if self.pushed_back:
00150       return self.pushed_back.pop()
00151     return self.it.next()

def utils.pushback_iter.pushback (   self,
  item 
)

Definition at line 152 of file utils.py.

00152 
00153   def pushback(self, item):
00154     self.pushed_back.append(item)

Member Data Documentation

Definition at line 130 of file utils.py.

Definition at line 131 of file utils.py.


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