o 1b'@sddlmZddlZddlZddlmZddlmZddlm Z Gddde Z dd d Z dddZ dddZ dddZeddeZdgZdS)) annotationsN) lru_cache)Callable)PlatformDirsABCc@seZdZdZedddZdddd d Zedd dZedddZedddZ edddZ edddZ edddZ edddZ edddZdS)Windowsa`MSDN on where to store app data files `_. Makes use of the `appname `, `appauthor `, `version `, `roaming `, `opinion `.returnstrcCs(|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)selfconstrr6/usr/lib/python3/dist-packages/platformdirs/windows.py user_data_dirs zWindows.user_data_dirN opinion_valuerr str | NonecCstg}|jr0|jdur|jp|j}||||j|dur'|jr'|||jr0||jtjj|g|RS)NF)appname appauthorappendopinionversionr rjoin)rrrparamsauthorrrrr s      zWindows._append_partscCstjtd}||S)zT:return: data directory shared by users, e.g. ``C:\ProgramData\$appauthor\$appname``CSIDL_COMMON_APPDATAr rrrrrrrrr site_data_dir-s zWindows.site_data_dircC|jS)zC:return: config directory tied to the user, same as `user_data_dir`rrrrruser_config_dir3zWindows.user_config_dircCr&)zF:return: config directory shared by the users, same as `site_data_dir`)r%r(rrrsite_config_dir8r*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_dirFr*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 Logs)rrr rrr$rrr user_log_dirKszWindows.user_log_dircCstjtdS)z` :return: documents directory tied to the user e.g. ``%USERPROFILE%\Documents`` CSIDL_PERSONAL)r rrrr(rrruser_documents_dirUszWindows.user_documents_dircCs$tjtjtdd}||S)z :return: runtime directory tied to the user, e.g. ``%USERPROFILE%\AppData\Local\Temp\$appauthor\$appname`` r Temp)r rrrrrr$rrruser_runtime_dir\s zWindows.user_runtime_dir)rr )rr rrrr )__name__ __module__ __qualname____doc__propertyrrr%r)r+r-r.r0r2r4rrrrr s*         r csidl_namer rcCsr|dkrtjtjtjddSdddd|}|dur&td |tj|}|dur7td ||S) z&Get folder from environment variables.r1 USERPROFILE DocumentsAPPDATAALLUSERSPROFILE LOCALAPPDATA)r r"r NUnknown CSIDL name: zUnset environment variable: )r rrrenvironget ValueError)r: env_var_nameresultrrrget_win_folder_from_env_varsfs rFcCsXddddd|}|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. AppDatazCommon AppDataz Local AppDataPersonalr r"r r1Nr@rz@Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders)rBrCwinregOpenKeyHKEY_CURRENT_USER QueryValueExr )r:shell_folder_namerJkey directory_rrrget_win_folder_from_registryxsrRcCsddddd|}|durtd|td}ttd }|jd|dd |td d |DrBtd}|j |j |drB|}|j S) zGet folder with ctypes.#rINr@iwindllrcss|] }t|dkVqdS)N)ord).0crrr sz,get_win_folder_via_ctypes..) rBrCctypescreate_unicode_buffergetattrshell32SHGetFolderPathWanykernel32GetShortPathNameWvalue)r: csidl_constbufrWbuf2rrrget_win_folder_via_ctypess"   riCallable[[str], str]cCs4ttdrtSzddl}WtStytYSw)NrWr)hasattrr]rirJ ImportErrorrFrR)rJrrr_pick_get_win_folders   rm)maxsize)r:r rr )rrj) __future__rr]r functoolsrtypingrapirrrFrRrirmr__all__rrrrs     [