
    	hr:                     2   S r SrSSKrSSKrSSKrSSKrSSKJrJrJ	r	J
r
  SrS rS r " S S\	R                  5      r " S	 S
\5      rS rSSS\S4S jr SS jrS r\S:X  a3  \" 5       r\(       a  \R.                  " \5        \R.                  " S5        gg)zGenerate a .py file from an OLE TypeLibrary file.


This module is concerned only with the actual writing of
a .py file.  It draws on the @build@ module, which builds
the knowledge of a COM interface.

a   
Usage:

  makepy.py [-i] [-v|q] [-h] [-u] [-o output_file] [-d] [typelib, ...]

  -i    -- Show information for the specified typelib.

  -v    -- Verbose output.

  -q    -- Quiet output.

  -h    -- Do not generate hidden methods.

  -u    -- Convert all Unicode objects to strings.

  -o    -- Create output in a specified output file.  If the path leading
           to the file does not exist, any missing directories will be
           created.
           NOTE: -o cannot be used with -d.  This will generate an error.

  -d    -- Generate the base code now and the class code on demand.
           Recommended for large type libraries.

  typelib -- A TLB, DLL, OCX or anything containing COM type information.
             If a typelib is not specified, a window containing a textbox
             will open from which you can select a registered type
             library.

Examples:

  makepy.py -d

    Presents a list of registered type libraries from which you can make
    a selection.

  makepy.py -d "Microsoft Excel 8.0 Object Library"

    Generate support for the type library with the specified description
    (in this case, the MS Excel object model).

    N)Dispatchgencachegenpy	selecttlbc                  v    [         R                  R                  [        5        [         R                  " S5        g )N   )sysstderrwrite	usageHelpexit     iC:\Users\julio\OneDrive\Documentos\Trabajo\Ideas Frescas\venv\Lib\site-packages\win32com/client/makepy.pyusager   M   s    JJYHHQKr   c           	      l   U (       dm  [         R                  " [         R                  S9nUc  g  [        R                  " UR
                  UR                  UR                  UR                  5      nX!4/nO[        U 5      nU H  u  p!UR                  nUc'  Uc  SUR                  -  nOUR!                  S5      S   n[#        U5        [#        SR%                  UR
                  UR                  UR                  UR                  5      5        [#        S5        [#        S5        [#        S	R%                  UR
                  UR                  UR                  UR                  5      5        M     g ! [        R                   a2    [        R                  R                  SUR
                  -  5        S n GNBf = f)
N)excludeFlagsz1Warning - could not load registered typelib '%s'
z<Could not load typelib %s>r   z  {}, lcid={}, major={}, minor={}zE >>> # Use these commands in Python code to auto generate .py supportz) >>> from win32com.client import gencachez, >>> gencache.EnsureModule('{}', {}, {}, {}))r   	SelectTlbFLAG_HIDDEN	pythoncomLoadRegTypeLibclsidmajorminorlcid	com_errorr	   r
   r   GetTypeLibsForSpecdescdllGetDocumentationprintformat)spectlbSpectlbinfosr   s        r   ShowInfor(   R   s^   %%93H3HI?	**w}}gmmW\\C  "4(||<{4D++B/2d.55w||W]]GMM	

 	UV9::AAw||W]]GMM	
  "" 	JJDV C		s   AE- -AF32F3c                   T    \ rS rSrSrS rS rS rSS jrSS jr	SS	 jr
S
 rS rSrg)SimpleProgressz   z3A simple progress class prints its output to stderrc                     Xl         g NverboseLevel)selfr/   s     r   __init__SimpleProgress.__init__}   s    (r   c                     g r-   r   r0   s    r   CloseSimpleProgress.Close       r   c                 d    U R                   S:  a   [        R                  R                  S5        g g )N   zGeneration complete..
r/   r	   r
   r   r4   s    r   FinishedSimpleProgress.Finished   s(    q JJ67 !r   Nc                 l    U R                   (       a#  [        R                  R                  US-   5        g g N
r:   r0   r   maxtickss      r   SetDescriptionSimpleProgress.SetDescription   s&    JJTD[) r   c                     g r-   r   r0   r   s     r   TickSimpleProgress.Tick   r7   r   c                 j    U R                   U:  a#  [        R                  R                  US-   5        g g r>   r:   )r0   r   r/   s      r   VerboseProgressSimpleProgress.VerboseProgress   s+    ,JJTD[) -r   c                 .    U R                  SU-  S5        g )NzGenerating to %sr9   rI   )r0   filenames     r   LogBeginGenerateSimpleProgress.LogBeginGenerate   s    /(:A>r   c                 .    U R                  SU-   S5        g )Nz	WARNING: r9   rL   rE   s     r   
LogWarningSimpleProgress.LogWarning   s    [4/3r   r.   r-   )r   )__name__
__module____qualname____firstlineno____doc__r1   r5   r;   rB   rF   rI   rN   rQ   __static_attributes__r   r   r   r*   r*   z   s-    =)8**?4r   r*   c                   :    \ rS rSrS rS rS rS	S jrS	S jrSr	g)
GUIProgress   c                 L    SS K nSS Kn[        R                  X5        S U l        g )Nr   )pywinwin32uir*   r1   dialog)r0   r/   r]   r^   s       r   r1   GUIProgress.__init__   s    3r   c                 b    U R                   b"  U R                   R                  5         S U l         g g r-   )r_   r5   r4   s    r   r5   GUIProgress.Close   s(    ;;"KKDK #r   c                     [         R                  X5        U R                  c  SSKJn  UR                  U5      U l        g U R                  R                  U5        g )Nr   )status)r*   Startingr_   pywin.dialogsrd   ThreadedStatusProgressDialogSetTitle)r0   tlb_descrd   s      r   re   GUIProgress.Starting   sA    /;;, ==hGDKKK  *r   Nc                     U R                   R                  U5        U(       a  U R                   R                  U5        g g r-   )r_   SetTextSetMaxTicksr@   s      r   rB   GUIProgress.SetDescription   s.    D!KK##H- r   c                 v    U R                   R                  5         Ub  U R                   R                  U5        g g r-   )r_   rF   rl   rE   s     r   rF   GUIProgress.Tick   s/    KK% r   )r_   r-   )
rS   rT   rU   rV   r1   r5   re   rB   rF   rX   r   r   r   rZ   rZ      s    
+.
&r   rZ   c                    / n  [         R                  " U 5      n[        R                  " SSSS5      nUR	                  X 5        UR                  X#45        U$ ! [         R                   Ga    [        R                  " U 5      n[        U5      S:X  a   [        U 5      nUR                  R                  5       R                  5       u  p&[        R                  " SSSS5      nUR	                  U5        UR                  U5        O! [         R                   a     Of = f[        U5      S:X  a  [        SU -  5        U H  nUR                  cB  [         R                  " UR                   UR"                  UR$                  UR&                  5      nO [         R                  " UR                  5      nUR)                  5       nUS   Ul        US   Ul        US   Ul        UR                  X#45        M      U$ f = f! [         R                   aY    [*        R,                  " 5       u  pn
[*        R.                  R1                  SU  SU	 S	35        Sn
[*        R2                  " S5         gf = f)
zGiven an argument on the command line (either a file name, library
description, or ProgID of an object) return a list of actual typelibs
to use.Nr   z-Could not locate a type library matching '%s'      r9   z"Unable to load type library from 'z' - r?   )r   LoadTypeLibr   TypelibSpecFromTypelibappendr   FindTlbsWithDescriptionlenr   _oleobj_GetTypeInfoGetContainingTypeLibr"   r    r   r   r   r   r   
GetLibAttrr	   exc_infor
   r   r   )argtypelibsr&   r$   tlbsobindexattrtvtbs              r   r   r      s    H,%	-'',C((q!Q7DS&OOSK(D C ""  	-44S9D4yA~!#B!#!8!8!:!O!O!QJC$00q!Q?D$$S)KK% ** 4yA~EMN 88##22

DJJ

DIIC $//9C ~~'!!W
!!W
 G	,! " C 	-D  <<>b

=cU$qcLM	sW   AA G; :G8A0DG8DG8DCG84G; 7G88G; ;A*I('I(r9   c           	         Uc  SnU(       a  Ub  [        S5      e[        U [        5      (       aS  U u  pgp[        R                  " XhX5      n
[
        R                  " XgX5      nUR                  U
[        U5      5        X4/nO[        U [
        R                  5      (       at  U R                  cB  [        R                  " U R                  U R                  U R                  U R                  5      n
O [        R                  " U R                  5      n
X4/nO\[        U S5      (       a@  U R!                  5       nUS   nUS   nUS   nUS   n	[
        R                  " XX5      nX4/nO[#        U 5      nUc  [%        U5      nUnUS L nU GH8  u  nn[&        R(                  " UUR                  XS9n[*        R,                  " UR                  UR                  UR                  UR                  5      nUGc  [.        R0                  R3                  [*        R4                  " 5       U5      nU(       a   [.        R6                  " US-   5         [.        R6                  " US	-   5         [.        R6                  " US
-   5        [.        R0                  R;                  U5      (       d  [.        R<                  " U5        [.        R0                  R3                  US5      nOUS-   nUR?                  U5      nURA                  U5        OUnSn URC                  UU5        SnUc3  [*        RD                  " U5         URG                  WUU5        S S S 5        O [H        RJ                  " 5         U(       d  GM  URM                  S5        [*        RN                  " UR                  UR                  UR                  UR                  5        GM;     URQ                  5         g ! [8         a     GNf = f! [8         a     GNf = f! [8         a     GNf = f! , (       d  f       N= f! UcD  [*        RD                  " U5         URG                  WUU5        S S S 5        f ! , (       d  f       f = ff = f)Nr   zPYou can only perform a demand-build when the output goes to the gen_py directoryr}   r9   rr   rs   )bBuildHiddenz.pyz.pycz.pyoz__init__.pyFTImporting module))RuntimeError
isinstancetupler   r   r   ru   rv   strr    r   r   r   r   rt   hasattrr}   r   r*   r   	Generatorr   GetGeneratedFileNameospathjoinGetGeneratePathunlinkOSErrorisdirmkdiropen_writerrN   generateModuleMutexfinish_writer	importlibinvalidate_cachesrB   AddModuleToCacher5   )typelibInfofiler/   progressInstance
bForDemandr   typelibCLSIDr   r   r   r&   r$   r   tlaguidprogress	bToGenDirtypelibinfogen	this_name	full_name
outputNamefileUseworkeds                            r   GenerateFromTypeLibSpecr      s    d&^
 	
 +u%%+6(E&&|EH$$\Fc,/0K=	K!6!6	7	7??"**!!!!!!  	C ''8C&'	l	+	+ $$&1v1vAA$$T> '(%k2),7HI!oogtxxU11JJ		4::tzz
	 <X%=%=%?KIIIi%/0IIi&01IIi&01 ww}}Y//HHY'WW\\)]C
&.
ooj1G%%j1G	CLL*-F|)))4%%j'6B 54  	##%9##$67%%djj$))TZZTW "Z NNC      $ 54 |)))4%%j'6B 544 sf   /O	O'#O8P1P	
O$#O$'
O54O58
PP	
P	Q#4Q		Q#
QQ#c                    Uc  Sn[        U[        5      (       a  Uu  pEpg[        R                  " XFXu5      nO&UnUR	                  5       n	U	S   nU	S   nU	S   nU	S   n[
        R                  " XEXg5      n
U
R                  U[        U5      5        X4/nUc  [        U5      nUnU GH  u  p[        R                  " UR                  UR                  UR                  UR                  5      n[         R"                  R%                  [        R&                  " 5       U5      nUR)                  U5        [*        R,                  " XR.                  U5      nUR1                  U U5        UR3                  S5        [4        R6                  " 5         [        R8                  " U5         [;        SU-   S-   U -   5        S S S 5        GM     UR=                  5         g ! , (       d  f       GM=  = f)Nr   r9   rr   rs   r   zwin32com.gen_py..)r   r   r   r   r}   r   ru   rv   r   r*   r   r   r   r   r   r   r   r   r   r   rN   r   r   r    generate_childrB   r   r   r   
__import__r5   )childr   r/   r   r   r   r   r   r&   r   r$   r   r   r   r   dir_namedir_path_namer   s                     r   GenerateChildFromTypeLibSpecr   U  s     	 +u%%+6(E&&|EH$$&1v1vAA  UBDS#l+,}H),7H!00JJ		4::tzz
 X%=%=%?J!!-0oogxx:5-0 23##%!!(+)H4s:UBC ,+ " NN ,+s    G
G#	c            	      N   SS K n SnS nSnSn[        n U R                  [        R                  SS  S5      u  pgU H{  u  pUS:X  a  SnM  US:X  a  U	nM  US:X  a  US-  nM&  US:X  a  US-  nM3  US:X  a3  [	        U5      S:X  a  [        S 5        OU H  n
[        U
5        M     SnMl  US	:X  d  Mt  U(       + nM}     U(       a,  Ub)  [        R                  R                  S5        [        5         U(       d  g[	        W5      S:X  a1  [        R                  " 5       nUc  [        R                  " S5        U/nUbk  [        R                  R!                  U5      nUS:w  a:  [        R                  R#                  U5      (       d  [        R$                  " U5        ['        USSS9nOS nU H  n
[)        U
UUUUS9  M     U(       a  UR+                  5         g g ! U R                   a@  n[        R                  R                  [        U5      S
-   5        [        5          S nAGNeS nAff = f)Nr   r9   zvo:huiqdz-hz-oz-vz-qz-iz-dr?   zCan not use -d and -o together
 wtmbcs)encoding)r/   r   r   )getoptbForDemandDefaultr	   argvry   r(   errorr
   r   r   r   r   r   r   r   r   dirnameexistsmakedirsopenr   close)r   
hiddenSpecr   r/   doitr   optsargsor   r   msgrcr   fs                  r   mainr   ~  s   JJLD"J]]388AB<<
DADy
d
d!d!dt9>TN#   $d!+^
# . j,

;<
4yA~  ":HHQKtwwz*2:bggnnT22KKTF3 %!#	
  			 	E << 

SD)s   BG /G H$$5HH$__main__)NN)rW   r   r   r   r	   r   win32com.clientr   r   r   r   r   r   r(   GeneratorProgressr*   rZ   r   r   r   r   rS   r   r   r   r   r   <module>r      s   )	V  	 
  @ @ 
%
P4U,, 4>&. &D1l 
 cN =A&R@F z	B	HHQK	 r   