
    	h                         S r SSKrSSKrSSKJr  SSKJr  SS jrS r " S S	5      r	 " S
 S\	5      r
\	\R                  SS4S jr " S S5      r\4S jr " S S5      rg)zGeneral Server side utilities    N   )policy)COMExceptionc                    Uc  [         R                  nUS:X  a$  SSKnUR                  R                  R
                  nUb  US:X  a	  U" U 5      n OU" X 5      n [        R                  " U 5      n Ub  U R                  U5      n U $ )zWraps an object in a PyGDispatch gateway.

Returns a client side PyI{iid} interface.

Interface and gateway support must exist for the specified IID, as
the QueryInterface() method is used.

Nr   r   )	r   DefaultPolicywin32com.server.dispatcherserver
dispatcherDefaultDebugDispatcher	pythoncom
WrapObjectQueryInterface)obiid	usePolicyuseDispatcherwin32coms        gC:\Users\julio\OneDrive\Documentos\Trabajo\Ideas Frescas\venv\Lib\site-packages\win32com/server/util.pywrapr   
   s     ((	) 22II 2r]9) 
		b	!B
s#I    c                     [         R                  " U 5      n [        U S5      (       a  U R                  n U R                  $ )zjUnwraps an interface.

Given an interface which wraps up a Gateway, return the object behind
the gateway.
r   )r   UnwrapObjecthasattrr   _obj_)r   s    r   unwrapr   %   s3     
			#Br8YY88Or   c                   f    \ rS rSrSr/ SQrS\R                  4S jrS r	S r
S rS	 rS
 rS rSrg)ListEnumerator2   aV  A class to expose a Python sequence as an EnumVARIANT.

Create an instance of this class passing a sequence (list, tuple, or
any sequence protocol supporting object) and it will automatically
support the EnumVARIANT interface for the object.

See also the @NewEnum@ function, which can be used to turn the
instance into an actual COM server.
)NextSkipResetCloner   c                 (    Xl         X l        X0l        g N)_list_index_iid_)selfdatar&   r   s       r   __init__ListEnumerator.__init__?   s    

r   c                 $    XR                   :X  a  gg )Nr   )r'   )r(   r   s     r   _query_interface_ ListEnumerator._query_interface_D   s    ** r   c                 t    U R                   U R                  U R                  U-    nU R                  U5        U$ r$   )r%   r&   r    r(   countresults      r   r   ListEnumerator.NextH   s0    TZZ$**u*<=		%r   c                     U R                   U-   nU[        U R                  5      :  a  [        U R                  5      nX l         g r$   )r&   lenr%   )r(   r1   ends      r   r    ListEnumerator.SkipM   s4    jj5 T[[!!dkk"C
r   c                     SU l         g Nr   )r&   r(   s    r   r!   ListEnumerator.ResetS   s	    
r   c                 l    U R                  U R                  U R                  U R                  5      5      $ r$   )_wrap	__class__r%   r&   r:   s    r   r"   ListEnumerator.CloneV   s$    zz$..djjABBr   c                     [        U5      $ r$   r   r(   r   s     r   r=   ListEnumerator._wrapY       Bxr   )r'   r%   r&   N)__name__
__module____qualname____firstlineno____doc___public_methods_r   IID_IEnumVARIANTr*   r-   r   r    r!   r"   r=   __static_attributes__ r   r   r   r   2   s>     :#$)*D*D 

Cr   r   c                       \ rS rSrSrS rSrg)ListEnumeratorGateway]   aR  A List Enumerator which wraps a sequence's items in gateways.

If a sequence contains items (objects) that have not been wrapped for
return through the COM layers, then a ListEnumeratorGateway can be
used to wrap those items before returning them (from the Next() method).

See also the @ListEnumerator@ class and the @NewEnum@ function.
c                     U R                   U R                  U R                  U-    nU R                  U5        [        U R                  U5      $ r$   )r%   r&   r    mapr=   r0   s      r   r   ListEnumeratorGateway.Nextg   s<    TZZ$**u*<=		%4::v&&r   rM   N)rE   rF   rG   rH   rI   r   rL   rM   r   r   rO   rO   ]   s    'r   rO   c                 "    U" XS9n[        XRX4S9$ )a  Creates a new enumerator COM server.

This function creates a new COM Server that implements the
IID_IEnumVARIANT interface.

A COM server that can enumerate the passed in sequence will be
created, then wrapped up for return through the COM framework.
Optionally, a custom COM server for enumeration can be passed
(the default is @ListEnumerator@), and the specific IEnum
interface can be specified.
)r   )r   r   rA   )seqclsr   r   r   r   s         r   NewEnumrW   m   s    $ 
S	B9JJr   c                   R    \ rS rSrSr/ SQrSS jrS r\rS r	S r
S	 rS
 rS rSrg)
Collection   zA collection of VARIANT values.)ItemCountAddRemoveInsertNc                 <    Uc  / nXl         U(       a
  SS/U l        g g )Nr[   r\   )r)   rJ   )r(   r)   readOnlys      r   r*   Collection.__init__   s(    <D	 %+W$5D! r   c                     [        U5      S:w  a  [        [        R                  S9e U R                  US      $ ! [
         a&  n[        [        R                  [        U5      S9eS nAff = f)Nr   scoder   re   desc)r5   r   winerrorDISP_E_BADPARAMCOUNTr)   
IndexErrorDISP_E_BADINDEXstr)r(   argsrg   s      r   r[   Collection.Item   s`    t9>X%B%BCC	O99T!W%% 	OX%=%=CINN	Os   : 
A*!A%%A*c                 ,    [        U R                  5      $ r$   )r5   r)   r:   s    r   r\   Collection.Count   s    499~r   c                 :    U R                   R                  U5        g r$   )r)   append)r(   values     r   r]   Collection.Add   s    		r   c                      U R                   U	 g ! [         a&  n[        [        R                  [        U5      S9eS nAff = f)Nrf   )r)   rj   r   rh   rk   rl   )r(   r&   rg   s      r   r^   Collection.Remove   s=    	O		%  	OX%=%=CINN	Os    
A !;A c                      [        U5      nU R                  R                  X5        g ! [        [        4 a    [        [        R
                  S9ef = f)Nrd   )int
ValueError	TypeErrorr   rh   DISP_E_TYPEMISMATCHr)   insert)r(   r&   rs   s      r   r_   Collection.Insert   sN    	CJE 			& I& 	CX%A%ABB	Cs	   ) (Ac                 ,    [        U R                  5      $ r$   )rW   r)   r:   s    r   _NewEnumCollection._NewEnum   s    tyy!!r   )rJ   r)   r9   )rE   rF   rG   rH   rI   rJ   r*   r[   _value_r\   r]   r^   r_   r   rL   rM   r   r   rY   rY      s7    %C6O G O'"r   rY   c                     [         R                  " [        R                  " U" U 5      5      [         R                  [         R                  5      $ )a{  Creates a new COM collection object

This function creates a new COM Server that implements the
common collection protocols, including enumeration. (_NewEnum)

A COM server that can enumerate the passed in sequence will be
created, then wrapped up for return through the COM framework.
Optionally, a custom COM server for enumeration can be passed
(the default is @Collection@).
)r   r   r   r   IID_IDispatch)rU   rV   s     r   NewCollectionr      s9     SX&	(?(?AXAX r   c                   `    \ rS rSr/ SQr\R                  /rS rS r	S r
S rS rS rS	 rS
rg)
FileStream   )ReadWriter"   CopyToSeekc                     Xl         g r$   file)r(   r   s     r   r*   FileStream.__init__   s    	r   c                 8    U R                   R                  U5      $ r$   )r   read)r(   amounts     r   r   FileStream.Read   s    yy~~f%%r   c                 N    U R                   R                  U5        [        U5      $ r$   )r   writer5   )r(   r)   s     r   r   FileStream.Write   s    		4yr   c                 V    U R                  U R                  U R                  5      5      $ r$   )r=   r>   r   r:   s    r   r"   FileStream.Clone   s    zz$..344r   c                 v    U R                   R                  U5      n[        U5      nUR                  U5        XD4$ r$   )r   r   r5   r   )r(   destcbr)   cbreads        r   r   FileStream.CopyTo   s1    yy~~b!T

4~r   c                 l    U R                   R                  X5        U R                   R                  5       $ r$   )r   seektell)r(   offsetorigins      r   r   FileStream.Seek   s#    		v&yy~~r   c                     [        U5      $ r$   rA   rB   s     r   r=   FileStream._wrap   rD   r   r   N)rE   rF   rG   rH   rJ   r   IID_IStream_com_interfaces_r*   r   r   r"   r   r   r=   rL   rM   r   r   r   r      s:    C!--.&5 
r   r   )NNN)rI   r   rh    r   	exceptionr   r   r   r   rO   rK   rW   rY   r   r   rM   r   r   <module>r      sn    #    #6
( (V'N '$ 	""K,2" 2"j &   r   