Yk" @sdZddlmZddlZddlZddlmZmZddlm Z m Z ddZ dd d Z d d d Z ddZddZddZeryddlZeZWnek reZYnXddZdS)zd This code was taken from https://github.com/ActiveState/appdirs and modified to suit our purposes. )absolute_importN)WINDOWS expanduser)PY2 text_typecCstrZtjjtd}tr?t|tr?t|}tjj ||d}n`t j dkrt d}tjj ||}n-tj dt d}tjj ||}|S)a5 Return full path to the user-specific cache dir for this application. "appname" is the name of application. Typical user cache directories are: macOS: ~/Library/Caches/ Unix: ~/.cache/ (XDG default) Windows: 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`). 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. CSIDL_LOCAL_APPDATACachedarwinz~/Library/CachesXDG_CACHE_HOMEz~/.cache)rospathnormpath_get_win_folderr isinstancer_win_path_to_bytesjoinsysplatformrgetenv)appnamer r0/tmp/pip-build-3puug3g5/pip/pip/utils/appdirs.pyuser_cache_dirs  rFcCstrB|rdpd}tjjtjjt||}nTtjdkrotjjtd|}n'tjjtj dtd|}|S)aS Return 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. "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/". CSIDL_APPDATArr z~/Library/Application Support/ XDG_DATA_HOMEz~/.local/share) rr r rr rrrrr)rroamingconstr rrr user_data_dir>s*     rTcCsjtrt|d|}nKtjdkr9t|}n-tjdtd}tjj||}|S)arReturn 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. "roaming" (boolean, default True) can be set False to not 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/ Win *: same as user_data_dir For Unix, we follow the XDG spec and support $XDG_CONFIG_HOME. That means, by default "~/.config/". rr XDG_CONFIG_HOMEz ~/.config) rrrrr rrr r)rrr rrruser_config_dirjsrcstr9tjjtd}tjj|g}n}tjdkrctjjdg}nStjdd}|rfdd|j tj D}ng}|j d|S) aReturn a list of potential user-shared config dirs for this application. "appname" is the name of application. Typical user config directories are: macOS: /Library/Application Support// Unix: /etc or $XDG_CONFIG_DIRS[i]// for each value in $XDG_CONFIG_DIRS Win XP: C:\Documents and Settings\All Users\Application ... ...Data\ Vista: (Fail! "C:\ProgramData" is a hidden *system* directory on Vista.) Win 7: Hidden, but writeable on Win 7: C:\ProgramData\ CSIDL_COMMON_APPDATAr z/Library/Application SupportXDG_CONFIG_DIRSz/etc/xdgcs+g|]!}tjjt|qSr)r r rr).0x)rrr s z$site_config_dirs..z/etc) rr r r rrrrrsplitpathsepappend)rr pathlistxdg_config_dirsr)rrsite_config_dirss r*cCsYddl}ddddddi|}|j|jd }|j||\}}|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. rNrAppDatar zCommon AppDatarz Local AppDataz@Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders)_winregOpenKeyHKEY_CURRENT_USER QueryValueEx) csidl_namer,shell_folder_namekey directory_typerrr_get_win_folder_from_registrys   r5cCsddddddi|}tjd}tjjjd|dd|d }x'|D]}t|d krWd }PqWW|rtjd}tjjj|j|dr|}|jS) Nrr #rirFT) ctypescreate_unicode_bufferwindllshell32SHGetFolderPathWordkernel32GetShortPathNameWvalue)r0 csidl_constbuf has_high_charcbuf2rrr_get_win_folder_with_ctypess   rHc CsAx:dD]2}y|j|SWqttfk r8YqXqW|S)aEncode Windows paths to bytes. Only used on Python 2. Motivation is to be consistent with other operating systems where paths are also returned as bytes. This avoids problems mixing bytes and Unicode elsewhere in the codebase. For more details and discussion see . If encoding using ASCII and MBCS fails, return the original Unicode path. ASCIIMBCS)zASCIIzMBCS)encodeUnicodeEncodeError LookupError)r encodingrrrrs  r)__doc__ __future__rr r pip.compatrrpip._vendor.sixrrrrrr*r5rHr:r ImportErrorrrrrrs$   0,! (