Classes | |
class | TestIterators |
Functions | |
def | _findIterators |
def | addIterator |
def | emptyIterator |
def | iteratorForBeginEnd |
def | iteratorForSizedObjects |
def python::iterators::_findIterators | ( | obj | ) | [private] |
Definition at line 46 of file iterators.py.
00047 : 00048 objDict = obj.__dict__ 00049 _beginNames = [name for name in objDict.keys() if "begin" in 00050 name.lower()] 00051 _endNames = [name for name in objDict.keys() if "end" in name.lower()] 00052 if len(_beginNames)==1 and len(_endNames)== 1 and _beginNames[0].lower().replace("begin","") == _endNames[0].lower().replace("end",""): 00053 return objDict[_beginNames[0]], objDict[_endNames[0]] 00054 else: 00055 return False 00056 00057
def python::iterators::addIterator | ( | obj | ) |
function for adding iterators to objects
Definition at line 6 of file iterators.py.
00007 : 00008 """function for adding iterators to objects""" 00009 if not hasattr(obj, "__iter__"): 00010 if hasattr(obj, "size"): 00011 obj.__iter__ = iteratorForSizedObjects 00012 else: 00013 try: 00014 begin, end = _findIterators(obj) 00015 except: 00016 return obj 00017 if not hasattr(obj, "_begin") and hasattr(obj, "_end"): 00018 obj._begin = begin 00019 obj._end = end 00020 obj.__iter__ = iteratorForBeginEnd 00021 #else: 00022 # obj.__iter__ = EmptyIterator 00023 return obj 00024
def python::iterators::emptyIterator | ( | self | ) |
empty iterator
Definition at line 40 of file iterators.py.
def python::iterators::iteratorForBeginEnd | ( | self | ) |
dynamically added iterator
Definition at line 32 of file iterators.py.
def python::iterators::iteratorForSizedObjects | ( | self | ) |
dynamically added iterator
Definition at line 25 of file iterators.py.