Current File : //lib/python3.9/site-packages/pip/_vendor/platformdirs/__pycache__/windows.cpython-39.pyc
a

[��f�@s�ddlZddlZddlmZddlmZmZddlmZGdd�de�Z	e
e
d�d	d
�Ze
e
d�dd�Ze
e
d�d
d�Z
ee
ge
fd�dd�Zedd�e��ZdgZdS)�N)�	lru_cache)�Callable�Optional�)�PlatformDirsABCc@s�eZdZdZeed�dd��Zdd�eeeed�dd	�Zeed�d
d��Z	eed�dd
��Z
eed�dd��Zeed�dd��Zeed�dd��Z
eed�dd��Zeed�dd��Zeed�dd��ZdS)�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>`.��returncCs(|jr
dnd}tj�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)Zroaming�os�path�normpath�get_win_folder�
_append_parts)�self�constr
�r�D/usr/lib/python3.9/site-packages/pip/_vendor/platformdirs/windows.py�
user_data_dirszWindows.user_data_dirN��
opinion_value)r
rr	cCstg}|jr`|jdur*|jp|j}|�|�|�|j�|durN|jrN|�|�|jr`|�|j�tjj|g|�R�S)NF)ZappnameZ	appauthor�append�opinion�versionrr
�join)rr
r�paramsZauthorrrrrs


zWindows._append_partscCstj�td��}|�|�S)zT:return: data directory shared by users, e.g. ``C:\ProgramData\$appauthor\$appname``�CSIDL_COMMON_APPDATA�rr
rrr�rr
rrr�
site_data_dir+szWindows.site_data_dircCs|jS)zC:return: config directory tied to the user, same as `user_data_dir`�r�rrrr�user_config_dir1szWindows.user_config_dircCs|jS)zF:return: config directory shared by the users, same as `site_data_dir`)r r"rrr�site_config_dir6szWindows.site_config_dircCstj�td��}|j|dd�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``
        rZCacherrrrrr�user_cache_dir;szWindows.user_cache_dircCs|jS)zB:return: state directory tied to the user, same as `user_data_dir`r!r"rrr�user_state_dirDszWindows.user_state_dircCs|j}|jrtj�|d�}|S)zy
        :return: log directory tied to the user, same as `user_data_dir` if not opinionated else ``Logs`` in it
        ZLogs)rrrr
rrrrr�user_log_dirIszWindows.user_log_dircCstj�td��S)z`
        :return: documents directory tied to the user e.g. ``%USERPROFILE%\Documents``
        �CSIDL_PERSONAL)rr
rrr"rrr�user_documents_dirSszWindows.user_documents_dircCs$tj�tj�td�d��}|�|�S)z�
        :return: runtime directory tied to the user, e.g.
         ``%USERPROFILE%\AppData\Local\Temp\$appauthor\$appname``
        rZTemp)rr
rrrrrrrr�user_runtime_dirZszWindows.user_runtime_dir)�__name__�
__module__�__qualname__�__doc__�property�strrrrr r#r$r%r&r'r)r*rrrrr	s(	

	r)�
csidl_namer	cCsr|dkr$tj�tj�tjd�d�Sdddd��|�}|durLtd	|����tj�|�}|durntd
|����|S)z&Get folder from environment variables.r(�USERPROFILEZ	Documents�APPDATAZALLUSERSPROFILEZLOCALAPPDATA)r
rrN�Unknown CSIDL name: zUnset environment variable: )rr
rr�environ�get�
ValueError)r1Zenv_var_name�resultrrr�get_win_folder_from_env_varsds��r9cCsXddddd��|�}|dur*td|����ddl}|�|jd	�}|�||�\}}t|�S)
z�Get 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.
    ZAppDatazCommon AppDataz
Local AppDataZPersonal�r
rrr(Nr4rz@Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders)r6r7�winreg�OpenKey�HKEY_CURRENT_USERZQueryValueExr0)r1Zshell_folder_namer;�keyZ	directory�_rrr�get_win_folder_from_registryvs��r@cCs�ddddd��|�}|dur*td|����t�d�}ttd	�}|j�d|dd
|�tdd�|D��r�t�d�}|j�	|j
|d�r�|}|j
S)
zGet folder with ctypes.��#��r:Nr4i�windllrcss|]}t|�dkVqdS)�N)�ord)�.0�crrr�	<genexpr>��z,get_win_folder_via_ctypes.<locals>.<genexpr>)r6r7�ctypesZcreate_unicode_buffer�getattrZshell32ZSHGetFolderPathW�anyZkernel32ZGetShortPathNameW�value)r1Zcsidl_const�bufrEZbuf2rrr�get_win_folder_via_ctypes�s"��


rQrcCs:ttd�rtSzddl}Wnty0tYS0tSdS)NrEr)�hasattrrLrQr;�ImportErrorr9r@)r;rrr�_pick_get_win_folder�s

rT)�maxsize)rLr�	functoolsr�typingrrZapirrr0r9r@rQrTr�__all__rrrr�<module>s[�