
    %
ih                       d dl mZ d dlZd dlmZ d dlZd dlZddlmZm	Z	 ej
        ej                 Zdddej        dfdZd#dZej        fdZej        fd	Zdddej        fd
Z	 	 	 	 	 d$dZ G d dej                  Zd%dZ G d d          Z e            Zd Z G d d          Zd Zd&dZd Zd Zd Zd Z  G d d          Z!d'dZ"d'dZ# G d d           Z$ G d! d"          Z%dS )(    )annotationsN)chain   )dynamicgencachec                J   |[	 |                                  }|'t          |                                d                   }n# t          j        t
          f$ r Y nw xY w|#ddlm}  |j        |          }| ||           S |t          }t          j        | ||||          S )z}
    Helper function to return a makepy generated class for a CLSID if it exists,
    otherwise cope by using CDispatch.
    Nr   r   r   clsctx)GetTypeInfostrGetTypeAttr	pythoncom	com_errorAttributeError r   GetClassForCLSID	CDispatchr   Dispatch)dispatchuserNameresultCLSIDtypeinfor   WrapperClassr   klasss           C:\Users\Dell Inspiron 16\Desktop\tws\AgrotaPowerBi\back-agrota-powerbi\mcp-client-agrota\venv\Lib\site-packages\win32com/client/__init__.py__WrapDispatchr      s     	++--H$!("6"6"8"8";<<#^4 	 	 	D	 *)+665??"  HhhvVVVVs   =A AAc                    |t           j        }| || |t          d          |t          ||          S t	          | |          S )a=  
    Mimic VB's GetObject() function.

    ob = GetObject(Class = "ProgID") or GetObject(Class = clsid) will
    connect to an already running instance of the COM object.

    ob = GetObject(r"c:\blah\blah\foo.xls") (aka the COM moniker syntax)
    will return a ready to use Python wrapping of the required COM object.

    Note: You must specifiy one or the other of these arguments. I know
    this isn't pretty, but it is what VB does. Blech. If you don't
    I'll throw ValueError at you. :)

    This will most likely throw pythoncom.com_error if anything fails.
    Nz=You must specify a value for Pathname or Class, but not both.)r   
CLSCTX_ALL
ValueErrorGetActiveObjectMoniker)PathnameClassr   s      r   	GetObjectr%   9   sc      ~%U]!2K
 
 	
 uf---x(((    c                    t          j        |           }t          j        |          }|                    t          j                  }t          || ||          S )zL
    Python friendly version of GetObject's ProgID/CLSID functionality.
    )r   r   )
pywintypesIIDr   r!   QueryInterfaceIID_IDispatchr   )r$   r   r   r   s       r   r!   r!   Y   sP     .''K(55H&&y'>??H(E{6RRRRr&   c                    t          j        |           \  }}}|                    |dt           j                  }t	          || |          S )zG
    Python friendly version of GetObject's moniker functionality.
    Nr
   )r   MkParseDisplayNameBindToObjectr+   r   )r#   r   monikeribindCtxr   s         r   r"   r"   c   sJ     $6x@@GQ##GT93JKKH(HV<<<<r&   c                \    t          j        | ||          \  } }t          | ||||          S )z$Creates a Dispatch based COM object.r
   )r   _GetGoodDispatchAndUserNamer   )r   r   r   r   r   s        r   r   r   l   s7     !<XxQWXXHh(Hk8FSSSSr&   c                    |t           j        }||t           j         z  }|d}n|f}|| }t          j        | d||t           j        f          d         }t          |||||          S )z:Creates a Dispatch based COM object on a specific machine.Nr   r
   )r   CLSCTX_SERVERCLSCTX_INPROCCoCreateInstanceExr+   r   )clsidmachiner   r   r   r   
serverInfor   s           r   
DispatchExr;   x   s     ~(y...F

Z
+tVZ)*A)C 	H HhXfMMMMr&   c                       e Zd ZdZddZd ZdS )r   z
    The dynamic class used as a last resort.
    The purpose of this overriding of dynamic.CDispatch is to perpetuate the policy
    of using the makepy generated wrapper Python class instead of dynamic.CDispatch
    if/when possible.
    Nc                $    t          |||          S N)r   )selfobr   returnCLSIDs       r   _wrap_dispatch_zCDispatch._wrap_dispatch_   s    Hk222r&   c                @    t           j                            |           S r>   )r   r   __dir__r?   s    r   rD   zCDispatch.__dir__   s     ((...r&   NN)__name__
__module____qualname____doc__rB   rD    r&   r   r   r      sA         3 3 3 3/ / / / /r&   r   c           	        d}|rt          j        |j        |j        t	          |j        d          t	          |j        d                    }t          ||          st          d| d|j	                  nt          |d          rd| j
        j        vrt          j        |           } d| j
        j        vrt          d          | j        }t          j        |          }t          j        |j        |j        |j        |j                  }|j                            |          }|t          d| d| d	          t          j        |          }|,t+          ||          }t+          |d
|          } ||           S t          )z('Cast' a COM object to another interfaceN   zThe interface name 'z+' does not appear in the specified library indexCLSIDz-Must be a makepy-able object for this to workz1' does not appear in the same library as object ''default_interface)r   MakeModuleForTypelibr8   lcidintmajorminorhasattrr    ver_desc	__class____dict__EnsureDispatchrO   GetModuleForCLSIDGetModuleForTypelibLCIDMajorVersionMinorVersionNamesToIIDMapgetgetattr)r@   targettypelibmodr8   target_clsidtarget_classs          r   CastTori      s    C+M7<W]B)?)?W]TVAWAW
 
 sF## 	:v : :%,%5: :  	 
	!	! 7",///(,,B",///LMMM (//*Isx!133C
 
 (,,V443v 3 3+-3 3 3   (66
sF++|-@,OO|B
r&   c                      e Zd ZdZd Zd ZdS )	Constantsz(A container for generated COM constants.c                    g | _         d S r>   )	__dicts__rE   s    r   __init__zConstants.__init__   s    r&   c                P    | j         D ]}||v r
||         c S t          |          r>   )rm   r   )r?   ads      r   __getattr__zConstants.__getattr__   s<     	 	AAvvt Qr&   N)rG   rH   rI   rJ   rn   rr   rK   r&   r   rk   rk      s8        22           r&   rk   c                    	 | j         j        d                             | ||           d S # t          $ r || j        |<   Y d S w xY wNr   )rY   	__bases____setattr__r   rZ   r?   attrvals      r   _event_setattr_rz      s_    " #//dC@@@@@ " " "!d"s   '+ AAc                  &    e Zd Zd Zd Zd Zd ZdS )EventsProxyc                    || j         d<   d S )N_obj_rZ   )r?   r@   s     r   rn   zEventsProxy.__init__   s    !#gr&   c                f    	 | j                                          d S # t          j        $ r Y d S w xY wr>   )r~   closer   r   rE   s    r   __del__zEventsProxy.__del__   sH    	 J" 	 	 	DD	s    00c                ,    t          | j        |          S r>   )rc   r~   )r?   rx   s     r   rr   zEventsProxy.__getattr__  s    tz4(((r&   c                2    t          | j        ||           d S r>   )setattrr~   rw   s      r   rv   zEventsProxy.__setattr__  s    
D#&&&&&r&   N)rG   rH   rI   rn   r   rr   rv   rK   r&   r   r|   r|      sP        $ $ $  ) ) )' ' ' ' 'r&   r|   c                   t          |           }|j        j                            d          r|j        }nd}	 |j                                        }|                                d         }|                                \  }}|                                }t          j
        |d         |d         |d         |d         d           t          j        t          |                    }n'# t          j        $ r}	t          |          |	d }	~	ww xY w|t          |          |j        }
t#          |
          }|t%          d          |||fS )	NrO   z`This COM object can not automate the makepy process - please run makepy manually for this objectr   r         )bValidateFilez(This COM object does not support events.)r   rY   rZ   rb   _oleobj_r   r   GetContainingTypeLib
GetLibAttrr   EnsureModuleGetClassForProgIDr   r   r   	TypeErrorrO   	geteventsr    )r   disp
disp_class	error_msgti
disp_clsidtlbrN   tlaerrorr8   events_classs               r   __get_disp_and_event_classesr     sS   HD~""7++ '^

 w			2**,,B))!,J0022JC..""C!#a&#a&#a&#a&PQRRRR!3C
OODDJJ" 	2 	2 	2I&&E1	2 I&&& E U##LCDDD\))s   B0C+ +D:D

Dreturnc                   t          |           \  }}}t          d|||fdt          i          } ||j                  }|                    ||           t          |d          r|                    |           t          |          S )a  Create a COM object that can fire events to a user defined class.
    clsid -- The ProgID or CLSID of the object to create.
    user_event_class -- A Python class object that responds to the events.

    This requires makepy support for the COM object being created.  If
    this support does not exist it will be automatically generated by
    this function.  If the object does not support makepy, a TypeError
    exception will be raised.

    The result is a class instance that both represents the COM object
    and handles events from the COM object.

    It is important to note that the returned instance is not a direct
    instance of the user_event_class, but an instance of a temporary
    class object that derives from three classes:
    * The makepy generated class for the COM object
    * The makepy generated class for the COM events
    * The user_event_class as passed to this function.

    If this is not suitable, see the getevents function for an alternative
    technique of handling events.

    Object Lifetimes:  Whenever the object returned from this function is
    cleaned-up by Python, the events will be disconnected from
    the COM object.  This is almost always what should happen,
    but see the documentation for getevents() for more details.

    Example:

    >>> class IEEvents:
    ...    def OnVisible(self, visible):
    ...       print("Visible changed:", visible)
    ...
    >>> ie = DispatchWithEvents("InternetExplorer.Application", IEEvents)
    >>> ie.Visible = 1
    Visible changed: 1
    COMEventClassrv   rn   )r   typerz   r   rn   rW   r|   )r8   user_event_classr   r   r   result_classinstances          r   DispatchWithEventsr   ,  s    L &B%%H%H"D*l	\#34	( L |DM**H(H---,, ,!!(+++x   r&   c                    t          |           \  } }}t          d||fi           } ||           }t          |d          r|                    |           |S )a  Similar to DispatchWithEvents - except that the returned
    object is *not* also usable as the original Dispatch object - that is
    the returned object is not dispatchable.

    The difference is best summarised by example.

    >>> class IEEvents:
    ...    def OnVisible(self, visible):
    ...       print("Visible changed:", visible)
    ...
    >>> ie = Dispatch("InternetExplorer.Application")
    >>> ie_events = WithEvents(ie, IEEvents)
    >>> ie.Visible = 1
    Visible changed: 1

    Compare with the code sample for DispatchWithEvents, where you get a
    single object that is both the interface and the event handler.  Note that
    the event handler instance will *not* be able to use 'self.' to refer to
    IE's methods and properties.

    This is mainly useful where using DispatchWithEvents causes
    circular reference problems that the simple proxy doesn't deal with
    r   rn   )r   r   rW   rn   )r   r   r   r   r   r   s         r   
WithEventsr   `  st    0 &B$%G%G"D*l	'(
 L |D!!H,, ,!!(+++Or&   c                    t          t          j        |                     } t          j        |           }	 |j        S # t          $ r4 	 t          j        |j                  j        cY S # t          $ r Y Y dS w xY ww xY w)a?  Determine the default outgoing interface for a class, given
    either a clsid or progid. It returns a class - you can
    conveniently derive your own handler from this class and implement
    the appropriate methods.

    This method relies on the classes produced by makepy. You must use
    either makepy or the gencache module to ensure that the
    appropriate support classes have been generated for the com server
    that you will be handling events from.

    Beware of COM circular references.  When the Events class is connected
    to the COM object, the COM object itself keeps a reference to the Python
    events class.  Thus, neither the Events instance or the COM object will
    ever die by themselves.  The 'close' method on the events instance
    must be called to break this chain and allow standard Python collection
    rules to manage object lifetimes.  Note that DispatchWithEvents() does
    work around this problem by the use of a proxy object, but if you use
    the getevents() function yourself, you must make your own arrangements
    to manage this circular reference issue.

    Beware of creating Python circular references: this will happen if your
    handler has a reference to an object that has a reference back to
    the event source. Call the 'close' method to break the chain.

    Example:

    >>>win32com.client.gencache.EnsureModule('{EAB22AC0-30C1-11CF-A7EB-0000C05BAE0B}',0,1,1)
    <module 'win32com.gen_py.....
    >>>
    >>> class InternetExplorerEvents(win32com.client.getevents("InternetExplorer.Application.1")):
    ...    def OnVisible(self, Visible):
    ...        print("Visibility changed: ", Visible)
    ...
    >>>
    >>> ie=win32com.client.Dispatch("InternetExplorer.Application.1")
    >>> events=InternetExplorerEvents(ie)
    >>> ie.Visible=1
    Visibility changed:  1
    >>>
    N)r   r(   r)   r   r   default_sourcer   coclass_clsid)r8   r   s     r   r   r     s    V 
u%%&&E%e,,E##   	,U-@AAPPPP 	 	 	444		s-   > 
A<	A)&A<)
A83A<7A88A<c                r   ddl m}  |j        |          }t          j        |j        j                 } |j        |j        |j	        |j
        |j                  }	 |j        |          }n$# t          $ r t          d|  d| d          w xY wt          j        |j        |j
        |j        |j	        |          S )a9  Creates a new record object, given the name of the record,
    and an object from the same type library.

    Example usage would be:
      app = win32com.client.Dispatch("Some.Application")
      point = win32com.client.Record("SomeAppPoint", app)
      point.x = 0
      point.y = 0
      app.MoveTo(point)
    r   r	   zThe structure 'z' is not defined in module 'rP   )r   r   r[   sysmodulesrY   rH   r]   rO   r^   r_   r`   	RecordMapKeyErrorr    r   GetRecordFromGuids)nameobjectr   modulepackagestruct_guids         r   Recordr     s     $X$V,,F[)45F +h*fk6#68K GY'- Y Y YW4WWWWWWXXXY'f)6+>[  s   A) )!B
c                :   t          | t          j                  st          d          	 | j        }| j        }| j        }| j        }| j        }n+# t          $ r}t          d| j
         d          |d}~ww xY w	 t          j        |||||          }n+# t          $ r}t          d| j
         d          |d}~ww xY w| j        t          j        v r5t          d| j         dt          j        | j                 j
         d          | t          j        | j        <   dS )a  
    Register a subclass of com_record to enable creation of the represented record objects.

    A subclass of com_record requires the following class attributes to be instantiable:

        TLBID : The GUID of the containing TypeLibrary as a string.
        MJVER : The major version number of the TypeLibrary as an integer.
        MNVER : The minor version number of the TypeLibrary as an integer.
        LCID  : The LCID of the TypeLibrary as an integer.
        GUID  : The GUID of the COM Record as a string.

    with GUID strings in {xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx} notation.

    To instantiate such a subclasses it has to be registered via this function.
    z2Only subclasses of 'com_record' can be registered.zClass z cannot be instantiated.NzRecord class with same GUID z" is already registered with name 'z'.)
issubclassr   
com_recordr   TLBIDMJVERMNVERr^   GUIDr   rG   r   	ExceptionRecordClassesr    )clsr   r   r   r^   r   e_s           r   register_record_classr     sj     c9/00 NLMMMU			xx U U ULclLLLMMSTTUP(udDII P P PGGGGHHaOP x9***_38 _ _090G0Q0Z_ _ _
 
 	
 ),ICH%%%s/   #A 
A7A22A7;B 
B<B77B<c                  P    e Zd ZddZd Zd Zd Zd Zd Zd Z	d	 Z
dd
ZddZdS )DispatchBaseClassNc                v   |t          j        | j                  }nt          |t          t
          f          rv	 t          |t                    r|j        n|}|                    | j        t           j                  }n1# t           j	        $ r}dd l
}|j        |j        k    r Y d }~nd }~ww xY w|| j        d<   d S )Nr   r   )r   newrO   
isinstancer   _PyIDispatchTyper   r*   r+   r   winerrorhresultE_NOINTERFACErZ   )r?   oobjdetailsr   s       r   rn   zDispatchBaseClass.__init__  s    <=,,DD02BCDD 	
(249J(K(KUt}}QU**4:y7NOO&   
 ?h&<<< =<<<< %)j!!!s   AA> >B,B''B,c                   t          | j        t          | j                  | j        | j                  }	 t          |d | j        D                       }n# t          $ r Y nw xY wt          t          |                    S )Nc                    g | ]	}|j         
S rK   )Name).0ps     r   
<listcomp>z-DispatchBaseClass.__dir__.<locals>.<listcomp>'  s    +M+M+MqAF+M+M+Mr&   )
r   rZ   dirrY   _prop_map_get__prop_map_put_Properties_r   listset)r?   
attributess     r   rD   zDispatchBaseClass.__dir__  s    M	
 

	z+M+MD<L+M+M+MNNJJ 	 	 	D	C
OO$$$s   A 
A"!A"c                   	 t           j        | j        j                 j        }|rd|z   }n!t           j        | j        j                 j        }n# t          $ r d}Y nw xY wd| d| j        j         dt          |            dS )Nzwin32com.gen_py.zwin32com.gen_py.unknown<.z instance at 0x>)r   r   rY   rH   rJ   rG   r   id)r?   mod_docmod_names      r   __repr__zDispatchBaseClass.__repr__-  s    	1k$.";<DG K-7;t~'@AJ 	1 	1 	10HHH	1Q8QQdn5QQbhhQQQQs   A
A AAc                :    t          |d|          }| j        |k    S Nr   rc   r   r?   others     r   __eq__zDispatchBaseClass.__eq__:       z511}%%r&   c                :    t          |d|          }| j        |k    S r   r   r   s     r   __ne__zDispatchBaseClass.__ne__>  r   r&   c           	     Z    |                       | j        j        |d|||g|R  ||          S rt   )_get_good_object_r   InvokeTypes)r?   dispidwFlagsretTypeargTypesuserr   argss           r   _ApplyTypes_zDispatchBaseClass._ApplyTypes_B  sB    %%%DM%fa(RTRRR
 
 	
r&   c                z    | j                             |          }|t          d| d| d           | j        | S NrP   z' object has no attribute ')r   rb   r   r   )r?   rx   r   s      r   rr   zDispatchBaseClass.__getattr__I  sO    "&&t,,< !OT!O!O!O!O!OPPP t $''r&   c                    || j         v r|| j         |<   d S 	 | j        |         \  }}n$# t          $ r t          d| d| d          w xY w | j        j        ||fz   |z     d S r   )rZ   r   r   r   r   Invoke)r?   rx   valuer   defArgss        r   rv   zDispatchBaseClass.__setattr__O  s    4=  "'DM$F	Q /5MD'' 	Q 	Q 	Q !OT!O!O!O!O!OPPP	Qtuh8::::s	   ( !A	c                $    t          |||          S r>   )_get_good_single_object_r?   obj
obUserNamer   s       r   r   z*DispatchBaseClass._get_good_single_object_Y  s    'ZEEEr&   c                $    t          |||          S r>   )r   r   s       r   r   z#DispatchBaseClass._get_good_object_\  s     j+>>>r&   r>   rF   )rG   rH   rI   rn   rD   r   r   r   r   rr   rv   r   r   rK   r&   r   r   r     s        ) ) ) )$% % %
R 
R 
R& & && & &
 
 
( ( (; ; ;F F F F? ? ? ? ? ?r&   r   c                R    t          | t                    rt          | ||          S | S r>   )r   r   r   )r   r   r   s      r   r   r   a  s,    #'(( 6Z555Jr&   c                    | d S t          | t                    rJ|ft          |           z  }|ft          |           z  }t          t          t          | ||                    S t          | ||          S r>   )r   tuplelenmapr   r   )r   r   r   obUserNameTupleresultCLSIDTuples        r   r   r   g  st    
{t	C		 F%-#c((2'>CHH4S*CBRSSTTT'ZEEEr&   c                  L    e Zd ZddZd Zd Zd Zd Zd Zd Z	d	 Z
d
 Zd ZdS )CoClassBaseClassNc                v    |t          j        | j                  }|                     |          | j        d<   d S N	_dispobj_)r   r   rO   rQ   rZ   )r?   r   s     r   rn   zCoClassBaseClass.__init__s  s8    <=,,D%)%;%;D%A%Ak"""r&   c                2    dt            d| j        j         dS )Nz<win32com.gen_py.r   r   )rJ   rY   rG   rE   s    r   r   zCoClassBaseClass.__repr__x  s     G7GGT^-DGGGGr&   c                ^    | j         d         }|t          ||          S t          |          r
  )rZ   rc   r   )r?   rx   rq   s      r   rr   zCoClassBaseClass.__getattr__{  s1    M+&=1d###T"""r&   c                    || j         v r|| j         |<   d S 	 | j         d         }||                    ||           d S n# t          $ r Y nw xY w|| j         |<   d S r
  )rZ   rv   r   )r?   rx   r   rq   s       r   rv   zCoClassBaseClass.__setattr__  s    4=  "'DM$F	k*A}dE***   	 	 	D	#ds   %? 
AAc                (     | j         d         |i |S r
  r   )r?   r   kwargss      r   __call__zCoClassBaseClass.__call__  s    )t}[)4:6:::r&   c                6    t          | j        d                   S r
  )r   rZ   r?   r   s     r   __str__zCoClassBaseClass.__str__      4=-...r&   c                6    t          | j        d                   S r
  )rT   rZ   r  s     r   __int__zCoClassBaseClass.__int__  r  r&   c                6    t          | j        d                   S r
  )iterrZ   rE   s    r   __iter__zCoClassBaseClass.__iter__      DM+.///r&   c                6    t          | j        d                   S r
  )r  rZ   rE   s    r   __len__zCoClassBaseClass.__len__  r  r&   c                6    t          | j        d                   S r
  )boolrZ   rE   s    r   __bool__zCoClassBaseClass.__bool__  r  r&   r>   )rG   rH   rI   rn   r   rr   rv   r  r  r  r  r  r   rK   r&   r   r  r  r  s        B B B B
H H H# # #$ $ $&; ; ;/ / // / /0 0 0/ / /0 0 0 0 0r&   r  c                  F    e Zd Zd Zd Zd Zd Z eeee          Zd Z	dS )VARIANTc                "    || _         || _        d S r>   varianttype_value)r?   vtr   s      r   rn   zVARIANT.__init__  s    r&   c                    | j         S r>   r&  rE   s    r   
_get_valuezVARIANT._get_value  s
    {r&   c                .    t          |          | _        d S r>   )r   r&  )r?   newvals     r   
_set_valuezVARIANT._set_value  s    '//r&   c                
    | ` d S r>   r)  rE   s    r   
_del_valuezVARIANT._del_value  s    KKKr&   c                (    d| j         d| j        dS )Nzwin32com.client.VARIANT(z, )r$  rE   s    r   r   zVARIANT.__repr__  s     P$*:PPPPPPr&   N)
rG   rH   rI   rn   r*  r-  r/  propertyr   r   rK   r&   r   r"  r"    sy            0 0 0   HZZ88EQ Q Q Q Qr&   r"  )NNN)NNNNNr>   )r   r|   rF   )&
__future__r   r   	itertoolsr   r   r(   r   r   r   TypeIIDsr+   r   r5   r   r%   r   r!   r"   r   r;   r   ri   rk   	constantsrz   r|   r   r   r   r   r   r   r   r   r   r  r"  rK   r&   r   <module>r7     s   # " " " " " 



                      %i&=> 
 "!W !W !W !WH) ) ) )@ #,"6 S S S S '1 = = = = "	T 	T 	T 	T N N N N8/ / / / /! / / /1 1 1 1h
  
  
  
  
  
  
  
  IKK	
" " "' ' ' ' ' ' ' '&* * *B1! 1! 1! 1!h" " "J5 5 5r  D%, %, %,VR? R? R? R? R? R? R? R?l   F F F F20 20 20 20 20 20 20 20tQ Q Q Q Q Q Q Q Q Qr&   