o ai@sddlZddlZddlmZddlmZmZddlmZGdddeZ de d e fd d Z de d e fd d Z de d e fddZ d ee ge ffddZeddeZdgZdS)N) lru_cache)CallableOptional)PlatformDirsABCc@seZdZdZedefddZdddedeedefd d Zedefd d Z edefd dZ edefddZ edefddZ edefddZ edefddZedefddZedefddZdS)Windowsa`MSDN on where to store app data files `_. Makes use of the `appname `, `appauthor `, `version `, `roaming `, `opinion `.returncCs(|jrdnd}tjt|}||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_APPDATACSIDL_LOCAL_APPDATA)roamingospathnormpathget_win_folder _append_parts)selfconstr r/builddir/build/BUILDROOT/alt-python310-pip-21.3.1-5.el8.x86_64/opt/alt/python310/lib/python3.10/site-packages/pip/_vendor/platformdirs/windows.py user_data_dirs zWindows.user_data_dirN opinion_valuer rcCstg}|jr0|jdur|jp|j}||||j|dur'|jr'|||jr0||jtjj|g|RS)NF)appname appauthorappendopinionversionr r join)rr rparamsauthorrrrrs      zWindows._append_partscCstjtd}||S)zT:return: data directory shared by users, e.g. ``C:\ProgramData\$appauthor\$appname``CSIDL_COMMON_APPDATAr r rrrrr rrr site_data_dir+s zWindows.site_data_dircC|jS)zC:return: config directory tied to the user, same as `user_data_dir`rrrrruser_config_dir1zWindows.user_config_dircCr$)zF:return: config directory shared by the users, same as `site_data_dir`)r#r&rrrsite_config_dir6r(zWindows.site_config_dircCstjtd}|j|ddS)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"rrruser_cache_dir;szWindows.user_cache_dircCr$)zB:return: state directory tied to the user, same as `user_data_dir`r%r&rrruser_state_dirDr(zWindows.user_state_dircCs|j}|jr tj|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 rr"rrr user_log_dirIszWindows.user_log_dircCstjtdS)z` :return: documents directory tied to the user e.g. ``%USERPROFILE%\Documents`` CSIDL_PERSONAL)r r rrr&rrruser_documents_dirSszWindows.user_documents_dircCs$tjtjtdd}||S)z :return: runtime directory tied to the user, e.g. ``%USERPROFILE%\AppData\Local\Temp\$appauthor\$appname`` r ZTemp)r r rrrrr"rrruser_runtime_dirZs zWindows.user_runtime_dir)__name__ __module__ __qualname____doc__propertystrrrrr#r'r)r+r,r-r/r0rrrrr s*    r csidl_namercCsr|dkrtjtjtjddSdddd|}|dur&td |tj|}|dur7td ||S) z&Get folder from environment variables.r. USERPROFILEZ DocumentsAPPDATAZALLUSERSPROFILE LOCALAPPDATA)r r r NUnknown CSIDL name: zUnset environment variable: )r r rrenvironget ValueError)r7Z env_var_nameresultrrrget_win_folder_from_env_varsds r@cCsXddddd|}|durtd|ddl}||jd }|||\}}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. ZAppDatazCommon AppDataz Local AppDataZPersonalr r r r.Nr;rz@Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders)r=r>winregOpenKeyHKEY_CURRENT_USER QueryValueExr6)r7Zshell_folder_namerBkey directory_rrrget_win_folder_from_registryvsrIcCsddddd|}|durtd|td}ttd }|jd|dd |td d |DrBtd}|j |j |drB|}|j S) zGet folder with ctypes.#rANr;iwindllrcss|] }t|dkVqdS)N)ord).0crrr sz,get_win_folder_via_ctypes..) r=r>ctypescreate_unicode_buffergetattrZshell32ZSHGetFolderPathWanyZkernel32ZGetShortPathNameWvalue)r7Z csidl_constbufrNZbuf2rrrget_win_folder_via_ctypess"   rZcCs4ttdrtSzddl}WtStytYSw)NrNr)hasattrrTrZrB ImportErrorr@rI)rBrrr_pick_get_win_folders   r])maxsize)rTr functoolsrtypingrrapirrr6r@rIrZr]r__all__rrrrs  [