[pywin32-checkins] pywin32/com/win32com/client util.py,1.1,1.2
OLD project page for the Python extensions for Windows
Brought to you by:
mhammond
From: <mha...@us...> - 2003-10-23 07:34:07
|
Update of /cvsroot/pywin32/pywin32/com/win32com/client In directory sc8-pr-cvs1:/tmp/cvs-serv29566 Modified Files: util.py Log Message: Add an Iterator class, which is used whenever Python wants an Iterator (the Enumerator is still used when Python tried indexed access) Index: util.py =================================================================== RCS file: /cvsroot/pywin32/pywin32/com/win32com/client/util.py,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** util.py 1 Sep 1999 22:58:56 -0000 1.1 --- util.py 23 Oct 2003 07:14:19 -0000 1.2 *************** *** 5,9 **** """ import pythoncom ! from win32com.client import Dispatch PyIDispatchType = pythoncom.TypeIIDs[pythoncom.IID_IDispatch] --- 5,9 ---- """ import pythoncom ! from win32com.client import Dispatch, _get_good_object_ PyIDispatchType = pythoncom.TypeIIDs[pythoncom.IID_IDispatch] *************** *** 57,61 **** def Next(self, count=1): ret = self._oleobj_.Next(count) - if ret is None: return None realRets = [] for r in ret: --- 57,60 ---- *************** *** 74,79 **** Enumerator.__init__(self, enum) def _make_retval_(self, result): ! if type(result)==PyIDispatchType: ! result = Dispatch(result, resultCLSID = self.resultCLSID) ! return result --- 73,83 ---- Enumerator.__init__(self, enum) def _make_retval_(self, result): ! return _get_good_object_(result, resultCLSID = self.resultCLSID) + class Iterator: + def __init__(self, enum): + self._iter_ = iter(enum.QueryInterface(pythoncom.IID_IEnumVARIANT)) + def __iter__(self): + return self + def next(self): + return _get_good_object_(self._iter_.next()) |