
    %
i1                         d dl Z d dlZd dlZd dlZdZdZdZd Zd ZddZ	ddZ
d	 Zdd
Zd Zd Zd Zd Zd Zd Zd Zd ZddZddZddZd ZddZd ZdS )    Nz&{b51df050-06ae-11cf-ad3b-524153480001}zPython.FilezPython.CompiledFilec                       dt           j        z   S )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.
    zSoftware\Python\PythonCore\)syswinver     C:\Users\Dell Inspiron 16\Desktop\tws\AgrotaPowerBi\back-agrota-powerbi\mcp-client-agrota\venv\Lib\site-packages\win32/lib/regutil.pyBuildDefaultPythonKeyr	      s     ,cj88r   c                      t                      } 	 t          j        t          j        |           }|                                 t          j        S # t          j        $ r t          j        cY S w xY w)z-Retrieves the Registry root in use by Python.)r	   win32api
RegOpenKeywin32conHKEY_CURRENT_USERcloseerrorHKEY_LOCAL_MACHINE)keynameks     r   
GetRootKeyr      si    #%%G+ :GDD				))> + + +****+s   >A A-,A-c                 L    |t                      }t          j        ||           S )z?A helper to return the default value for a key in the registry.)r   r   RegQueryValue)subkeyrootkeys     r   GetRegistryDefaultValuer   $   s#    ,,!'6222r   c                     |t                      }t          |t                    rt          j        }n4t          |t
                    rt          j        }nt          d|          t          j	        || ||           dS )z;A helper to set the default value for a key in the registryNz-Value must be string or integer - was passed )
r   
isinstancestrr   REG_SZint	REG_DWORD	TypeErrorr   RegSetValue)subKeyvaluer   typeIds       r   SetRegistryDefaultValuer%   +   s}    ,,% S	E3		 S#QQQRRR&&%88888r   c                      dS )Nz3Software\Microsoft\Windows\CurrentVersion\App Pathsr   r   r   r   GetAppPathsKeyr'   9   s    DDr   c                     |rt          d          |t          j                            |           }t	          j        t                      t                      dz   |z   t          j	        |            dS )a  Register 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\)

ValueErrorospathbasenamer   r!   r   r'   r   r   )exeFullPathexeAlias
exeAppPaths      r   RegisterPythonExer1   =   su    "  IGHHH7##K00n&&-8(/;    r   c                 h    t          j        t                      t                      dz   | z             S )zGet a registered .exer)   )r   r   r   r'   )r/   s    r   GetRegisteredExer3   W   s)    !*,,0@0@40G(0RSSSr   c                     	 t          j        t                      t                      dz   | z              dS # t           j        $ r }ddl}|j        |j        k    r Y d}~dS d}~ww xY w)z(Unregister a .exe file that uses Python.r)   r   N)r   RegDeleteKeyr   r'   r   winerrorERROR_FILE_NOT_FOUND)r/   excr6   s      r   UnregisterPythonExer9   \   s~    jllN,<,<t,Ch,NOOOOO>   <8888   37 A&A!!A&c                     t                      dz   }| r|d| z   z  }t          j        t                      |t          j        |           dS )z5Register a named path - ie, a named PythonPath entry.\PythonPathr)   N)r	   r   r!   r   r   r   )namer,   keyStrs      r   RegisterNamedPathr?   h   sK    "$$~5F $+vxEEEEEr   c                     t                      dz   | z   }	 t          j        t                      |           dS # t          j        $ r }ddl}|j        |j        k    r Y d}~dS d}~ww xY w)z7Unregister a named path - ie, a named PythonPath entry.z\PythonPath\r   N)r	   r   r5   r   r   r6   r7   r=   r>   r8   r6   s       r   UnregisterNamedPathrB   p   s    "$$'77$>FjllF33333>   <8888s   !9 A(A##A(c                     t                      dz   }| r|d| z   z  }	 t          j        t                      |          S # t          j        $ r }ddl}|j        |j        k    r Y d}~dS d}~ww xY w)z9Get a registered named path, or None if it doesn't exist.r<   r)   r   N)r	   r   r   r   r   r6   r7   rA   s       r   GetRegisteredNamedPathrD   }   s    "$$~5F $+%jllF;;;>   <8888ttttts    > A-A((A-c                     	 ddl } |j        |           n"# t          $ r t          d|z             Y nw xY wt	          j        t                      t                      d| z  z   t          j	        |           dS )aP  Register 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.
    r   Nz+Warning: Registering non-existant module %s\Modules\%s)
r+   statOSErrorprintr   r!   r   r	   r   r   )modNamemodPathr+   s      r   RegisterModulerL      s    G			 G G G;gEFFFFFG/G";;	    s    66c                     	 t          j        t                      t                      d| z  z              dS # t           j        $ r }ddl}|j        |j        k    r Y d}~dS d}~ww xY w)znUnregister an explicit module in the registry.

    modName -- The name of the module, as used by import.
    rF   r   N)r   r5   r   r	   r   r6   r7   )rJ   r8   r6   s      r   UnregisterModulerN      s    
LL/11Og4MM	
 	
 	
 	
 	
 >   <8888 988888r:   c                     	 t          t                      dz   | z             S # t          j        $ rG 	 t          t                      dz   | z   t          j                  cY S # t          j        $ r Y nw xY wY nw xY wdS )z1Given a description, return the registered entry.z\Help\N)r   r	   r   r   r   r   )helpDescs    r   GetRegisteredHelpFilerQ      s    	&'<'>'>'Kh'VWWW>   	*%''*4x?*     ~ 	 	 	D	D 4s2    # A9+A!A9!A30A92A33A98A9   c                 6   || }t           j                            ||           }	 |rt          j        |           n# t          $ r t          d          w xY wt          j        t                      t                      d|z  z   t          j        |           dS )a  Register 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.
    NzHelp file does not exist\Help\%s)r+   r,   joinrG   rH   r*   r   r!   r   r	   r   r   )helpFilehelpPathrP   
bCheckFilefullHelpFiles        r   RegisterHelpFilerZ      s     7<<(33L5 	"GL!!! 5 5 534445 ,"99	    s	   = Ac                    t          j        t          j        ddt          j                  }	 	 t          j        ||            n1# t           j        $ r}ddl}|j        |j        k    r Y d}~nd}~ww xY wt          j	        |           n# t          j	        |           w xY w|| }	 t          j
        t                      t                      d|z  z              dS # t           j        $ r }ddl}|j        |j        k    r Y d}~dS d}~ww xY w)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.
    zSoftware\Microsoft\Windows\Helpr   NrT   )r   r   r   r   KEY_ALL_ACCESSRegDeleteValuer   r6   r7   RegCloseKeyr5   r   r	   )rV   rP   keyr8   r6   s        r   UnregisterHelpFiler`      sa    
#,		 C	"	#C2222~ 	 	 	OOO|x<<< =<<<<	 	S!!!!S!!!! LL/11L84KK	
 	
 	
 	
 	
 >   <8888 988888sG   A B
 A2A-(B
 -A22B
 
B (3C D,DDc                     | t          j        t          j                  } n8	 t	          j        |            n"# t          $ r t          d| z             Y nw xY wt          j        t                      t                                }	 t          j        |dt          j        |            t          j        |           n# t          j        |           w xY wt          j        t                      dt          j        t          j                   dS )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 %sDllz)Software\Python\PythonCore\CurrentVersion)r   GetModuleFileNamer   	dllhandler+   rG   rH   rI   RegCreateKeyr   r	   r!   r   r   r^   r   )coredllNamehKeys     r   RegisterCoreDLLrh     s    0??	QGK     	Q 	Q 	QAKOPPPPP	Q  /D/F/FGGD#T5(/;GGGT""""T""""6
	    s   8 AA!B> >Cc                 &   t           }t          j        t          j        dt          j        |           t          j        t          j        |t          j        d           t          j        t          j        d|z  t          j        t                     t          j        t          j        d|z  t          j        |            dt           z  }t          j        t          j        |dz   t          j        d           t          j        t          j        |dz   t          j        |           t          }t          j        t          j        d	t          j        |           t          j        t          j        |t          j        d
           t          j        t          j        d|z  t          j        |           d|z  }t          j        t          j        |dz   t          j        d           t          j        t          j        |dz   t          j        |           dS )a  Register 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\OpenRunz\Open\Commandz.pyczCompiled Python FileN)RegistryIDPyFiler   r!   r   HKEY_CLASSES_ROOTr   CLSIDPyFileRegistryIDPycFile)	defPyIcon
defPycIcon
runCommandpythonFileIdbases        r   RegisterFileExtensionsru     s    $L"E8?L   "L(/=   "l"	   "L(	   ))D"D8OX_e   "  	   %L"FHO\   "	   "L(	   %D"D8OX_e   "  	    r   c                     dt           z  }|r1t          j        t          j        |d| z  z   t          j        |           t          j        t          j        |d| z  z   t          j        |           d S )Nrj   z\%sz\%s\Commandrl   r   r!   r   rm   r   )shellCommand
exeCommandshellUserCommandrt   s       r   RegisterShellCommandr{   b  s    
 ))D 
&6\**O		
 	
 	
 ",//	    r   c                 @   dt           z  }t          j        t          j        |d| z  z   t          j        |           t          j        t          j        |d| z  z   t          j        |           t          j        t          j        |d| z  z   t          j        |           d S )Nrj   z\%s\ddeexecz\%s\ddeexec\Applicationz\%s\ddeexec\Topicrw   )rx   ddeAppddeTopic
ddeCommandrt   s        r   RegisterDDECommandr   x  s    ))D",//	   "+|<<	   "%66	    r   )N)NN)NrR   )r+   r   r   r   rn   rl   ro   r	   r   r   r%   r'   r1   r3   r9   r?   rB   rD   rL   rN   rQ   rZ   r`   rh   ru   r{   r   r   r   r   <module>r      s   				 



   7  ) 9 9 9+ + +3 3 3 39 9 9 9E E E   4T T T
	 	 	F F F
 
 
    ,        8" " " "J   :@ @ @F   ,    r   