a oe50@sddlZddlZddlZddlZdZdZdZdZddZdd Z d/d d Z d0d d Z ddZ d1ddZ ddZddZddZddZddZddZddZd d!Zd2d#d$Zd3d%d&Zd4d'd(Zd)d*Zd5d+d,Zd-d.ZdS)6NzRegistry utility errorz&{b51df050-06ae-11cf-ad3b-524153480001}z Python.FilezPython.CompiledFilecCs dtjS)zBuilds a string containing the path to the current registry key. The Python registry key contains the Python version. This function uses the version of the DLL used by the current process to get the registry key currently in use. zSoftware\Python\PythonCore\)syswinverrr2C:\Program Files\Certbot\pkgs\win32\lib\regutil.pyBuildDefaultPythonKeysrcCsDt}zttj|}|tjWStjy>tjYS0dS)z-Retrieves the Registry root in use by Python.N)rwin32api RegOpenKeywin32conHKEY_CURRENT_USERcloseerrorHKEY_LOCAL_MACHINE)Zkeynamekrrr GetRootKeysrcCs|durt}t||S)z?A helper to return the default value for a key in the registry.N)rr RegQueryValue)ZsubkeyrootkeyrrrGetRegistryDefaultValue&srcCsZ|durt}t|tkr"tj}n$t|tkr6tj}ntdt|t ||||dS)z;A helper to set the default value for a key in the registryNz-Value must be string or integer - was passed ) rtypestrr REG_SZint REG_DWORD TypeErrorreprr RegSetValue)ZsubKeyvaluerZtypeIdrrrSetRegistryDefaultValue-s  rcCsdS)Nz3Software\Microsoft\Windows\CurrentVersion\App PathsrrrrrGetAppPathsKey;srcCsB|r td|dur tj|}tttd|tj |dS)aRegister a .exe file that uses Python. Registers the .exe with the OS. This allows the specified .exe to be run from the command-line or start button without using the full path, and also to setup application specific path (ie, os.environ['PATH']). Currently the exeAppPath is not supported, so this function is general purpose, and not specific to Python at all. Later, exeAppPath may provide a reasonable default that is used. exeFullPath -- The full path to the .exe exeAlias = None -- An alias for the exe - if none, the base portion of the filename is used. exeAppPath -- Not supported. z,Do not support exeAppPath argument currentlyN\) r ospathbasenamerrrrr r)Z exeFullPathexeAliasZ exeAppPathrrrRegisterPythonExe?s r#cCstttd|S)zGet a registered .exer)rrrr)r"rrrGetRegisteredExeYsr$c Cs`ztttd|Wn>tjyZ}z$ddl}|j|jkrDWYd}~dSd}~00dS)z(Unregister a .exe file that uses Python.rrN)r RegDeleteKeyrrr winerrorERROR_FILE_NOT_FOUND)r"excr&rrrUnregisterPythonExe^s r)cCs2td}|r|d|}tt|tj|dS)z5Register a named path - ie, a named PythonPath entry. \PythonPathrN)rrrrr r)namer keyStrrrrRegisterNamedPathjs  r-c Csdtd|}ztt|Wn>tjy^}z$ddl}|j|jkrHWYd}~dSd}~00dS)z7Unregister a named path - ie, a named PythonPath entry.z \PythonPath\rN)rrr%rr r&r'r+r,r(r&rrrUnregisterNamedPathrs r/c Csntd}|r|d|}ztt|WStjyh}z$ddl}|j|jkrRWYd}~dSd}~00dS)z8Get a registered named path, or None if it doesnt exist.r*rrN)rrrrr r&r'r.rrrGetRegisteredNamedPaths   r0cCsZzddl}||Wn |jy6td|Yn0tttd|tj |dS)aPRegister an explicit module in the registry. This forces the Python import mechanism to locate this module directly, without a sys.path search. Thus a registered module need not appear in sys.path at all. modName -- The name of the module, as used by import. modPath -- The full path and file name of the module. rNz+Warning: Registering non-existant module %s \Modules\%s) rstatr printrrrrr r)modNameZmodPathrrrrRegisterModules r5c Cs^ztttd|Wn<tjyX}z"ddl}|j|jkrDWYd}~n d}~00dS)znUnregister an explicit module in the registry. modName -- The name of the module, as used by import. r1rN)rr%rrr r&r')r4r(r&rrrUnregisterModules r6c Cs`zttd|WStjyZzttd|tjWYStjyTYn0Yn0dS)z1Given a description, return the registered entry.z\Help\N)rrrr r r )helpDescrrrGetRegisteredHelpFiles   r8cCsl|dur |}tj||}z|r*t|WntjyHtdYn0ttt d|t j |dS)aRegister a help file in the registry. Note that this used to support writing to the Windows Help key, however this is no longer done, as it seems to be incompatible. helpFile -- the base name of the help file. helpPath -- the path to the help file helpDesc -- A description for the help file. If None, the helpFile param is used. bCheckFile -- A flag indicating if the file existence should be checked. NzHelp file does not exist\Help\%s) rr joinr2r ValueErrorrrrrr r)helpFileZhelpPathr7Z bCheckFileZ fullHelpFilerrrRegisterHelpFiles  r>c Csttjddtj}z\zt||Wn<tjyb}z"ddl}|j|jkrNWYd}~n d}~00Wt |n t |0|dur|}zt t t d|Wn<tjy}z"ddl}|j|jkr΂WYd}~n d}~00dS)zUnregister a help file in the registry. helpFile -- the base name of the help file. helpDesc -- A description for the help file. If None, the helpFile param is used. zSoftware\Microsoft\Windows\HelprNr:) rrr r KEY_ALL_ACCESSZRegDeleteValuer r&r' RegCloseKeyr%rr)r=r7keyr(r&rrrUnregisterHelpFiles0  rBc Cs|durttj}n0zt|Wn tjyDtd|Yn0tt t }z t |dt j |Wt|n t|0t t dt j tjdS)zRegisters the core DLL in the registry. If no params are passed, the name of the Python DLL used in the current process is used and registered. Nz-Warning: Registering non-existant core DLL %sZDllz)Software\Python\PythonCore\CurrentVersion)rZGetModuleFileNamer dllhandlerr2r r3Z RegCreateKeyrrrr rr@r)Z coredllNameZhKeyrrrRegisterCoreDLLs rDcCst}ttjdtj|ttj|tjdttjd|tjtttjd|tj|dt}ttj|dtjdttj|dtj|t}ttjd tj|ttj|tjd ttjd|tj|d|}ttj|dtjdttj|dtj|d S) aRegister the core Python file extensions. defPyIcon -- The default icon to use for .py files, in 'fname,offset' format. defPycIcon -- The default icon to use for .pyc files, in 'fname,offset' format. runCommand -- The command line to use for running .py files z.pyz Python Filez%s\CLSIDz%s\DefaultIcon%s\Shellz\OpenZRunz \Open\Commandz.pyczCompiled Python FileN)RegistryIDPyFilerrr HKEY_CLASSES_ROOTr CLSIDPyFileRegistryIDPycFile)Z defPyIconZ defPycIconZ runCommandZ pythonFileIdbaserrrRegisterFileExtensions!sn   rKcCsHdt}|r(ttj|d|tj|ttj|d|tj|dS)NrEz\%sz \%s\CommandrFrrr rGr) shellCommandZ exeCommandZshellUserCommandrJrrrRegisterShellCommandds  rNcCs`dt}ttj|d|tj|ttj|d|tj|ttj|d|tj|dS)NrEz \%s\ddeexecz\%s\ddeexec\Applicationz\%s\ddeexec\TopicrL)rMZddeAppZddeTopicZ ddeCommandrJrrrRegisterDDECommandzs&   rO)N)N)NN)Nr9)N)N)N)rrrr r rHrFrIrrrrrr#r$r)r-r/r0r5r6r8r>rBrDrKrNrOrrrrs6        % C