a oe @sbdZddlZddlmZmZejejZd ddZGdddZ Gdd d e Z Gd d d Z dS) zGeneral client side utilities. This module contains utility functions, used primarily by advanced COM programmers, or other COM modules. N)Dispatch_get_good_object_cCs*t|tjtjkr |tj}t||S)zWrap an object in a VARIANT enumerator. All VT_DISPATCHs returned by the enumerator are converted to wrapper objects (which may be either a class instance, or a dynamic.Dispatch type object). )type pythoncomTypeIIDsIID_IEnumVARIANTQueryInterface EnumVARIANT)ob resultCLSIDr 5C:\Program Files\Certbot\pkgs\win32com\client\util.pyWrapEnum s rc@sReZdZdZddZddZddZdd Zdd d Zd dZ ddZ ddZ dS) EnumeratoraA class that provides indexed access into an Enumerator By wrapping a PyIEnum* object in this class, you can perform natural looping and indexing into the Enumerator. Looping is very efficient, but it should be noted that although random access is supported, the underlying object is still an enumerator, so this will force many reset-and-seek operations to find the requested index. cCs||_d|_dS)N)_oleobj_index)selfenumr r r __init__$szEnumerator.__init__cCs ||SN_Enumerator__GetIndexrrr r r __getitem__(szEnumerator.__getitem__cCs ||Srrrr r r __call__+szEnumerator.__call__cCstt|tdkrtd||jdkr@|j|r@|j|||_|jd}t|rh||dSt ddS)Nrz2Only integer indexes are supported for enumeratorszlist index out of range) r TypeErrorrrResetZSkipNextlen _make_retval_ IndexError)rrresultr r r Z __GetIndex.s  zEnumerator.__GetIndexrcCs2|j|}g}|D]}|||qt|Sr)rrappendr!tuple)rcountretZrealRetsrr r r rCs  zEnumerator.NextcCs |jSr)rrrr r r rJszEnumerator.ResetcCs||j|jSr) __class__rCloner r)r r r r+MszEnumerator.ClonecCs|Srr rr#r r r r!PszEnumerator._make_retval_N)r) __name__ __module__ __qualname____doc__rrrrrrr+r!r r r r rs  rc@seZdZdddZddZdS)r NcCs||_t||dSr)r rrrrr r r r rUszEnumVARIANT.__init__cCst||jdSN)r )rr r,r r r r!YszEnumVARIANT._make_retval_)N)r-r.r/rr!r r r r r Ts r c@s&eZdZdddZddZddZdS) IteratorNcCs||_t|tj|_dSr)r iterrrr_iter_r1r r r r^szIterator.__init__cCs|Srr r)r r r __iter__bszIterator.__iter__cCstt|j|jdSr2)rnextr5r r)r r r __next__eszIterator.__next__)N)r-r.r/rr6r8r r r r r3]s r3)N) r0rZwin32com.clientrrrZ IID_IDispatchZPyIDispatchTyperrr r3r r r r s  <