U ÀÒ.eã_ã @s`dZdZd eeeƒ¡ZddlZddlZejddkZ e r>eZ ej   d¡rˆddl Z e   ¡ddZe  d¡rrdZqŽe  d ¡r‚d ZqŽd Znej Zd4d d„Zd5dd„Zd6dd„Zd7dd„Zd8dd„Zd9dd„Zd:dd„ZGdd„deƒZdd„Zd d!„Zd"d#„Zd$d%„Zedkrfzdd&lmZeZWnBe k rdzddl!Z"eZWne k r^eZYnXYnXe#d'kr\d(Z$d)Z%d*Z&e'd+eƒe'd,ƒee$e%d-d.Z(e&D]Z)e'd/e)e*e(e)ƒfƒq¢e'd0ƒee$e%ƒZ(e&D]Z)e'd/e)e*e(e)ƒfƒqÖe'd1ƒee$ƒZ(e&D]Z)e'd/e)e*e(e)ƒfƒqe'd2ƒee$d d3Z(e&D]Z)e'd/e)e*e(e)ƒfƒq>dS);zyUtilities for determining application-specific dirs. See for details and usage. )éééÚ.éNrÚjavaZWindowsÚwin32ZMacÚdarwinZlinux2FcCsÆtdkr^|dkr|}|rdpd}tj t|ƒ¡}|r¬|dk rNtj |||¡}q¬tj ||¡}nNtdkr†tj d¡}|r¬tj ||¡}n&t dtj d ¡¡}|r¬tj ||¡}|rÂ|rÂtj ||¡}|S) aJReturn full path to the user-specific data dir for this application. "appname" is the name of application. If None, just the system directory is returned. "appauthor" (only used on Windows) is the name of the appauthor or distributing body for this application. Typically it is the owning company name. This falls back to appname. You may pass False to disable it. "version" is an optional version path element to append to the path. You might want to use this if you want multiple versions of your app to be able to run independently. If used, this would typically be ".". Only applied when appname is present. "roaming" (boolean, default False) can be set True to use the Windows roaming appdata directory. That means that for users on a Windows network setup for roaming profiles, this user data will be sync'd on login. See for a discussion of issues. Typical user data directories are: Mac OS X: ~/Library/Application Support/ Unix: ~/.local/share/ # or in $XDG_DATA_HOME, if defined Win XP (not roaming): C:\Documents and Settings\\Application Data\\ Win XP (roaming): C:\Documents and Settings\\Local Settings\Application Data\\ Win 7 (not roaming): C:\Users\\AppData\Local\\ Win 7 (roaming): C:\Users\\AppData\Roaming\\ For Unix, we follow the XDG spec and support $XDG_DATA_HOME. That means, by default "~/.local/share/". rNÚ CSIDL_APPDATAÚCSIDL_LOCAL_APPDATAFrz~/Library/Application Support/Z XDG_DATA_HOMEz~/.local/share©ÚsystemÚosÚpathÚnormpathÚ_get_win_folderÚjoinÚ expanduserÚgetenv)ÚappnameÚ appauthorÚversionÚroamingÚconstr©rú7/usr/lib/python3.8/site-packages/pip/_vendor/appdirs.pyÚ user_data_dir-s&   rcs tdkrR|dkrˆ}tj tdƒ¡}ˆrî|dk rBtj ||ˆ¡}qîtj |ˆ¡}nœtdkrztj d¡}ˆrîtj |ˆ¡}ntt dtj dd g¡¡}d d „|  tj¡Dƒ}ˆrÐ|r¾tj ˆ|¡‰‡fd d „|Dƒ}|râtj |¡}n|d }|Sˆr|rtj ||¡}|S)aiReturn full path to the user-shared data dir for this application. "appname" is the name of application. If None, just the system directory is returned. "appauthor" (only used on Windows) is the name of the appauthor or distributing body for this application. Typically it is the owning company name. This falls back to appname. You may pass False to disable it. "version" is an optional version path element to append to the path. You might want to use this if you want multiple versions of your app to be able to run independently. If used, this would typically be ".". Only applied when appname is present. "multipath" is an optional parameter only applicable to *nix which indicates that the entire list of data dirs should be returned. By default, the first item from XDG_DATA_DIRS is returned, or '/usr/local/share/', if XDG_DATA_DIRS is not set Typical site data directories are: Mac OS X: /Library/Application Support/ Unix: /usr/local/share/ or /usr/share/ Win XP: C:\Documents and Settings\All Users\Application Data\\ Vista: (Fail! "C:\ProgramData" is a hidden *system* directory on Vista.) Win 7: C:\ProgramData\\ # Hidden, but writeable on Win 7. For Unix, this is using the $XDG_DATA_DIRS[0] default. WARNING: Do not use this on Windows. See the Vista-Fail note above for why. rNÚCSIDL_COMMON_APPDATAFrz/Library/Application SupportZ XDG_DATA_DIRSz/usr/local/sharez /usr/sharecSs g|]}tj | tj¡¡‘qSr©r rrÚrstripÚsep©Ú.0ÚxrrrÚ •sz!site_data_dir..csg|]}tj |ˆg¡‘qSr©r rrr ©rrrr#™sr) r r rrrrrrÚpathsepÚsplit©rrrÚ multipathrZpathlistrr%rÚ site_data_dirds6 ÿ r*cCsXtdkrt||d|ƒ}n&t dtj d¡¡}|r>tj ||¡}|rT|rTtj ||¡}|S)aÔReturn full path to the user-specific config dir for this application. "appname" is the name of application. If None, just the system directory is returned. "appauthor" (only used on Windows) is the name of the appauthor or distributing body for this application. Typically it is the owning company name. This falls back to appname. You may pass False to disable it. "version" is an optional version path element to append to the path. You might want to use this if you want multiple versions of your app to be able to run independently. If used, this would typically be ".". Only applied when appname is present. "roaming" (boolean, default False) can be set True to use the Windows roaming appdata directory. That means that for users on a Windows network setup for roaming profiles, this user data will be sync'd on login. See for a discussion of issues. Typical user config directories are: Mac OS X: same as user_data_dir Unix: ~/.config/ # or in $XDG_CONFIG_HOME, if defined Win *: same as user_data_dir For Unix, we follow the XDG spec and support $XDG_CONFIG_HOME. That means, by default "~/.config/". ©rrNZXDG_CONFIG_HOMEz ~/.config©r rr rrrr©rrrrrrrrÚuser_config_dir¦sr.cs’tdkr*tˆ|ƒ}ˆrŽ|rŽtj ||¡}ndt dd¡}dd„| tj¡Dƒ}ˆrt|rbtj ˆ|¡‰‡fdd„|Dƒ}|r†tj |¡}n|d}|S)aReturn full path to the user-shared data dir for this application. "appname" is the name of application. If None, just the system directory is returned. "appauthor" (only used on Windows) is the name of the appauthor or distributing body for this application. Typically it is the owning company name. This falls back to appname. You may pass False to disable it. "version" is an optional version path element to append to the path. You might want to use this if you want multiple versions of your app to be able to run independently. If used, this would typically be ".". Only applied when appname is present. "multipath" is an optional parameter only applicable to *nix which indicates that the entire list of config dirs should be returned. By default, the first item from XDG_CONFIG_DIRS is returned, or '/etc/xdg/', if XDG_CONFIG_DIRS is not set Typical site config directories are: Mac OS X: same as site_data_dir Unix: /etc/xdg/ or $XDG_CONFIG_DIRS[i]/ for each value in $XDG_CONFIG_DIRS Win *: same as site_data_dir Vista: (Fail! "C:\ProgramData" is a hidden *system* directory on Vista.) For Unix, this is using the $XDG_CONFIG_DIRS[0] default, if multipath=False WARNING: Do not use this on Windows. See the Vista-Fail note above for why. r+ZXDG_CONFIG_DIRSz/etc/xdgcSs g|]}tj | tj¡¡‘qSrrr rrrr#ôsz#site_config_dir..csg|]}tj |ˆg¡‘qSrr$r r%rrr#øsr)r r*r rrrr'r&r(rr%rÚsite_config_dirÎs  r/TcCsÌtdkrd|dkr|}tj tdƒ¡}|r²|dk rBtj |||¡}ntj ||¡}|r²tj |d¡}nNtdkrŒtj d¡}|r²tj ||¡}n&t dtj d ¡¡}|r²tj ||¡}|rÈ|rÈtj ||¡}|S) aReturn full path to the user-specific cache dir for this application. "appname" is the name of application. If None, just the system directory is returned. "appauthor" (only used on Windows) is the name of the appauthor or distributing body for this application. Typically it is the owning company name. This falls back to appname. You may pass False to disable it. "version" is an optional version path element to append to the path. You might want to use this if you want multiple versions of your app to be able to run independently. If used, this would typically be ".". Only applied when appname is present. "opinion" (boolean) can be False to disable the appending of "Cache" to the base app data dir for Windows. See discussion below. Typical user cache directories are: Mac OS X: ~/Library/Caches/ Unix: ~/.cache/ (XDG default) Win XP: C:\Documents and Settings\\Local Settings\Application Data\\\Cache Vista: C:\Users\\AppData\Local\\\Cache On Windows the only suggestion in the MSDN docs is that local settings go in the `CSIDL_LOCAL_APPDATA` directory. This is identical to the non-roaming app data dir (the default returned by `user_data_dir` above). Apps typically put cache data somewhere *under* the given dir here. Some examples: ...\Mozilla\Firefox\Profiles\\Cache ...\Acme\SuperApp\Cache\1.0 OPINION: This function appends "Cache" to the `CSIDL_LOCAL_APPDATA` value. This can be disabled with the `opinion=False` option. rNr FZCacherz~/Library/CachesZXDG_CACHE_HOMEz~/.cacher ©rrrZopinionrrrrÚuser_cache_dirs(! r1cCsXtdkrt||d|ƒ}n&t dtj d¡¡}|r>tj ||¡}|rT|rTtj ||¡}|S)aReturn full path to the user-specific state dir for this application. "appname" is the name of application. If None, just the system directory is returned. "appauthor" (only used on Windows) is the name of the appauthor or distributing body for this application. Typically it is the owning company name. This falls back to appname. You may pass False to disable it. "version" is an optional version path element to append to the path. You might want to use this if you want multiple versions of your app to be able to run independently. If used, this would typically be ".". Only applied when appname is present. "roaming" (boolean, default False) can be set True to use the Windows roaming appdata directory. That means that for users on a Windows network setup for roaming profiles, this user data will be sync'd on login. See for a discussion of issues. Typical user state directories are: Mac OS X: same as user_data_dir Unix: ~/.local/state/ # or in $XDG_STATE_HOME, if defined Win *: same as user_data_dir For Unix, we follow this Debian proposal to extend the XDG spec and support $XDG_STATE_HOME. That means, by default "~/.local/state/". r+NZXDG_STATE_HOMEz~/.local/stater,r-rrrÚuser_state_dir:sr2cCsˆtdkr tj tj d¡|¡}nNtdkrLt|||ƒ}d}|rntj |d¡}n"t|||ƒ}d}|rntj |d¡}|r„|r„tj ||¡}|S)a½Return full path to the user-specific log dir for this application. "appname" is the name of application. If None, just the system directory is returned. "appauthor" (only used on Windows) is the name of the appauthor or distributing body for this application. Typically it is the owning company name. This falls back to appname. You may pass False to disable it. "version" is an optional version path element to append to the path. You might want to use this if you want multiple versions of your app to be able to run independently. If used, this would typically be ".". Only applied when appname is present. "opinion" (boolean) can be False to disable the appending of "Logs" to the base app data dir for Windows, and "log" to the base cache dir for Unix. See discussion below. Typical user log directories are: Mac OS X: ~/Library/Logs/ Unix: ~/.cache//log # or under $XDG_CACHE_HOME if defined Win XP: C:\Documents and Settings\\Local Settings\Application Data\\\Logs Vista: C:\Users\\AppData\Local\\\Logs On Windows the only suggestion in the MSDN docs is that local settings go in the `CSIDL_LOCAL_APPDATA` directory. (Note: I'm interested in examples of what some windows apps use for a logs dir.) OPINION: This function appends "Logs" to the `CSIDL_LOCAL_APPDATA` value for Windows and appends "log" to the user cache dir for Unix. This can be disabled with the `opinion=False` option. rz~/Library/LogsrFZLogsÚlog)r r rrrrr1r0rrrÚ user_log_dirds"  þ  r4c@sneZdZdZddd„Zedd„ƒZedd „ƒZed d „ƒZed d „ƒZ edd„ƒZ edd„ƒZ edd„ƒZ dS)ÚAppDirsz1Convenience wrapper for getting application dirs.NFcCs"||_||_||_||_||_dS)N)rrrrr))Úselfrrrrr)rrrÚ__init__™s zAppDirs.__init__cCst|j|j|j|jdS©N)rr)rrrrr©r6rrrr¡s ÿzAppDirs.user_data_dircCst|j|j|j|jdS©N)rr))r*rrrr)r9rrrr*¦s ÿzAppDirs.site_data_dircCst|j|j|j|jdSr8)r.rrrrr9rrrr.«s ÿzAppDirs.user_config_dircCst|j|j|j|jdSr:)r/rrrr)r9rrrr/°s ÿzAppDirs.site_config_dircCst|j|j|jdS©N©r)r1rrrr9rrrr1µs ÿzAppDirs.user_cache_dircCst|j|j|jdSr;)r2rrrr9rrrr2ºs ÿzAppDirs.user_state_dircCst|j|j|jdSr;)r4rrrr9rrrr4¿s ÿzAppDirs.user_log_dir)NNNFF) Ú__name__Ú __module__Ú __qualname__Ú__doc__r7Úpropertyrr*r.r/r1r2r4rrrrr5—s&ÿ       r5cCsHtrddl}nddl}ddddœ|}| |jd¡}| ||¡\}}|S)z–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. rNZAppDatazCommon AppDataz Local AppData©r rr z@Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders)ÚPY3ÚwinregÚ_winregÚOpenKeyÚHKEY_CURRENT_USERZ QueryValueEx)Ú csidl_namerEZshell_folder_nameÚkeyÚdirÚtyperrrÚ_get_win_folder_from_registryÇs ýüþrLcCsžddlm}m}| dt||ƒdd¡}z^t|ƒ}d}|D]}t|ƒdkr8d}qRq8|r‚zddl}| |¡}Wnt k r€YnXWnt k r˜YnX|S)Nr)ÚshellconÚshellFéÿT) Zwin32com.shellrMrNÚSHGetFolderPathÚgetattrÚunicodeÚordÚwin32apiÚGetShortPathNameÚ ImportErrorÚ UnicodeError)rHrMrNrJÚ has_high_charÚcrTrrrÚ_get_win_folder_with_pywin32ßs$  rZcCs†ddl}ddddœ|}| d¡}|jj d|dd|¡d}|D]}t|ƒdkr@d }qZq@|r€| d¡}|jj |j|d¡r€|}|jS) Nréé#érBiFrOT) ÚctypesZcreate_unicode_bufferÚwindllZshell32ZSHGetFolderPathWrSZkernel32ZGetShortPathNameWÚvalue)rHr^Z csidl_constÚbufrXrYZbuf2rrrÚ_get_win_folder_with_ctypesús&ýü   rbc CsÖddl}ddlm}ddlm}|jjd}| d|¡}|jj }|  dt |j |ƒd|j j |¡|j | ¡¡ d¡}d}|D]} t| ƒdkr|d }q–q||rÒ| d|¡}|jj } |  |||¡rÒ|j | ¡¡ d¡}|S) Nr)Újna)rérYúFrOT)ÚarrayZcom.sunrcZcom.sun.jna.platformrZWinDefZMAX_PATHZzerosZShell32ZINSTANCErPrQZShlObjZSHGFP_TYPE_CURRENTZNativeZtoStringZtostringrrSZKernel32rU) rHrfrcrZbuf_sizerarNrJrXrYZkernelrrrÚ_get_win_folder_with_jnas&      rg)r_Ú__main__ZMyAppZ MyCompany)rr.r1r2r4r*r/z-- app dirs %s --z%-- app dirs (with optional 'version')z1.0r<z%s: %sz) -- app dirs (without optional 'version')z+ -- app dirs (without optional 'appauthor')z( -- app dirs (with disabled 'appauthor'))r)NNNF)NNNF)NNNF)NNNF)NNNT)NNNF)NNNT)+r@Z__version_info__rÚmapÚstrÚ __version__Úsysr Ú version_inforCrRÚplatformÚ startswithZjava_verZos_namer rr*r.r/r1r2r4Úobjectr5rLrZrbrgr^r_rrVZ com.sun.jnaZcomr=rrZpropsÚprintÚdirsZproprQrrrrÚsv     7 B ( 3 9 * 30