abc@s@dZd,ZdjeeeZddlZddlZejddkZ e r^eZ nej j drddl Z e j ddZej d rd Zqej d rd Zqd Zn ej ZdddedZdddedZdddedZdddedZdddedZdddedZdefdYZdZdZdZdZed kr!yddlZ eZ!Wq!e"k ryddl#m$Z$eZ!Wqe"k ryddl%Z&eZ!Wqe"k reZ!qXqXq!Xne'dkr<dZ(dZ)d-Z*d$GHee(e)d%d&Z+x&e*D]Z,d'e,e-e+e,fGHq`Wd(GHee(e)Z+x&e*D]Z,d'e,e-e+e,fGHqWd)GHee(Z+x&e*D]Z,d'e,e-e+e,fGHqWd*GHee(d+eZ+x)e*D]Z,d'e,e-e+e,fGHqWndS(.syUtilities for determining application-specific dirs. See for details and usage. iiit.iNitjavatWindowstwin32tMactdarwintlinux2cCs6tdkr|dkr!|}n|r-dp0d}tjjt|}|r|tk rxtjj|||}qtjj||}qn{tdkrtjjd}|rtjj||}qn<tj dtjjd}|rtjj||}n|r2|r2tjj||}n|S( sJReturn 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: macOS: ~/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/". Rt CSIDL_APPDATAtCSIDL_LOCAL_APPDATARs~/Library/Application Support/t XDG_DATA_HOMEs~/.local/shareN( tsystemtNonetostpathtnormpatht_get_win_foldertFalsetjoint expandusertgetenv(tappnamet appauthortversiontroamingtconstR ((s7/usr/lib/python2.7/site-packages/pip/_vendor/appdirs.pyt user_data_dir-s&      cCstdkr|d kr!|}ntjjtd}|r|tk rftjj|||}q~tjj||}qntdkrtjjd}|rtjj||}qntj dtj jddg}g|j tj D]$}tjj|j tj ^q}|rs|rEtjj||}ng|D]}tj j||g^qL}n|rtj j|}n |d}|S|r|rtjj||}n|S( siReturn 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 user data directories are: macOS: /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. RtCSIDL_COMMON_APPDATARs/Library/Application Supportt XDG_DATA_DIRSs/usr/local/shares /usr/shareiN(R R R R RRRRRRtpathseptsplittrstriptsep(RRRt multipathR txtpathlist((s7/usr/lib/python2.7/site-packages/pip/_vendor/appdirs.pyt site_data_dirds4      =.  cCstdkr$t||d|}n<tjdtjjd}|r`tjj||}n|r|rtjj||}n|S(sReturn 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 data directories are: macOS: 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 deafult "~/.config/". RRtXDG_CONFIG_HOMEs ~/.config(RRN(R RR R RR RR(RRRRR ((s7/usr/lib/python2.7/site-packages/pip/_vendor/appdirs.pytuser_config_dirs  cCs tdkrBt||}|r|rtjj||}qntjdd}g|jtjD]$}tjj|j tj ^qg}|r|rtjj||}ng|D]}tj j||g^q}n|rtjj|}n |d}|S(sReturn 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 user data directories are: macOS: 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. RRtXDG_CONFIG_DIRSs/etc/xdgi(RR( R R#R R RRRRRRR(RRRR R R!R"((s7/usr/lib/python2.7/site-packages/pip/_vendor/appdirs.pytsite_config_dirs  =. cCsBtdkr|dkr!|}ntjjtd}|r|tk rftjj|||}ntjj||}|rtjj|d}qqn{tdkrtjjd}|rtjj||}qn<tj dtjjd}|rtjj||}n|r>|r>tjj||}n|S( sReturn 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: macOS: ~/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. RRtCacheRs~/Library/CachestXDG_CACHE_HOMEs~/.cacheN( R R R R RRRRRR(RRRtopinionR ((s7/usr/lib/python2.7/site-packages/pip/_vendor/appdirs.pytuser_cache_dirs(!      cCstdkr0tjjtjjd|}n{tdkrut|||}t}|rtjj|d}qn6t|||}t}|rtjj|d}n|r|rtjj||}n|S(sReturn 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 cache directories are: macOS: ~/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. Rs~/Library/LogsRtLogstlog(R R R RRRRR+(RRRR*R ((s7/usr/lib/python2.7/site-packages/pip/_vendor/appdirs.pyt user_log_dir:s     tAppDirscBs}eZdZddeedZedZedZedZ edZ edZ edZ RS( s1Convenience wrapper for getting application dirs.cCs1||_||_||_||_||_dS(N(RRRRR (tselfRRRRR ((s7/usr/lib/python2.7/site-packages/pip/_vendor/appdirs.pyt__init__os     cCs%t|j|jd|jd|jS(NRR(RRRRR(R0((s7/usr/lib/python2.7/site-packages/pip/_vendor/appdirs.pyRwscCs%t|j|jd|jd|jS(NRR (R#RRRR (R0((s7/usr/lib/python2.7/site-packages/pip/_vendor/appdirs.pyR#|scCs%t|j|jd|jd|jS(NRR(R%RRRR(R0((s7/usr/lib/python2.7/site-packages/pip/_vendor/appdirs.pyR%scCs%t|j|jd|jd|jS(NRR (R'RRRR (R0((s7/usr/lib/python2.7/site-packages/pip/_vendor/appdirs.pyR'scCst|j|jd|jS(NR(R+RRR(R0((s7/usr/lib/python2.7/site-packages/pip/_vendor/appdirs.pyR+scCst|j|jd|jS(NR(R.RRR(R0((s7/usr/lib/python2.7/site-packages/pip/_vendor/appdirs.pyR.sN( t__name__t __module__t__doc__R RR1tpropertyRR#R%R'R+R.(((s7/usr/lib/python2.7/site-packages/pip/_vendor/appdirs.pyR/ms  cCs\ddl}idd6dd6dd6|}|j|jd }|j||\}}|S( sThis 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. iNtAppDataRsCommon AppDataRs Local AppDataRs@Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders(t_winregtOpenKeytHKEY_CURRENT_USERt QueryValueEx(t csidl_nameR7tshell_folder_nametkeytdirttype((s7/usr/lib/python2.7/site-packages/pip/_vendor/appdirs.pyt_get_win_folder_from_registrys  cCsddlm}m}|jdt||dd}yt|}t}x*|D]"}t|dkrSt}PqSqSW|ryddl }|j |}Wqt k rqXnWnt k rnX|S(Ni(tshellcontshellii( twin32com.shellRARBtSHGetFolderPathtgetattrtunicodeRtordtTruetwin32apitGetShortPathNamet ImportErrort UnicodeError(R;RARBR>t has_high_chartcRI((s7/usr/lib/python2.7/site-packages/pip/_vendor/appdirs.pyt_get_win_folder_with_pywin32s$!      cCsddl}idd6dd6dd6|}|jd}|jjjd|dd |t}x*|D]"}t|d krft}PqfqfW|r|jd}|jj j |j |dr|}qn|j S( NiiRi#RiRiii( tctypestcreate_unicode_buffertwindlltshell32tSHGetFolderPathWR RRGRHtkernel32tGetShortPathNameWtvalue(R;RPt csidl_consttbufRMRNtbuf2((s7/usr/lib/python2.7/site-packages/pip/_vendor/appdirs.pyt_get_win_folder_with_ctypess$   c Cs=ddl}ddlm}ddlm}|jjd}|jd|}|jj }|j dt |j |d|j j||jj|jjd}t}x*|D]"} t| dkrt}PqqW|r9|jd|}|jj } tj|||r9|jj|jjd}q9n|S(Ni(tjna(RiRNsi(tarraytcom.sunR\tcom.sun.jna.platformRtWinDeftMAX_PATHtzerostShell32tINSTANCERDR REtShlObjtSHGFP_TYPE_CURRENTtNativettoStringttostringRRRGRHtKernel32tkernalRJ( R;R]R\Rtbuf_sizeRYRBR>RMRNtkernel((s7/usr/lib/python2.7/site-packages/pip/_vendor/appdirs.pyt_get_win_folder_with_jnas&  +!  '(RRt__main__tMyAppt MyCompanyRR#R%R'R+R.s%-- app dirs (with optional 'version')Rs1.0s%s: %ss) -- app dirs (without optional 'version')s+ -- app dirs (without optional 'appauthor')s( -- app dirs (with disabled 'appauthor')R(iii(RR#R%R'R+R.(.R4t__version_info__Rtmaptstrt __version__tsysR t version_infotPY3RFtplatformt startswithtjava_vertos_nameR R RRR#R%R'RHR+R.tobjectR/R@ROR[RnRCtwin32comRRKRPRRt com.sun.jnatcomR2RRtpropstdirstpropRE(((s7/usr/lib/python2.7/site-packages/pip/_vendor/appdirs.pyt s~        7B(393+