1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
U
H=®d3eã @sŠdZdZedd„e d¡DƒƒZddlZddlZejddkZerFe    Z
ej   d¡rddl Z e   ¡ddZe  d    ¡rzd
Zq°e  d ¡rŠd Zq°d Zn ej dkrªejdkrªd
Znej Zd:dd„Zd;dd„Zd<dd„Zd=dd„Zd>dd„Zd?dd„Zd@dd„ZGd d!„d!eƒZd"d#„Zd$d%„Zd&d'„Zd(d)„Zed
krˆzdd*lmZeZ WnBe!k
r†zddl"Z#eZ Wne!k
r€eZ YnXYnXd+d,„Z$e%d-kr†d.Z&d/Z'd0Z(e)d1eƒe)d2ƒee&e'd3d4Z*e(D]Z+e)d5e+e,e*e+ƒfƒqÌe)d6ƒee&e'ƒZ*e(D]Z+e)d5e+e,e*e+ƒfƒqe)d7ƒee&ƒZ*e(D]Z+e)d5e+e,e*e+ƒfƒq2e)d8ƒee&dd9Z*e(D]Z+e)d5e+e,e*e+ƒfƒqhdS)AzyUtilities for determining application-specific dirs.
 
See <http://github.com/ActiveState/appdirs> for details and usage.
z1.4.4ccs|]}t|ƒVqdS©N)Úint)Ú.0Úsegment©rúJD:\z\workplace\VsCode\pyvenv\venv\Lib\site-packages\pip/_vendor/appdirs.pyÚ    <genexpr>srÚ.éNéÚjavaÚWindowsÚwin32ZMacÚdarwinZlinux2ÚcliÚntFcCsÆ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)
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.
        "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 "<major>.<minor>".
            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
            <http://technet.microsoft.com/en-us/library/cc766489(WS.10).aspx>
            for a discussion of issues.
 
    Typical user data directories are:
        Mac OS X:               ~/Library/Application Support/<AppName>  # or ~/.config/<AppName>, if the other does not exist
        Unix:                   ~/.local/share/<AppName>    # or in $XDG_DATA_HOME, if defined
        Win XP (not roaming):   C:\Documents and Settings\<username>\Application Data\<AppAuthor>\<AppName>
        Win XP (roaming):       C:\Documents and Settings\<username>\Local Settings\Application Data\<AppAuthor>\<AppName>
        Win 7  (not roaming):   C:\Users\<username>\AppData\Local\<AppAuthor>\<AppName>
        Win 7  (roaming):       C:\Users\<username>\AppData\Roaming\<AppAuthor>\<AppName>
 
    For Unix, we follow the XDG spec and support $XDG_DATA_HOME.
    That means, by default "~/.local/share/<AppName>".
    r NÚ CSIDL_APPDATAÚCSIDL_LOCAL_APPDATAFrz~/Library/Application Support/Ú XDG_DATA_HOMEz~/.local/share)ÚsystemÚosÚpathÚnormpathÚ_get_win_folderÚjoinÚ
expanduserÚgetenv)ÚappnameÚ    appauthorÚversionÚroamingÚconstrrrrÚ user_data_dir1s&   r!cs 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 "<major>.<minor>".
            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/<AppName>',
            if XDG_DATA_DIRS is not set
 
    Typical site data directories are:
        Mac OS X:   /Library/Application Support/<AppName>
        Unix:       /usr/local/share/<AppName> or /usr/share/<AppName>
        Win XP:     C:\Documents and Settings\All Users\Application Data\<AppAuthor>\<AppName>
        Vista:      (Fail! "C:\ProgramData" is a hidden *system* directory on Vista.)
        Win 7:      C:\ProgramData\<AppAuthor>\<AppName>   # 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.
    r NÚCSIDL_COMMON_APPDATAFrz/Library/Application SupportÚ XDG_DATA_DIRSz/usr/local/sharez
/usr/sharecSs g|]}tj | tj¡¡‘qSr©rrrÚrstripÚsep©rÚxrrrÚ
<listcomp>™sz!site_data_dir.<locals>.<listcomp>csg|]}tj |ˆ¡‘qSr©rrrr'©rrrr)sr    )
rrrrrrrrÚpathsepÚsplit©rrrÚ    multipathrÚpathlistrr+rÚ site_data_dirhs6 ÿ r1cCsXtdkrt||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 "<major>.<minor>".
            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
            <http://technet.microsoft.com/en-us/library/cc766489(WS.10).aspx>
            for a discussion of issues.
 
    Typical user config directories are:
        Mac OS X:               same as user_data_dir
        Unix:                   ~/.config/<AppName>     # 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/<AppName>".
    ©r rNÚXDG_CONFIG_HOMEz    ~/.config©rr!rrrrr©rrrrrrrrÚuser_config_dirªsr6cs”tdkr*tˆ|ƒ}ˆr|rtj ||¡}nft d¡p6d}dd„| tj¡Dƒ}ˆrv|rdtj ˆ|¡‰‡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 "<major>.<minor>".
            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/<AppName>', if XDG_CONFIG_DIRS is not set
 
    Typical site config directories are:
        Mac OS X:   same as site_data_dir
        Unix:       /etc/xdg/<AppName> or $XDG_CONFIG_DIRS[i]/<AppName> 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.
    r2ÚXDG_CONFIG_DIRSz/etc/xdgcSs$g|]}|rtj | tj¡¡‘qSrr$r'rrrr)ûsz#site_config_dir.<locals>.<listcomp>csg|]}tj |ˆ¡‘qSrr*r'r+rrr)ÿsr    )rr1rrrrr-r,r.rr+rÚsite_config_dirÔs
r8TcCsâtdkrz|dkr|}tj tdƒ¡}ts:t|tƒr:t|ƒ}|rÈ|dk    rXtj     |||¡}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 "<major>.<minor>".
            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/<AppName>
        Unix:       ~/.cache/<AppName> (XDG default)
        Win XP:     C:\Documents and Settings\<username>\Local Settings\Application Data\<AppAuthor>\<AppName>\Cache
        Vista:      C:\Users\<username>\AppData\Local\<AppAuthor>\<AppName>\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\<ProfileName>\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.
    r NrFÚCacherz~/Library/CachesÚXDG_CACHE_HOMEz~/.cache) rrrrrÚPY3Ú
isinstanceÚunicodeÚ_win_path_to_bytesrrr©rrrÚopinionrrrrÚuser_cache_dirs,! rAcCsXtdkrt||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 "<major>.<minor>".
            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
            <http://technet.microsoft.com/en-us/library/cc766489(WS.10).aspx>
            for a discussion of issues.
 
    Typical user state directories are:
        Mac OS X:  same as user_data_dir
        Unix:      ~/.local/state/<AppName>   # or in $XDG_STATE_HOME, if defined
        Win *:     same as user_data_dir
 
    For Unix, we follow this Debian proposal <https://wiki.debian.org/XDGBaseDirectorySpecification#state>
    to extend the XDG spec and support $XDG_STATE_HOME.
 
    That means, by default "~/.local/state/<AppName>".
    r2NÚXDG_STATE_HOMEz~/.local/stater4r5rrrÚuser_state_dirEsrCcCsˆ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 "<major>.<minor>".
            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/<AppName>
        Unix:       ~/.cache/<AppName>/log  # or under $XDG_CACHE_HOME if defined
        Win XP:     C:\Documents and Settings\<username>\Local Settings\Application Data\<AppAuthor>\<AppName>\Logs
        Vista:      C:\Users\<username>\AppData\Local\<AppAuthor>\<AppName>\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/Logsr FÚLogsÚlog)rrrrrr!rAr?rrrÚ user_log_diros" 
þ  rFc@sneZdZdZddd„Zedd„ƒZedd    „ƒZed
d „ƒZed d „ƒZ    edd„ƒZ
edd„ƒZ edd„ƒZ dS)ÚAppDirsz1Convenience wrapper for getting application dirs.NFcCs"||_||_||_||_||_dSr)rrrrr/)Úselfrrrrr/rrrÚ__init__¤s
zAppDirs.__init__cCst|j|j|j|jdS©N)rr)r!rrrr©rHrrrr!¬s
ÿzAppDirs.user_data_dircCst|j|j|j|jdS©N)rr/)r1rrrr/rKrrrr1±s
ÿzAppDirs.site_data_dircCst|j|j|j|jdSrJ)r6rrrrrKrrrr6¶s
ÿzAppDirs.user_config_dircCst|j|j|j|jdSrL)r8rrrr/rKrrrr8»s
ÿzAppDirs.site_config_dircCst|j|j|jdS©N©r)rArrrrKrrrrAÀs
ÿzAppDirs.user_cache_dircCst|j|j|jdSrM)rCrrrrKrrrrCÅs
ÿzAppDirs.user_state_dircCst|j|j|jdSrM)rFrrrrKrrrrFÊs
ÿzAppDirs.user_log_dir)NNNFF) Ú__name__Ú
__module__Ú __qualname__Ú__doc__rIÚpropertyr!r1r6r8rArCrFrrrrrG¢s&ÿ
 
 
 
 
 
 
rGcCsHtrddl}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.
    r    NÚAppDatazCommon AppDataz Local AppData©rr"rz@Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders)r;ÚwinregÚ_winregÚOpenKeyÚHKEY_CURRENT_USERÚ QueryValueEx)Ú
csidl_namerWÚshell_folder_nameÚkeyÚdirÚtyperrrÚ_get_win_folder_from_registryÒs
ýüþr`cCsž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) Úwin32com.shellrarbÚSHGetFolderPathÚgetattrr=ÚordÚwin32apiÚGetShortPathNameÚ ImportErrorÚ UnicodeError)r[rarbr^Ú has_high_charÚcrhrrrÚ_get_win_folder_with_pywin32ês$ 
rncCs†ddl}ddddœ|}| d¡}|jj d|dd|¡d}|D]}t|ƒdkr@d    }qZq@|r€| d¡}|jj |j|d¡r€|}|jS)
Nr    éé#érUiFrcT)    ÚctypesÚcreate_unicode_bufferÚwindllÚshell32ÚSHGetFolderPathWrgÚkernel32ÚGetShortPathNameWÚvalue)r[rrÚ csidl_constÚbufrlrmÚbuf2rrrÚ_get_win_folder_with_ctypess&ýü
 
r}c 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 érmúFrcT)ÚarrayÚcom.sunr~Úcom.sun.jna.platformr ÚWinDefÚMAX_PATHÚzerosÚShell32ÚINSTANCErerfÚShlObjÚSHGFP_TYPE_CURRENTÚNativeÚtoStringÚtostringr%rgÚKernel32ri) r[rr~r Úbuf_sizer{rbr^rlrmÚkernelrrrÚ_get_win_folder_with_jnas&      r‘)rtc
Cs8dD].}z| |¡WSttfk
r0YqXq|S)a–Encode 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
    <https://github.com/pypa/pip/issues/3463>.
 
    If encoding using ASCII and MBCS fails, return the original Unicode path.
    )ÚASCIIÚMBCS)ÚencodeÚUnicodeEncodeErrorÚ LookupError)rÚencodingrrrr>Es
r>Ú__main__ZMyAppZ    MyCompany)r!r6rArCrFr1r8z-- app dirs %s --z%-- app dirs (with optional 'version')z1.0rNz%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)-rRÚ __version__Útupler-Ú__version_info__ÚsysrÚ version_infor;Ústrr=ÚplatformÚ
startswithÚjava_verÚos_namerÚnamer!r1r6r8rArCrFÚobjectrGr`rnr}r‘rrrtrrjZ com.sun.jnaÚcomr>rOrrÚpropsÚprintÚdirsÚproprfrrrrÚ<module>s|
 
 
 
7
B
*
4
=
*
30