a „oeìOã@s¨Gdd„deƒZddlZdd„Zdd„Zdd „Zd d „Zd d „Zdd„Zdd„Z dd„Z dd„Z dd„Z dd„Z dPdd„Zdd„ZdQdd„Zd d!„ZdRd"d#„ZdSd$d%„Zd&d'„Zd(d)„Zd*ejdZd+Zd,Zed-kr¤eejƒd.krejd.d/vreeƒn eejƒd.ks(ejd.dd0vrôejdd…Zejd.d…D]Ze  e¡qDe  d1¡e  d2¡e  d3¡e  d4¡e  d5¡e  d6¡d7ej!vrªe  d8¡n e  d9¡ed:ƒeeƒeeƒed;ed<ƒed=ƒddl"Z"e" #¡n°gZ$ddl%Z%e% %ejd.d…d>gd?¢¡\Z&Z'e'D]Ze$  e¡q$e&D]f\Z(Z)e(d@krVeeƒe(dAkrheeƒe(dBkr‚edCƒee$ƒe(dDkr¢edEe)ƒee)de$ƒe(dFvrÈddl*Z*edGe)ƒe* +e)¡e(dHkrþddl*Z*dI ,e$¡ZedJe)dKeƒe* -e)e¡e(dLkr:ee$ƒsedMƒ‚ddl*Z*ddl.Z.e* /d¡ 0dI¡Z1ee1ƒZ2e$D]Z3e3e1vrFe1  e3¡qFee1ƒe2kr˜edNee1ƒe2ƒe* -ddI ,e1¡¡nedOƒq:dS)Tc@s eZdZdS)ÚerrorN)Ú__name__Ú __module__Ú __qualname__©rrú7C:\Program Files\Certbot\pkgs\win32\scripts\regsetup.pyrsréNc CsFddl}z| |¡WdS|jy@}zWYd}~dSd}~00dS)z/Check if a file exists. Returns true or false.rNé)ÚosÚstatr)Úfnamer ÚdetailsrrrÚ FileExists s  r cCs0ddl}|durd}t|j |j ||¡|¡ƒS)z~Given a path, a ni package name, and possibly a known file name in the root of the package, see if this path is good. rNÚ.)r r ÚpathÚjoin)rÚ packageNameÚ knownFileNamer rrrÚ IsPackageDirsrcCsddl}d|jjvrdSdS)zoReturn "_d" if we're running a debug version. This is to be used within DLL names when locating them. rNz_d.pydZ_dÚ)Úimportlib.machineryÚ machineryÚEXTENSION_SUFFIXES)Ú importlibrrrÚIsDebug!srcCspddl}ddl}| |¡}|r2t|||ƒr2|dfS|D](}t|||ƒr6|j |¡}||fSq6td|ƒ‚dS)zÀFind a package. Given a ni style package name, check the package is registered. First place looked is the registry for an existing entry. Then the searchPaths are searched. rNz!The package %s can not be located)r ÚregutilÚGetRegisteredNamedPathrrÚabspathr)rrÚ searchPathsr rÚpathLookÚretrrrÚFindPackagePath+s   r c Cs ddl}ddl}ddl}z†| |jdd|j¡}zbz@| ||¡d}t|j  ||¡ƒrn|j  |¡WW|  ¡WSWn|j y„Yn0W|  ¡n |  ¡0Wn|j y²Yn0|D]V}t|j  ||¡ƒrÞ|j  |¡S|j  |d¡}t|j  ||¡ƒr¸|j  |¡Sq¸t d|ƒ‚dS)NrzSoftware\Microsoft\Windows\HelpZHelpz#The help file %s can not be located) r Úwin32apiÚwin32conZ RegOpenKeyÚHKEY_LOCAL_MACHINEÚKEY_ALL_ACCESSZRegQueryValueExr rrrÚCloser) ÚhelpFileÚhelpDescrr r!r"ÚkeyrrrrrÚ FindHelpPathCs:üür)cCs†ddl}ddl}| |¡}|r,| d¡d}|rFt|j ||¡ƒrFdS|D]&}t|j ||¡ƒrJ|j |¡SqJtd||fƒ‚dS)z€Find an application. First place looked is the registry for an existing entry. Then the searchPaths are searched. rNú;z1The file %s can not be located for application %s) r rrÚsplitr rrrr)ÚappNamerrr rZregPathrrrrÚ FindAppPathes  ÿr-c CsÒddl}ddl}ddl}ddl}|dur,|}|j |j|¡}t|ƒsvd|jvrd|j |jdd|¡}n|j |jd|¡}t|ƒsˆt ||ƒ}d}z(|  |  ¡|  ¡d|¡} || k}Wn|j yÈYn0||fS)zùFind an exe. Returns the full path to the .exe, and a boolean indicating if the current registered entry is OK. We don't trust the already registered version even if it exists - it may be wrong (ie, for a different Python version) rNú64 bitÚPCBuildÚamd64ú\)r Úsysrr!rrÚprefixr ÚversionÚLocateFileNameZ RegQueryValueÚ GetRootKeyZGetAppPathsKeyr) ÚexeAliasZpossibleRealNamesrr r2rr!ÚfoundZ registered_okZ registeredrrrÚ FindPythonExes,  ÿ r9cCs8ddl}z| d¡d|WSty2|YS0dS)z6Given a filename, return a quoted version if necessaryrNú z"%s")rÚindexÚ ValueError)r rrrrÚQuotedFileName£s    r=c Cs ddl}ddl}| d¡}|D]T}|D]@}z"|j ||¡}| |¡WqhWq&|jydd}Yq&0q&|rqq|d}zddl}ddl} Wnt y®td|ƒ‚Yn0|j } |j  |¡d} d| | f} |   dd|| | d¡} |   d|¡|  ¡|jkr tdƒ‚|  ¡}|j |¡S) zÔLocate a file name, anywhere on the search path. If the file can not be located, prompt the user to find it for us (using a common OpenFile dialog) Raises KeyboardInterrupt if the user cancels. rNr*zNeed to locate the file %s, but the win32ui module is not available Please run the program again, passing as a parameter the path to this file.rz#Files of requested type (*%s)|*%s||zLocate zUser cancelled the process)r rr+rrr rr"Úwin32uiÚ ImportErrorZOFN_FILEMUSTEXISTÚsplitextZCreateFileDialogZ SetOFNTitleZDoModalZIDOKÚKeyboardInterruptZ GetPathNamer)ZfileNamesStringrr rZ fileNamesrÚfileNameZretPathr"r>ÚflagsÚextÚfilterZdlgrrrr5°s@      ÿÿ  r5cCs&ddl}|j |j t||ƒ¡d¡S)z2Like LocateFileName, but returns a directory only.rN)r rrr+r5)rBrr rrrÚ LocatePathÝsrFcCs&z t||ƒWSty YdS0dS)z6Like LocatePath, but returns None if the user cancels.N)rFrA©rBrrrrÚLocateOptionalPathäs  rHcCs&z t||ƒWSty YdS0dS)z:Like LocateFileName, but returns None if the user cancels.N)r5rArGrrrÚLocateOptionalFileNameìs  rIc Cs ddl}ddl}| d¡}|r*| d¡}n|j d¡g}d}|D]}t|j |d¡ƒr@|}q`q@|durz|durztd|ƒ}|durŠt dƒ‚d}t ƒ}|D]"}t|j |d|¡ƒr˜|}q¼q˜|durÚ|durÚtd||ƒ}|durêt dƒ‚|j |j |d ¡¡} | ||gfS) z¡Locate and validate the core Python directories. Returns a list of paths that should be used as the core (ie, un-named) portion of the Python path. rNr*rzos.pyz-The core Python library could not be located.zunicodedata%s.pydz*The core Python path could not be located.ú..) r rrr+rrr rrFrr) rr rZ currentPathZpresearchPathsZlibPathrZcorePathÚsuffixÚ installPathrrrÚLocatePythonCoreôs6   rMc Cs¼ddl}|stdƒ‚| d¡ d¡}|s,|}|p2|}z6t|||ƒ\}}|durf||vrZd}| ||¡|WSty¶}z4td||fƒtdƒtdƒtd ƒWYd}~n d}~00dS) afFind and Register a package. Assumes the core registry setup correctly. In addition, if the location located by the package is already in the **core** path, then an entry is registered, but no path. (no other paths are checked, as the application whose path was used may later be uninstalled. This should not happen with the core) rNzA package name must be suppliedr*rz/*** The %s package could not be registered - %szH*** Please ensure you have passed the correct paths on the command line.zL*** - For packages, you should pass a path to the packages parent directory,z-*** - and not the package directory itself...)rrrr+r ÚRegisterNamedPathÚprint) rÚ knownFilerZregistryAppNamerÚ corePathsrZpathAddr rrrÚFindRegisterPackages2   ÿÿÿrRc Cs’ddl}t|ƒtdƒkr|g}g}z(|D]}t|||ƒ}|r(| |¡q(Wn0tyz}ztd|ƒWYd}~dSd}~00| |d |¡¡dS)zRFind and Register a package. Assumes the core registry setup correctly. rNrú*** r*)rÚtyper-ÚappendrrOrNr)r,Z knownFilesrrÚpathsrPrr rrrÚFindRegisterAppBs  rWcCs,ddl}t|||ƒ\}}|s(| ||¡|S)zvFind and Register a Python exe (not necessarily *the* python.exe) Assumes the core registry setup correctly. rN)rr9ZRegisterPythonExe)r7rZactualFileNamesrr ÚokrrrÚFindRegisterPythonExeZs  rYc Cs\ddl}zt|||ƒ}Wn0tyH}ztd|ƒWYd}~dSd}~00| |||¡dS)NrrS)rr)rrOZRegisterHelpFile)r&rr'rrr rrrÚFindRegisterHelpFilehs rZc Cs,ddl}|D]}|j |¡q ddl}ddl}ddl}ddl}t|ƒ\}}t|ƒ|  dd  |¡¡|  |  ¡|  ¡¡} z | | d|j|¡W| | ¡n | | ¡0|j |j |j¡d¡d|j |j td|jƒ¡d¡} |j  |jd¡} d|jvr|j  | d¡} |j | ¡r(|  d| ¡dS) a Setup the core Python information in the registry. This function makes no assumptions about the current state of sys.path. After this function has completed, you should have access to the standard Python library, and the standard Win32 extensions rNr*Z InstallPathzwin32con.py;win32con.pycr/r.r0)r2rrUr rr!r"rMrOrNrZ RegCreateKeyr6ZBuildDefaultPythonKeyZ RegSetValueÚREG_SZZ RegCloseKeyrr+Ú__file__r5r3r4Úisdir) rr2rr rr!r"rLrQZhKeyZ win32pathsÚcheckrrrÚ SetupCorets6  ÿÿþÿ  r_cCszddl}ddl}tƒ}td||ƒ}| dd|j¡| dt|ƒdd¡| d d ||j¡td |d ƒtd |d ƒdS)z¿Registers key parts of the Python installation with the Windows Shell. Assumes a valid, minimal Python installation exists (ie, SetupCore() has been previously successfully run) rNz Python%s.exez.pyz Python.FileZOpenz "%1" %*z&RunzPython.File\DefaultIconz%s,0z Python.hlpzMain Python DocumentationzActivePython.chm) rr"rrYZSetRegistryDefaultValueÚHKEY_CLASSES_ROOTZRegisterShellCommandr=rZ)rrr"rKZexePathrrrÚRegisterShellInfo©s ÿ raa£regsetup.py - Setup/maintain the registry for Python apps. Run without options, (but possibly search paths) to repair a totally broken python registry setup. This should allow other options to work. Usage: %s [options ...] paths ... -p packageName -- Find and register a package. Looks in the paths for a sub-directory with the name of the package, and adds a path entry for the package. -a appName -- Unconditionally add an application name to the path. A new path entry is create with the app name, and the paths specified are added to the registry. -c -- Add the specified paths to the core Pythonpath. If a path appears on the core path, and a package also needs that same path, the package will not bother registering it. Therefore, By adding paths to the core path, you can avoid packages re-registering the same path. -m filename -- Find and register the specific file name as a module. Do not include a path on the filename! --shell -- Register everything with the Win95/NT shell. --upackage name -- Unregister the package --uapp name -- Unregister the app (identical to --upackage) --umodule name -- Unregister the module --description -- Print a description of the usage. --examples -- Print examples of usage. aÕIf no options are processed, the program attempts to validate and set the standard Python path to the point where the standard library is available. This can be handy if you move Python to a new drive/sub-directory, in which case most of the options would fail (as they need at least string.py, os.py etc to function.) Running without options should repair Python well enough to run with the other options. paths are search paths that the program will use to seek out a file. For example, when registering the core Python, you may wish to provide paths to non-standard places to look for the Python help files, library files, etc. See also the "regcheck.py" utility which will check and dump the contents of the registry. aˆExamples: "regsetup c:\wierd\spot\1 c:\wierd\spot\2" Attempts to setup the core Python. Looks in some standard places, as well as the 2 wierd spots to locate the core Python files (eg, Python.exe, python14.dll, the standard library and Win32 Extensions. "regsetup -a myappname . .\subdir" Registers a new Pythonpath entry named myappname, with "C:\I\AM\HERE" and "C:\I\AM\HERE\subdir" added to the path (ie, all args are converted to absolute paths) "regsetup -c c:\my\python\files" Unconditionally add "c:\my\python\files" to the 'core' Python path. "regsetup -m some.pyd \windows\system" Register the module some.pyd in \windows\system as a registered module. This will allow some.pyd to be imported, even though the windows system directory is not (usually!) on the Python Path. "regsetup --umodule some" Unregister the module "some". This means normal import rules then apply for that module. Ú__main__r)z/?z-?z-helpz-h)ú/ú-z..\Buildz..\LibrJz..\..z ..\..\libz..\buildr.z..\..\pcbuild\amd64z ..\..\pcbuildz*Attempting to setup/repair the Python corez PyWin32.chmzPythonwin Referencez0Registration complete - checking the registry...zp:a:m:c)Úshellz upackage=zuapp=zumodule=Ú descriptionÚexamplesz --descriptionz --examplesz--shellzRegistering the Python core.z-pzRegistering package)z --upackagez--uappz!Unregistering application/packagez-ar*zRegistering applicationzto pathz-cz3-c option must provide at least one additional pathzRegistering %d new core pathsz+All specified paths are already registered.)N)N)N)N)4Ú Exceptionrr2r rrr r)r-r9r=r5rFrHrIrMrRrWrYrZr_raÚargvÚusagerfrgrÚlenrOrZ searchPathÚargrUr4ZregcheckZ CheckRegistryrÚgetoptZoptsÚargsÚoÚarZUnregisterNamedPathrrNr!rr+Z currentPathsZoldLenZnewPathrrrrÚs¼   "$ - ' '  5äÿ    $            ý               ÿ