HEX
Server: LiteSpeed
System: Linux s787.bom1.mysecurecloudhost.com 4.18.0-477.13.1.lve.el8.x86_64 #1 SMP Thu Jun 1 16:40:47 EDT 2023 x86_64
User: mobilech (5348)
PHP: 8.1.34
Disabled: NONE
Upload Files
File: //opt/saltstack/salt/lib/python3.10/site-packages/platformdirs/__pycache__/windows.cpython-310.pyc
o

;jz(�@s�dZddlmZddlZddlZddlmZddlmZddl	m
Z
er*ddlmZGd	d
�d
e
�Z
ddd�Zddd�Zddd�Zddd�Zddd�Zedd�e��Zd
gZdS)zWindows.�)�annotationsN)�	lru_cache)�
TYPE_CHECKING�)�PlatformDirsABC)�Callablec@seZdZdZed+dd��Zdd�d,dd�Zed+d
d��Zed+dd��Zed+dd��Z	ed+dd��Z
ed+dd��Zed+dd��Zed+dd��Z
ed+dd��Zed+dd��Zed+dd ��Zed+d!d"��Zed+d#d$��Zed+d%d&��Zed+d'd(��Zed+d)d*��ZdS)-�Windowsa�
    `MSDN on where to store app data files <https://learn.microsoft.com/en-us/windows/win32/shell/knownfolderid>`_.

    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>`, `ensure_exists
    <platformdirs.api.PlatformDirsABC.ensure_exists>`.

    �return�strcCs(|jrdnd}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�H/opt/saltstack/salt/lib/python3.10/site-packages/platformdirs/windows.py�
user_data_dirs
zWindows.user_data_dirN��
opinion_valuerr�
str | NonecCs�g}|jr0|jdur|jp|j}|�|�|�|j�|dur'|jr'|�|�|jr0|�|j�tjj|g|�R�}|�|�|S)NF)	ZappnameZ	appauthor�append�opinion�versionr
r�join�_optionally_create_directory)rrr�paramsZauthorrrrr&s



zWindows._append_partscCstj�td��}|�|�S)zT:return: data directory shared by users, e.g. ``C:\ProgramData\$appauthor\$appname``�CSIDL_COMMON_APPDATA�r
rrrr�rrrrr�
site_data_dir5s
zWindows.site_data_dircC�|jS)zC:return: config directory tied to the user, same as `user_data_dir`�r�rrrr�user_config_dir;�zWindows.user_config_dircCr$)zF:return: config directory shared by the users, same as `site_data_dir`)r#r&rrr�site_config_dir@r(zWindows.site_config_dircC�tj�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``
        r�Cacherr!r"rrr�user_cache_dirEszWindows.user_cache_dircCr*)zd:return: cache directory shared by users, e.g. ``C:\ProgramData\$appauthor\$appname\Cache\$version``r r+rr!r"rrr�site_cache_dirNszWindows.site_cache_dircCr$)zB:return: state directory tied to the user, same as `user_data_dir`r%r&rrr�user_state_dirTr(zWindows.user_state_dircCs(|j}|jrtj�|d�}|�|�|S)zg:return: log directory tied to the user, same as `user_data_dir` if not opinionated else ``Logs`` in itZLogs)rrr
rrrr"rrr�user_log_dirYs

zWindows.user_log_dircC�tj�td��S)zN:return: documents directory tied to the user e.g. ``%USERPROFILE%\Documents``�CSIDL_PERSONAL�r
rrrr&rrr�user_documents_dirb�zWindows.user_documents_dircCr0)zN:return: downloads directory tied to the user e.g. ``%USERPROFILE%\Downloads``�CSIDL_DOWNLOADSr2r&rrr�user_downloads_dirgr4zWindows.user_downloads_dircCr0)zL:return: pictures directory tied to the user e.g. ``%USERPROFILE%\Pictures``�CSIDL_MYPICTURESr2r&rrr�user_pictures_dirlr4zWindows.user_pictures_dircCr0)zH:return: videos directory tied to the user e.g. ``%USERPROFILE%\Videos``�
CSIDL_MYVIDEOr2r&rrr�user_videos_dirqr4zWindows.user_videos_dircCr0)zF:return: music directory tied to the user e.g. ``%USERPROFILE%\Music``�
CSIDL_MYMUSICr2r&rrr�user_music_dirvr4zWindows.user_music_dircCr0)zK:return: desktop directory tied to the user, e.g. ``%USERPROFILE%\Desktop``�CSIDL_DESKTOPDIRECTORYr2r&rrr�user_desktop_dir{r4zWindows.user_desktop_dircCs$tj�tj�td�d��}|�|�S)z�
        :return: runtime directory tied to the user, e.g.
         ``%USERPROFILE%\AppData\Local\Temp\$appauthor\$appname``
        rZTemp)r
rrrrrr"rrr�user_runtime_dir�s
zWindows.user_runtime_dircCr$)zF:return: runtime directory shared by users, same as `user_runtime_dir`)r?r&rrr�site_runtime_dir�r(zWindows.site_runtime_dir)r	r
)rr
rrr	r
)�__name__�
__module__�__qualname__�__doc__�propertyrrr#r'r)r,r-r.r/r3r6r8r:r<r>r?r@rrrrrsF

r�
csidl_namer
r	cCsjt|�}|dur
|Sdddd��|�}|dur d|��}t|��tj�|�}|dur3d|��}t|��|S)z&Get folder from environment variables.N�APPDATAZALLUSERSPROFILEZLOCALAPPDATA)rr r�Unknown CSIDL name: zUnset environment variable: )�(get_win_folder_if_csidl_name_not_env_var�get�
ValueErrorr
�environ)rF�resultZenv_var_name�msgrrr�get_win_folder_from_env_vars�s"��

rOrcCs�|dkrtj�tj�tjd�d�S|dkr$tj�tj�tjd�d�S|dkr6tj�tj�tjd�d�S|dkrHtj�tj�tjd�d	�S|d
krZtj�tj�tjd�d�SdS)
zMGet a folder for a CSIDL name that does not exist as an environment variable.r1�USERPROFILEZ	Documentsr5�	Downloadsr7ZPicturesr9ZVideosr;ZMusicN)r
rrrrL)rFrrrrI�srIc		Cs�dh}dddddddd	d
��|�}|durd|��}t|��tjd
kr%t�ddl}||vr0|jn|j}|�|d�}|�	||�\}}t
|�S)z�
    Get folder from the registry.

    This is a fallback technique at best. I'm not sure if using the registry for these guarantees us the correct answer
    for all CSIDL_* names.

    r ZAppDatazCommon AppDataz
Local AppDataZPersonalz&{374DE290-123F-4565-9164-39C4925E467B}zMy PictureszMy VideozMy Music)rr rr1r5r7r9r;NrH�win32rz@Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders)rJrK�sys�platform�NotImplementedError�winreg�HKEY_LOCAL_MACHINE�HKEY_CURRENT_USER�OpenKey�QueryValueExr
)	rFZ
machine_namesZshell_folder_namerNrV�hkey�key�	directory�_rrr�get_win_folder_from_registry�s.	��	�


r_c
Cs�ddl}ddddddd	d
dd�	�|�}|dur d
|��}t|��|�d�}t|d�}|j�d|dd|�tdd�|D��rM|�d�}|j�	|j
|d�rM|}|dkrYtj�
|j
d�S|j
S)zGet folder with ctypes.rN��#���'��
�(�)	rr rr1r7r9r;r5r=rHi�windllcss�|]	}t|�dkVqdS)�N)�ord)�.0�crrr�	<genexpr>�s�z,get_win_folder_via_ctypes.<locals>.<genexpr>r5rQ)�ctypesrJrK�create_unicode_buffer�getattrZshell32ZSHGetFolderPathW�anyZkernel32ZGetShortPathNameW�valuer
rr)rFroZcsidl_constrN�bufriZbuf2rrr�get_win_folder_via_ctypes�s4�
�



ru�Callable[[str], str]cCsTzddl}Wn	tyYnwt|d�rtSzddl}WtSty)tYSw)Nrri)ro�ImportError�hasattrrurVrOr_)rorVrrr�_pick_get_win_folders�

��ry)�maxsize)rFr
r	r
)rFr
r	r)r	rv)rD�
__future__rr
rS�	functoolsr�typingrZapir�collections.abcrrrOrIr_ruryr�__all__rrrr�<module>s$



$
'�