U ÀÒ.e&&ã@sÊdZddlmZddlZddlZddlmZmZddlm Z m Z ddl m Z e r\ddl mZdd „Zdd d „Zddd„Zdd„Zdd„Zdd„Ze r¾zddlZeZWnek r¼eZYnXdd„ZdS)zd This code was taken from https://github.com/ActiveState/appdirs and modified to suit our purposes. é)Úabsolute_importN)ÚPY2Ú text_type)ÚWINDOWSÚ expanduser)ÚMYPY_CHECK_RUNNING)ÚListcCs€tr 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_APPDATAZCacheÚdarwinz~/Library/CachesZXDG_CACHE_HOMEz~/.cache)rÚosÚpathÚnormpathÚ_get_win_folderrÚ isinstancerÚ_win_path_to_bytesÚjoinÚsysÚplatformrÚgetenv)Úappnamer ©rú?/usr/lib/python3.8/site-packages/pip/_internal/utils/appdirs.pyÚuser_cache_dirs rFcCs”tr,|r dpd}tj tj t|ƒ¡|¡}ndtjdkrvtj tj t dƒ|¡¡rbtj t dƒ|¡ntj t dƒ|¡}ntj t  dt dƒ¡|¡}|S)aœ 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/ if it exists, else ~/.config/ 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_APPDATAr r z~/Library/Application Support/z ~/.config/Z XDG_DATA_HOMEz~/.local/share) rr r rr rrrÚisdirrr)rÚroamingÚconstr rrrÚ user_data_dirHs,   þýþþù þrTcCsHtrt||d�}n2tjdkr&t|ƒ}nt dtdƒ¡}tj ||¡}|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 ZXDG_CONFIG_HOMEz ~/.config) rrrrr rrr r)rrr rrrÚuser_config_dir}s  rcs€tr&tj tdƒ¡}tj |ˆ¡g}nVtjdkrBtj dˆ¡g}n:t dd¡}|rn‡fdd„|  tj ¡Dƒ}ng}|  d¡|S) a�Return 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 SupportZXDG_CONFIG_DIRSz/etc/xdgcsg|]}tj t|ƒˆ¡‘qSr)r r rr)Ú.0Úx©rrrÚ ¹sÿz$site_config_dirs..z/etc) rr r r rrrrrÚsplitÚpathsepÚappend)rr ZpathlistZxdg_config_dirsrr"rÚsite_config_dirsŸs    þ r'cCs:ddl}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©rrr z@Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders)Ú_winregÚOpenKeyÚHKEY_CURRENT_USERZ QueryValueEx)Ú csidl_namer)Zshell_folder_nameÚkeyZ directoryZ_typerrrÚ_get_win_folder_from_registryÈsýüþr.cCs€ddddœ|}t d¡}tj}|j d|dd|¡d}|D]}t|ƒdkr. If encoding using ASCII and MBCS fails, return the original Unicode path. )ÚASCIIZMBCS)ÚencodeÚUnicodeEncodeErrorÚ LookupError)r Úencodingrrrrs r)F)T)Ú__doc__Z __future__rr rZpip._vendor.sixrrZpip._internal.utils.compatrrZpip._internal.utils.typingrÚtypingrrrrr'r.r8r3rÚ ImportErrorrrrrrÚs*   1 5 ")