/ lib / pkg_resources / _vendor / appdirs.pyc
appdirs.pyc
  1  o

  2  6�Hc}`�@szdZdZd�eee��ZddlZddlZejddkZ	e	reZ
  3  ej�d�rDddlZe�
�ddZe�d�r9dZne�d	�rAd
  4  ZndZnejZd4d
d�Zd4dd�Zd4dd�Zd4dd�Zd5dd�Zd4dd�Zd5dd�ZGdd�de�Zdd�Zd d!�Zd"d#�Zd$d%�Zedkr�zddlZeZWn1e y�z
  5  dd&l!m"Z"eZWne y�zddl#Z$eZWne y�eZYnwYnwYnwe%d'k�r9d(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d3�Z*e(D]Z+e)d/e+e,e*e+�f��q*dSdS)6zyUtilities for determining application-specific dirs.
  6  
  7  See <http://github.com/ActiveState/appdirs> for details and usage.
  8  )����.�Nr�java�Windows�win32ZMac�darwin�linux2FcCs�tdkr/|dur
  9  |}|rdpd}tj�t|��}|r.|dur'tj�|||�}n/tj�||�}n'tdkrCtj�d�}|rBtj�||�}nt�dtj�d	��}|rVtj�||�}|ra|ratj�||�}|S)
 10  aJReturn full path to the user-specific data dir for this application.
 11  
 12          "appname" is the name of application.
 13              If None, just the system directory is returned.
 14          "appauthor" (only used on Windows) is the name of the
 15              appauthor or distributing body for this application. Typically
 16              it is the owning company name. This falls back to appname. You may
 17              pass False to disable it.
 18          "version" is an optional version path element to append to the
 19              path. You might want to use this if you want multiple versions
 20              of your app to be able to run independently. If used, this
 21              would typically be "<major>.<minor>".
 22              Only applied when appname is present.
 23          "roaming" (boolean, default False) can be set True to use the Windows
 24              roaming appdata directory. That means that for users on a Windows
 25              network setup for roaming profiles, this user data will be
 26              sync'd on login. See
 27              <http://technet.microsoft.com/en-us/library/cc766489(WS.10).aspx>
 28              for a discussion of issues.
 29  
 30      Typical user data directories are:
 31          Mac OS X:               ~/Library/Application Support/<AppName>
 32          Unix:                   ~/.local/share/<AppName>    # or in $XDG_DATA_HOME, if defined
 33          Win XP (not roaming):   C:\Documents and Settings\<username>\Application Data\<AppAuthor>\<AppName>
 34          Win XP (roaming):       C:\Documents and Settings\<username>\Local Settings\Application Data\<AppAuthor>\<AppName>
 35          Win 7  (not roaming):   C:\Users\<username>\AppData\Local\<AppAuthor>\<AppName>
 36          Win 7  (roaming):       C:\Users\<username>\AppData\Roaming\<AppAuthor>\<AppName>
 37  
 38      For Unix, we follow the XDG spec and support $XDG_DATA_HOME.
 39      That means, by default "~/.local/share/<AppName>".
 40      rN�
CSIDL_APPDATA�CSIDL_LOCAL_APPDATAFr	z~/Library/Application Support/�
XDG_DATA_HOMEz~/.local/share��system�os�path�normpath�_get_win_folder�join�
 41  expanduser�getenv)�appname�	appauthor�version�roaming�constr�r��C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.10_3.10.2800.0_x64__qbz5n2kfra8p0\lib\site-packages\pkg_resources\_vendor\appdirs.py�
user_data_dir-s* ��rcs
 42  tdkr)|dur
 43  �}tj�td��}�r(|dur!tj�||��}nWtj�|��}nOtdkr=tj�d�}�r<tj�|��}n;t�dtj�dd	g��}d
 44  d�|�	tj�D�}�rh|r_tj��|���fdd�|D�}|rrtj�|�}|S|d
}|S�r�|r�tj�||�}|S)aiReturn full path to the user-shared data dir for this application.
 45  
 46          "appname" is the name of application.
 47              If None, just the system directory is returned.
 48          "appauthor" (only used on Windows) is the name of the
 49              appauthor or distributing body for this application. Typically
 50              it is the owning company name. This falls back to appname. You may
 51              pass False to disable it.
 52          "version" is an optional version path element to append to the
 53              path. You might want to use this if you want multiple versions
 54              of your app to be able to run independently. If used, this
 55              would typically be "<major>.<minor>".
 56              Only applied when appname is present.
 57          "multipath" is an optional parameter only applicable to *nix
 58              which indicates that the entire list of data dirs should be
 59              returned. By default, the first item from XDG_DATA_DIRS is
 60              returned, or '/usr/local/share/<AppName>',
 61              if XDG_DATA_DIRS is not set
 62  
 63      Typical site data directories are:
 64          Mac OS X:   /Library/Application Support/<AppName>
 65          Unix:       /usr/local/share/<AppName> or /usr/share/<AppName>
 66          Win XP:     C:\Documents and Settings\All Users\Application Data\<AppAuthor>\<AppName>
 67          Vista:      (Fail! "C:\ProgramData" is a hidden *system* directory on Vista.)
 68          Win 7:      C:\ProgramData\<AppAuthor>\<AppName>   # Hidden, but writeable on Win 7.
 69  
 70      For Unix, this is using the $XDG_DATA_DIRS[0] default.
 71  
 72      WARNING: Do not use this on Windows. See the Vista-Fail note above for why.
 73      rN�CSIDL_COMMON_APPDATAFr	z/Library/Application Support�
XDG_DATA_DIRSz/usr/local/sharez
 74  /usr/sharecS� g|]}tj�|�tj���qSr�rrr�rstrip�sep��.0�xrrr�
 75  <listcomp>�� z!site_data_dir.<locals>.<listcomp>c�g|]
 76  }tj�|�g��qSr�rr$rr%�rrrr(��r)
 77  rrrrrrrr�pathsep�split�rrr�	multipathr�pathlistrr,r�
site_data_dirds<����r3cC�Xtdvrt||d|�}nt�dtj�d��}|rtj�||�}|r*|r*tj�||�}|S)a�Return full path to the user-specific config dir for this application.
 78  
 79          "appname" is the name of application.
 80              If None, just the system directory is returned.
 81          "appauthor" (only used on Windows) is the name of the
 82              appauthor or distributing body for this application. Typically
 83              it is the owning company name. This falls back to appname. You may
 84              pass False to disable it.
 85          "version" is an optional version path element to append to the
 86              path. You might want to use this if you want multiple versions
 87              of your app to be able to run independently. If used, this
 88              would typically be "<major>.<minor>".
 89              Only applied when appname is present.
 90          "roaming" (boolean, default False) can be set True to use the Windows
 91              roaming appdata directory. That means that for users on a Windows
 92              network setup for roaming profiles, this user data will be
 93              sync'd on login. See
 94              <http://technet.microsoft.com/en-us/library/cc766489(WS.10).aspx>
 95              for a discussion of issues.
 96  
 97      Typical user config directories are:
 98          Mac OS X:               same as user_data_dir
 99          Unix:                   ~/.config/<AppName>     # or in $XDG_CONFIG_HOME, if defined
100          Win *:                  same as user_data_dir
101  
102      For Unix, we follow the XDG spec and support $XDG_CONFIG_HOME.
103      That means, by default "~/.config/<AppName>".
104      �rr	N�XDG_CONFIG_HOMEz	~/.config�rrrrrrr�rrrrrrrr�user_config_dir�sr9cs�tdvrt�|�}�r|rtj�||�}|St�dd�}dd�|�tj�D�}�r;|r2tj��|���fdd�|D�}|rEtj�|�}|S|d}|S)aReturn full path to the user-shared data dir for this application.
105  
106          "appname" is the name of application.
107              If None, just the system directory is returned.
108          "appauthor" (only used on Windows) is the name of the
109              appauthor or distributing body for this application. Typically
110              it is the owning company name. This falls back to appname. You may
111              pass False to disable it.
112          "version" is an optional version path element to append to the
113              path. You might want to use this if you want multiple versions
114              of your app to be able to run independently. If used, this
115              would typically be "<major>.<minor>".
116              Only applied when appname is present.
117          "multipath" is an optional parameter only applicable to *nix
118              which indicates that the entire list of config dirs should be
119              returned. By default, the first item from XDG_CONFIG_DIRS is
120              returned, or '/etc/xdg/<AppName>', if XDG_CONFIG_DIRS is not set
121  
122      Typical site config directories are:
123          Mac OS X:   same as site_data_dir
124          Unix:       /etc/xdg/<AppName> or $XDG_CONFIG_DIRS[i]/<AppName> for each value in
125                      $XDG_CONFIG_DIRS
126          Win *:      same as site_data_dir
127          Vista:      (Fail! "C:\ProgramData" is a hidden *system* directory on Vista.)
128  
129      For Unix, this is using the $XDG_CONFIG_DIRS[0] default, if multipath=False
130  
131      WARNING: Do not use this on Windows. See the Vista-Fail note above for why.
132      r5�XDG_CONFIG_DIRSz/etc/xdgcSr!rr"r%rrrr(�r)z#site_config_dir.<locals>.<listcomp>cr*rr+r%r,rrr(�r-r)rr3rrrrr/r.r0rr,r�site_config_dir�s 
133  ��r;TcCs�tdkr2|dur
134  |}tj�td��}|r1|dur!tj�|||�}ntj�||�}|r1tj�|d�}n'tdkrFtj�d�}|rEtj�||�}nt�dtj�d	��}|rYtj�||�}|rd|rdtj�||�}|S)
135  aReturn full path to the user-specific cache dir for this application.
136  
137          "appname" is the name of application.
138              If None, just the system directory is returned.
139          "appauthor" (only used on Windows) is the name of the
140              appauthor or distributing body for this application. Typically
141              it is the owning company name. This falls back to appname. You may
142              pass False to disable it.
143          "version" is an optional version path element to append to the
144              path. You might want to use this if you want multiple versions
145              of your app to be able to run independently. If used, this
146              would typically be "<major>.<minor>".
147              Only applied when appname is present.
148          "opinion" (boolean) can be False to disable the appending of
149              "Cache" to the base app data dir for Windows. See
150              discussion below.
151  
152      Typical user cache directories are:
153          Mac OS X:   ~/Library/Caches/<AppName>
154          Unix:       ~/.cache/<AppName> (XDG default)
155          Win XP:     C:\Documents and Settings\<username>\Local Settings\Application Data\<AppAuthor>\<AppName>\Cache
156          Vista:      C:\Users\<username>\AppData\Local\<AppAuthor>\<AppName>\Cache
157  
158      On Windows the only suggestion in the MSDN docs is that local settings go in
159      the `CSIDL_LOCAL_APPDATA` directory. This is identical to the non-roaming
160      app data dir (the default returned by `user_data_dir` above). Apps typically
161      put cache data somewhere *under* the given dir here. Some examples:
162          ...\Mozilla\Firefox\Profiles\<ProfileName>\Cache
163          ...\Acme\SuperApp\Cache\1.0
164      OPINION: This function appends "Cache" to the `CSIDL_LOCAL_APPDATA` value.
165      This can be disabled with the `opinion=False` option.
166      rNrF�Cacher	z~/Library/Caches�XDG_CACHE_HOMEz~/.cacher�rrr�opinionrrrr�user_cache_dirs,!��r@cCr4)aReturn full path to the user-specific state dir for this application.
167  
168          "appname" is the name of application.
169              If None, just the system directory is returned.
170          "appauthor" (only used on Windows) is the name of the
171              appauthor or distributing body for this application. Typically
172              it is the owning company name. This falls back to appname. You may
173              pass False to disable it.
174          "version" is an optional version path element to append to the
175              path. You might want to use this if you want multiple versions
176              of your app to be able to run independently. If used, this
177              would typically be "<major>.<minor>".
178              Only applied when appname is present.
179          "roaming" (boolean, default False) can be set True to use the Windows
180              roaming appdata directory. That means that for users on a Windows
181              network setup for roaming profiles, this user data will be
182              sync'd on login. See
183              <http://technet.microsoft.com/en-us/library/cc766489(WS.10).aspx>
184              for a discussion of issues.
185  
186      Typical user state directories are:
187          Mac OS X:  same as user_data_dir
188          Unix:      ~/.local/state/<AppName>   # or in $XDG_STATE_HOME, if defined
189          Win *:     same as user_data_dir
190  
191      For Unix, we follow this Debian proposal <https://wiki.debian.org/XDGBaseDirectorySpecification#state>
192      to extend the XDG spec and support $XDG_STATE_HOME.
193  
194      That means, by default "~/.local/state/<AppName>".
195      r5N�XDG_STATE_HOMEz~/.local/stater7r8rrr�user_state_dir:srBcCs�tdkrtj�tj�d�|�}n'tdkr&t|||�}d}|r%tj�|d�}nt|||�}d}|r7tj�|d�}|rB|rBtj�||�}|S)a�Return full path to the user-specific log dir for this application.
196  
197          "appname" is the name of application.
198              If None, just the system directory is returned.
199          "appauthor" (only used on Windows) is the name of the
200              appauthor or distributing body for this application. Typically
201              it is the owning company name. This falls back to appname. You may
202              pass False to disable it.
203          "version" is an optional version path element to append to the
204              path. You might want to use this if you want multiple versions
205              of your app to be able to run independently. If used, this
206              would typically be "<major>.<minor>".
207              Only applied when appname is present.
208          "opinion" (boolean) can be False to disable the appending of
209              "Logs" to the base app data dir for Windows, and "log" to the
210              base cache dir for Unix. See discussion below.
211  
212      Typical user log directories are:
213          Mac OS X:   ~/Library/Logs/<AppName>
214          Unix:       ~/.cache/<AppName>/log  # or under $XDG_CACHE_HOME if defined
215          Win XP:     C:\Documents and Settings\<username>\Local Settings\Application Data\<AppAuthor>\<AppName>\Logs
216          Vista:      C:\Users\<username>\AppData\Local\<AppAuthor>\<AppName>\Logs
217  
218      On Windows the only suggestion in the MSDN docs is that local settings
219      go in the `CSIDL_LOCAL_APPDATA` directory. (Note: I'm interested in
220      examples of what some windows apps use for a logs dir.)
221  
222      OPINION: This function appends "Logs" to the `CSIDL_LOCAL_APPDATA`
223      value for Windows and appends "log" to the user cache dir for Unix.
224      This can be disabled with the `opinion=False` option.
225      r	z~/Library/LogsrF�Logs�log)rrrrrrr@r>rrr�user_log_dirds$ 
226  ��rEc@sreZdZdZ		ddd�Zedd��Zedd	��Zed
227  d��Zedd
��Z	edd��Z
228  edd��Zedd��ZdS)�AppDirsz1Convenience wrapper for getting application dirs.NFcCs"||_||_||_||_||_dS)N)rrrrr1)�selfrrrrr1rrr�__init__�s
229  
230  zAppDirs.__init__cC�t|j|j|j|jd�S�N)rr)rrrrr�rGrrrr��
231  �zAppDirs.user_data_dircCrI�N)rr1)r3rrrr1rKrrrr3�rLzAppDirs.site_data_dircCrIrJ)r9rrrrrKrrrr9�rLzAppDirs.user_config_dircCrIrM)r;rrrr1rKrrrr;�rLzAppDirs.site_config_dircC�t|j|j|jd�S�N�r)r@rrrrKrrrr@��
232  �zAppDirs.user_cache_dircCrNrO)rBrrrrKrrrrB�rQzAppDirs.user_state_dircCrNrO)rErrrrKrrrrE�rQzAppDirs.user_log_dir)NNNFF)
�__name__�
233  __module__�__qualname__�__doc__rH�propertyrr3r9r;r@rBrErrrrrF�s&
234  �
235  
236  
237  
238  
239  
240  rFcCsHtrddl}nddl}dddd�|}|�|jd�}|�||�\}}|S)z�This is a fallback technique at best. I'm not sure if using the
241      registry for this guarantees us the correct answer for all CSIDL_*
242      names.
243      rN�AppDatazCommon AppDataz
Local AppData�rrrz@Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders)�PY3�winreg�_winreg�OpenKey�HKEY_CURRENT_USER�QueryValueEx)�
244  csidl_namer[�shell_folder_name�key�dir�typerrr�_get_win_folder_from_registry�s
245  ���rdcCs�ddlm}m}|�dt||�dd�}z3t|�}d}|D]}t|�dkr(d}nq|rDz
ddl}|�|�}WW|St	yCYW|SwW|St
246  yPY|Sw)Nr)�shellcon�shellF��T)�win32com.shellrerf�SHGetFolderPath�getattr�unicode�ord�win32api�GetShortPathName�ImportError�UnicodeError)r_rerfrb�
has_high_char�crmrrr�_get_win_folder_with_pywin32�s2������rscCs�ddl}dddd�|}|�d�}|jj�d|dd|�d}|D]}t|�dkr,d	}nq |r@|�d�}|jj�|j|d�r@|}|jS)
247  Nr��#�rXiFrgT)	�ctypes�create_unicode_buffer�windll�shell32�SHGetFolderPathWrl�kernel32�GetShortPathNameW�value)r_rw�csidl_const�bufrqrr�buf2rrr�_get_win_folder_with_ctypes�s(��
248  �
249  r�cCs�ddl}ddlm}ddlm}|jjd}|�d|�}|jj	}|�
250  dt|j|�d|jj
|�|j�|����d�}d}|D]}	t|	�dkrJd	}nq>|ri|�d|�}|jj	}
251  |
252  �|||�ri|j�|����d�}|S)
253  Nr)�jna)r�rr�FrgT)�array�com.sunr��com.sun.jna.platformr�WinDef�MAX_PATH�zeros�Shell32�INSTANCErirj�ShlObj�SHGFP_TYPE_CURRENT�Native�toString�tostringr#rl�Kernel32rn)r_r�r�r�buf_sizer�rfrbrqrr�kernelrrr�_get_win_folder_with_jnas(�r�)ry�__main__ZMyAppZ	MyCompany)rr9r@rBrEr3r;z-- app dirs %s --z%-- app dirs (with optional 'version')z1.0rPz%s: %sz)
254  -- app dirs (without optional 'version')z+
255  -- app dirs (without optional 'appauthor')z(
256  -- app dirs (with disabled 'appauthor'))r)NNNF)NNNT)-rU�__version_info__r�map�str�__version__�sysr�version_inforYrk�platform�
257  startswith�java_ver�os_namerrr3r9r;r@rBrE�objectrFrdrsr�r�rh�win32comrrorwry�com.sun.jna�comrRrr�props�print�dirs�proprjrrrr�<module>s�
258  
259  
260  
261  
262  7
263  B
264  (
265  3
266  9
267  *30�����
268  
269  �