a „oeD:ã@sÔdZdZddlZddlZddlZddlZddlmZmZm Z m Z dZ dZ dd„Z dd „ZGd d „d e jƒZGd d „d eƒZdd„Zdddde dfdd„Zddd„Zdd„ZedkrÐeƒZerÆe e¡e d¡dS)zÍGenerate 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 -- Python 1.5 and earlier: Do NOT convert all Unicode objects to strings. Python 1.6 and later: 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Ú selecttlbz makepy.errorcCstj t¡t d¡dS)Né)ÚsysÚstderrÚwriteÚ usageHelpÚexit©r r ú7C:\Program Files\Certbot\pkgs\win32com\client\makepy.pyÚusageQs rcCs |srtjtjd}|durdSzt |j|j|j|j¡}Wn*tj ydt j   d|j¡d}Yn0||fg}nt |ƒ}|D]ˆ\}}|j}|dur¶|dur¨d|j}n| d¡d}t|ƒtd|j|j|j|jfƒtdƒtdƒtd |j|j|j|jfƒq~dS) N)Z excludeFlagsz1Warning - could not load registered typelib '%s' zéÿÿÿÿrz %s, lcid=%s, major=%s, minor=%szE >>> # Use these commands in Python code to auto generate .py supportz) >>> from win32com.client import gencachez, >>> gencache.EnsureModule('%s', %s, %s, %s))rÚ SelectTlbZ FLAG_HIDDENÚ pythoncomÚLoadRegTypeLibÚclsidÚmajorÚminorÚlcidÚ com_errorrrr ÚGetTypeLibsForSpecÚdescÚdllZGetDocumentationÚprint)ÚspecZtlbSpecÚtlbZinfosrr r r ÚShowInfoVsDÿÿ    ÿÿÿÿrc@sVeZdZdZdd„Zdd„Zdd„Zdd d „Zdd d „Zddd„Z dd„Z dd„Z dS)ÚSimpleProgressz3A simple progress class prints its output to stderrcCs ||_dS©N)Ú verboseLevel)Úselfr!r r r Ú__init__szSimpleProgress.__init__cCsdSr r ©r"r r r ÚClose‚szSimpleProgress.ClosecCs|jdkrtj d¡dS)NézGeneration complete.. ©r!rrr r$r r r ÚFinished…s zSimpleProgress.FinishedNcCs|jrtj |d¡dS©NÚ r'©r"rZmaxticksr r r ÚSetDescription‰szSimpleProgress.SetDescriptioncCsdSr r ©r"rr r r ÚTickszSimpleProgress.TickrcCs|j|krtj |d¡dSr)r')r"rr!r r r ÚVerboseProgresss zSimpleProgress.VerboseProgresscCs| d|d¡dS)NzGenerating to %sr&©r/)r"Úfilenamer r r ÚLogBeginGenerate”szSimpleProgress.LogBeginGeneratecCs| d|d¡dS)Nz WARNING: r&r0r-r r r Ú LogWarning—szSimpleProgress.LogWarning)N)N)r) Ú__name__Ú __module__Ú __qualname__Ú__doc__r#r%r(r,r.r/r2r3r r r r r|s   rc@s8eZdZdd„Zdd„Zdd„Zd dd „Zd d d „ZdS)Ú GUIProgresscCs&ddl}ddl}t ||¡d|_dS)Nr)ÚpywinÚwin32uirr#Údialog)r"r!r9r:r r r r#œs zGUIProgress.__init__cCs|jdur|j ¡d|_dSr )r;r%r$r r r r%¤s  zGUIProgress.ClosecCs@t ||¡|jdur0ddlm}| |¡|_n |j |¡dS)Nr)Ústatus)rÚStartingr;Z pywin.dialogsr<ZThreadedStatusProgressDialogZSetTitle)r"Ztlb_descr<r r r r=©s    zGUIProgress.StartingNcCs |j |¡|r|j |¡dSr )r;ÚSetTextZ SetMaxTicksr+r r r r,²s zGUIProgress.SetDescriptioncCs"|j ¡|dur|j |¡dSr )r;r.r>r-r r r r.·s zGUIProgress.Tick)N)N)r4r5r6r#r%r=r,r.r r r r r8›s  r8c Cs g}zNz:t |¡}t dddd¡}| ||¡| ||f¡Wn tjyNt |¡}t|ƒdkrÂzBt |ƒ}|j   ¡  ¡\}}t dddd¡}| |¡| |¡WntjyÀYn0t|ƒdkrÚt d|ƒ|D]j}|jdurt |j|j|j|j¡}n t |j¡}| ¡}|d|_|d|_|d|_| ||f¡qÞYn0|WStjyšt ¡\}} } tj d|| f¡d} t d¡Yn0dS)z˜Given 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.Nrz-Could not locate a type library matching '%s'éér&z+Unable to load type library from '%s' - %s )rÚ LoadTypeLibrÚ TypelibSpecÚ FromTypelibÚappendrZFindTlbsWithDescriptionÚlenrZ_oleobj_Z GetTypeInfoZGetContainingTypeLibrrrrrrrÚ GetLibAttrrÚexc_inforr r ) ÚargÚtypelibsrrZtlbsÚobÚindexÚattrÚtÚvÚtbr r r r½sJ        ÿ    rr&c Csð|dusJdƒ‚|durd}|r0|dur0tdƒ‚t|tƒr‚|\}}} } t || | |¡} t ||| | ¡} |  | t|ƒ¡| | fg} n t|tjƒrÊ|j dur²t |j |j |j |j ¡} n t |j ¡} | |fg} nXt|dƒr| ¡}|d}|d}|d} |d} t ||| | ¡} || fg} nt|ƒ} |dur4t|ƒ}|}|du}| D]œ\}}tj||j ||d}|dur`t |j |j |j |j ¡}tj t ¡|¡}|rBzt |d ¡WntjyÄYn0zt |d ¡WntjyîYn0zt |d ¡WntjyYn0tj |¡s2t |¡tj |d ¡}n|d }| |¡}|  |¡n|}d }z,| !||¡d}W|dur°| "|||¡n|dur®| "|||¡0t# $¡|rD| %d¡t &|j |j |j |j ¡qD| '¡dS)Nú#this is deprecated and will go awayrzPYou can only perform a demand-build when the output goes to the gen_py directoryrFr&r?r@)Ú bBuildHiddenz.pyz.pycz.pyoz __init__.pyFTúImporting module)(Ú RuntimeErrorÚ isinstanceÚtuplerrrrBrCÚstrrrrrrrAÚhasattrrFrrrÚ GeneratorrÚGetGeneratedFileNameÚosÚpathÚjoinÚGetGeneratePathÚunlinkÚerrorÚisdirÚmkdirZ open_writerr2ZgenerateZ finish_writerÚ importlibÚinvalidate_cachesr,ZAddModuleToCacher%)Ú typelibInfoÚfiler!ÚprogressInstanceÚbUnicodeToStringÚ bForDemandrQÚ typelibCLSIDrrrrrrIÚtlaZguidÚprogressZ bToGenDirÚtypelibÚinfoÚgenZ this_nameZ full_nameÚ outputNameZfileUseZworkedr r r ÚGenerateFromTypeLibSpecñs˜  ÿ     ü      ÿ     ÿ  rpcCsD|dusJdƒ‚|durd}t|ƒtdƒkrJ|\}}}}t ||||¡} n,|} | ¡} | d}| d}| d}| d}t ||||¡} |  | t|ƒ¡| | fg} |dur°t|ƒ}|} | D]~\}}t   |j |j |j |j¡}tj t  ¡|¡}|  |¡t ||j| ¡}| ||¡|  d¡t ¡td|d |ƒq¸|  ¡dS) NrPrr r&r?r@rRzwin32com.gen_py.Ú.)ÚtyperrrFrrBrCrVrrrYrrrrrZr[r\r]r2rrXrZgenerate_childr,rbrcÚ __import__r%)Úchildrdr!rfrgrirrrrrjrrIrkrlrmZdir_nameZ dir_path_namernr r r ÚGenerateChildFromTypeLibSpecWs>ÿ   ÿ   ruc Csddl}d}d}d}d}t}z°| tjdd…d¡\}}|D]Œ\}} |dkrRd}q<|dkr`| }q<|dkrr|d}q<|dkr„|d}q<|dkrºt|ƒdkr¢tdƒn|D] } t| ƒq¦d}q<|d kr<| }qs8.&"6ù gÿ )G