
    Kxh                        d dl mZ d dlZd dlZd dlZd dlmZ d dlmZ ddl	m
Z
  G d de
          ZddZddZddZddZ  ed           e                      ZdgZdS )    )annotationsN)	lru_cache)Callable   )PlatformDirsABCc                      e Zd ZdZedd            Zdddd
Zedd            Zedd            Zedd            Z	edd            Z
edd            Zedd            Zedd            Zedd            ZdS )Windowsa  `MSDN on where to store app data files
    <http://support.microsoft.com/default.aspx?scid=kb;en-us;310294#XSLTH3194121123120121120120>`_.
    Makes use of the
    `appname <platformdirs.api.PlatformDirsABC.appname>`,
    `appauthor <platformdirs.api.PlatformDirsABC.appauthor>`,
    `version <platformdirs.api.PlatformDirsABC.version>`,
    `roaming <platformdirs.api.PlatformDirsABC.roaming>`,
    `opinion <platformdirs.api.PlatformDirsABC.opinion>`.returnstrc                    | j         rdnd}t          j                            t	          |                    }|                     |          S )z
        :return: data directory tied to the user, e.g.
         ``%USERPROFILE%\AppData\Local\$appauthor\$appname`` (not roaming) or
         ``%USERPROFILE%\AppData\Roaming\$appauthor\$appname`` (roaming)
        CSIDL_APPDATACSIDL_LOCAL_APPDATA)roamingospathnormpathget_win_folder_append_parts)selfconstr   s      S/var/www/html/what/lib/python3.11/site-packages/pip/_vendor/platformdirs/windows.pyuser_data_dirzWindows.user_data_dir   sF     $(<J5Jwu 5 566!!$'''    Nopinion_valuer   r   
str | Nonec               L   g }| j         r| j        dur#| j        p| j         }|                    |           |                    | j                    || j        r|                    |           | j        r|                    | j                   t          j        j        |g|R  S )NF)appname	appauthorappendopinionversionr   r   join)r   r   r   paramsauthors        r   r   zWindows._append_parts!   s    < 	,~U**74<f%%%MM$,'''(T\(m,,,| ,dl+++w|D*6****r   c                    t           j                            t          d                    }|                     |          S )zT:return: data directory shared by users, e.g. ``C:\ProgramData\$appauthor\$appname``CSIDL_COMMON_APPDATAr   r   r   r   r   r   r   s     r   site_data_dirzWindows.site_data_dir.   s6     w/E F FGG!!$'''r   c                    | j         S )zC:return: config directory tied to the user, same as `user_data_dir`r   r   s    r   user_config_dirzWindows.user_config_dir4        !!r   c                    | j         S )zF:return: config directory shared by the users, same as `site_data_dir`)r*   r-   s    r   site_config_dirzWindows.site_config_dir9   r/   r   c                    t           j                            t          d                    }|                     |d          S )z
        :return: cache directory tied to the user (if opinionated with ``Cache`` folder within ``$appname``) e.g.
         ``%USERPROFILE%\AppData\Local\$appauthor\$appname\Cache\$version``
        r   Cacher   r(   r)   s     r   user_cache_dirzWindows.user_cache_dir>   s;     w/D E EFF!!$g!>>>r   c                    | j         S )zB:return: state directory tied to the user, same as `user_data_dir`r,   r-   s    r   user_state_dirzWindows.user_state_dirG   r/   r   c                b    | j         }| j        r t          j                            |d          }|S )zy
        :return: log directory tied to the user, same as `user_data_dir` if not opinionated else ``Logs`` in it
        Logs)r   r!   r   r   r#   r)   s     r   user_log_dirzWindows.user_log_dirL   s0    
 !< 	.7<<f--Dr   c                Z    t           j                            t          d                    S )z`
        :return: documents directory tied to the user e.g. ``%USERPROFILE%\Documents``
        CSIDL_PERSONAL)r   r   r   r   r-   s    r   user_documents_dirzWindows.user_documents_dirV   s#    
 w/? @ @AAAr   c                    t           j                            t           j                            t	          d          d                    }|                     |          S )z
        :return: runtime directory tied to the user, e.g.
         ``%USERPROFILE%\AppData\Local\Temp\$appauthor\$appname``
        r   Temp)r   r   r   r#   r   r   r)   s     r   user_runtime_dirzWindows.user_runtime_dir]   sG     w^<Q-R-RTZ [ [\\!!$'''r   )r
   r   )r   r   r   r   r
   r   )__name__
__module____qualname____doc__propertyr   r   r*   r.   r1   r4   r6   r9   r<   r?    r   r   r	   r	      sg       = = ( ( ( X( GK + + + + + + ( ( ( X(
 " " " X" " " " X" ? ? ? X? " " " X"    X B B B XB ( ( ( X( ( (r   r	   
csidl_namer   r
   c                l   | dk    rMt           j                            t           j                            t           j        d                   d          S dddd                    |           }|t          d	|            t           j                            |          }|t          d
|           |S )z&Get folder from environment variables.r;   USERPROFILE	DocumentsAPPDATAALLUSERSPROFILELOCALAPPDATA)r   r'   r   NUnknown CSIDL name: zUnset environment variable: )r   r   r#   r   environget
ValueError)rF   env_var_nameresults      r   get_win_folder_from_env_varsrS   g   s    %%%w||BG,,RZ-FGGUUU # 1-  
c*oo	 
 <
<<===Z^^L))F~FFFGGGMr   c                   ddddd                     |           }|t          d|            t          j        dk    rt          d	dl}|                    |j        d
          }|                    ||          \  }}t          |          S )zGet folder from the registry.

    This is a fallback technique at best. I'm not sure if using the
    registry for this guarantees us the correct answer for all CSIDL_*
    names.
    AppDatazCommon AppDatazLocal AppDataPersonalr   r'   r   r;   NrM   win32r   z@Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders)
rO   rP   sysplatformNotImplementedErrorwinregOpenKeyHKEY_CURRENT_USERQueryValueExr   )rF   shell_folder_namer\   key	directory_s         r   get_win_folder_from_registryrd   y   s     # 0.$	 
 
c*oo   <
<<===
|w!!MMM
..13v
w
wC&&s,=>>LIqy>>r   c                   ddddd                     |           }|t          d|            t          j        d          }t	          t          d	          }|j                            d|dd
|           t          d |D                       r7t          j        d          }|j        	                    |j
        |d          r|}|j
        S )zGet folder with ctypes.   #         rW   NrM   i   windllr   c              3  <   K   | ]}t          |          d k    V  dS )   N)ord).0cs     r   	<genexpr>z,get_win_folder_via_ctypes.<locals>.<genexpr>   s,      
%
%A3q66C<
%
%
%
%
%
%r   )rO   rP   ctypescreate_unicode_buffergetattrshell32SHGetFolderPathWanykernel32GetShortPathNameWvalue)rF   csidl_constbufrj   buf2s        r   get_win_folder_via_ctypesr}      s      "!	 
 
c*oo  <
<<===

&t
,
,CVX&&F
N##D+tQDDD 
%
%
%
%
%%% +D11?,,SYdCC 	C9r   Callable[[str], str]c                     t          t          d          rt          S 	 dd l} t          S # t
          $ r
 t          cY S w xY w)Nrj   r   )hasattrrq   r}   r\   rd   ImportErrorrS   )r\   s    r   _pick_get_win_folderr      sY    vx   )((, ,+  , , ,++++,s   ) ==)maxsize)rF   r   r
   r   )r
   r~   )
__future__r   rq   r   rY   	functoolsr   typingr   apir   r	   rS   rd   r}   r   r   __all__rE   r   r   <module>r      s#   " " " " " "  				 



                        X( X( X( X( X(o X( X( X(v   $   0   0, , , , )4((()=)=)?)?@@ r   