]>
jfr.im git - dlqueue.git/blob - venv/lib/python3.11/site-packages/pip/_vendor/platformdirs/__init__.py
2 Utilities for determining application-specific dirs. See <https://github.com/platformdirs/platformdirs> for details and
5 from __future__
import annotations
9 from typing
import TYPE_CHECKING
11 from .api
import PlatformDirsABC
12 from .version
import __version__
13 from .version
import __version_tuple__
as __version_info__
16 from pathlib
import Path
18 if sys
.version_info
>= (3, 8): # pragma: no cover (py38+)
19 from typing
import Literal
20 else: # pragma: no cover (py38+)
21 from pip
._vendor
.typing_extensions
import Literal
24 def _set_platform_dir_class() -> type[PlatformDirsABC
]:
25 if sys
.platform
== "win32":
26 from pip
._vendor
.platformdirs
.windows
import Windows
as Result
27 elif sys
.platform
== "darwin":
28 from pip
._vendor
.platformdirs
.macos
import MacOS
as Result
30 from pip
._vendor
.platformdirs
.unix
import Unix
as Result
32 if os
.getenv("ANDROID_DATA") == "/data" and os
.getenv("ANDROID_ROOT") == "/system":
33 if os
.getenv("SHELL") or os
.getenv("PREFIX"):
36 from pip
._vendor
.platformdirs
.android
import _android_folder
38 if _android_folder() is not None:
39 from pip
._vendor
.platformdirs
.android
import Android
41 return Android
# return to avoid redefinition of result
46 PlatformDirs
= _set_platform_dir_class() #: Currently active platform
47 AppDirs
= PlatformDirs
#: Backwards compatibility with appdirs
51 appname
: str |
None = None,
52 appauthor
: str |
None | Literal
[False] = None,
53 version
: str |
None = None,
54 roaming
: bool = False, # noqa: FBT001, FBT002
55 ensure_exists
: bool = False, # noqa: FBT001, FBT002
58 :param appname: See `appname <platformdirs.api.PlatformDirsABC.appname>`.
59 :param appauthor: See `appauthor <platformdirs.api.PlatformDirsABC.appauthor>`.
60 :param version: See `version <platformdirs.api.PlatformDirsABC.version>`.
61 :param roaming: See `roaming <platformdirs.api.PlatformDirsABC.roaming>`.
62 :param ensure_exists: See `ensure_exists <platformdirs.api.PlatformDirsABC.ensure_exists>`.
63 :returns: data directory tied to the user
70 ensure_exists
=ensure_exists
,
75 appname
: str |
None = None,
76 appauthor
: str |
None | Literal
[False] = None,
77 version
: str |
None = None,
78 multipath
: bool = False, # noqa: FBT001, FBT002
79 ensure_exists
: bool = False, # noqa: FBT001, FBT002
82 :param appname: See `appname <platformdirs.api.PlatformDirsABC.appname>`.
83 :param appauthor: See `appauthor <platformdirs.api.PlatformDirsABC.appauthor>`.
84 :param version: See `version <platformdirs.api.PlatformDirsABC.version>`.
85 :param multipath: See `roaming <platformdirs.api.PlatformDirsABC.multipath>`.
86 :param ensure_exists: See `ensure_exists <platformdirs.api.PlatformDirsABC.ensure_exists>`.
87 :returns: data directory shared by users
94 ensure_exists
=ensure_exists
,
99 appname
: str |
None = None,
100 appauthor
: str |
None | Literal
[False] = None,
101 version
: str |
None = None,
102 roaming
: bool = False, # noqa: FBT001, FBT002
103 ensure_exists
: bool = False, # noqa: FBT001, FBT002
106 :param appname: See `appname <platformdirs.api.PlatformDirsABC.appname>`.
107 :param appauthor: See `appauthor <platformdirs.api.PlatformDirsABC.appauthor>`.
108 :param version: See `version <platformdirs.api.PlatformDirsABC.version>`.
109 :param roaming: See `roaming <platformdirs.api.PlatformDirsABC.roaming>`.
110 :param ensure_exists: See `ensure_exists <platformdirs.api.PlatformDirsABC.ensure_exists>`.
111 :returns: config directory tied to the user
118 ensure_exists
=ensure_exists
,
123 appname
: str |
None = None,
124 appauthor
: str |
None | Literal
[False] = None,
125 version
: str |
None = None,
126 multipath
: bool = False, # noqa: FBT001, FBT002
127 ensure_exists
: bool = False, # noqa: FBT001, FBT002
130 :param appname: See `appname <platformdirs.api.PlatformDirsABC.appname>`.
131 :param appauthor: See `appauthor <platformdirs.api.PlatformDirsABC.appauthor>`.
132 :param version: See `version <platformdirs.api.PlatformDirsABC.version>`.
133 :param multipath: See `roaming <platformdirs.api.PlatformDirsABC.multipath>`.
134 :param ensure_exists: See `ensure_exists <platformdirs.api.PlatformDirsABC.ensure_exists>`.
135 :returns: config directory shared by the users
142 ensure_exists
=ensure_exists
,
147 appname
: str |
None = None,
148 appauthor
: str |
None | Literal
[False] = None,
149 version
: str |
None = None,
150 opinion
: bool = True, # noqa: FBT001, FBT002
151 ensure_exists
: bool = False, # noqa: FBT001, FBT002
154 :param appname: See `appname <platformdirs.api.PlatformDirsABC.appname>`.
155 :param appauthor: See `appauthor <platformdirs.api.PlatformDirsABC.appauthor>`.
156 :param version: See `version <platformdirs.api.PlatformDirsABC.version>`.
157 :param opinion: See `roaming <platformdirs.api.PlatformDirsABC.opinion>`.
158 :param ensure_exists: See `ensure_exists <platformdirs.api.PlatformDirsABC.ensure_exists>`.
159 :returns: cache directory tied to the user
166 ensure_exists
=ensure_exists
,
171 appname
: str |
None = None,
172 appauthor
: str |
None | Literal
[False] = None,
173 version
: str |
None = None,
174 opinion
: bool = True, # noqa: FBT001, FBT002
175 ensure_exists
: bool = False, # noqa: FBT001, FBT002
178 :param appname: See `appname <platformdirs.api.PlatformDirsABC.appname>`.
179 :param appauthor: See `appauthor <platformdirs.api.PlatformDirsABC.appauthor>`.
180 :param version: See `version <platformdirs.api.PlatformDirsABC.version>`.
181 :param opinion: See `opinion <platformdirs.api.PlatformDirsABC.opinion>`.
182 :param ensure_exists: See `ensure_exists <platformdirs.api.PlatformDirsABC.ensure_exists>`.
183 :returns: cache directory tied to the user
190 ensure_exists
=ensure_exists
,
195 appname
: str |
None = None,
196 appauthor
: str |
None | Literal
[False] = None,
197 version
: str |
None = None,
198 roaming
: bool = False, # noqa: FBT001, FBT002
199 ensure_exists
: bool = False, # noqa: FBT001, FBT002
202 :param appname: See `appname <platformdirs.api.PlatformDirsABC.appname>`.
203 :param appauthor: See `appauthor <platformdirs.api.PlatformDirsABC.appauthor>`.
204 :param version: See `version <platformdirs.api.PlatformDirsABC.version>`.
205 :param roaming: See `roaming <platformdirs.api.PlatformDirsABC.roaming>`.
206 :param ensure_exists: See `ensure_exists <platformdirs.api.PlatformDirsABC.ensure_exists>`.
207 :returns: state directory tied to the user
214 ensure_exists
=ensure_exists
,
219 appname
: str |
None = None,
220 appauthor
: str |
None | Literal
[False] = None,
221 version
: str |
None = None,
222 opinion
: bool = True, # noqa: FBT001, FBT002
223 ensure_exists
: bool = False, # noqa: FBT001, FBT002
226 :param appname: See `appname <platformdirs.api.PlatformDirsABC.appname>`.
227 :param appauthor: See `appauthor <platformdirs.api.PlatformDirsABC.appauthor>`.
228 :param version: See `version <platformdirs.api.PlatformDirsABC.version>`.
229 :param opinion: See `roaming <platformdirs.api.PlatformDirsABC.opinion>`.
230 :param ensure_exists: See `ensure_exists <platformdirs.api.PlatformDirsABC.ensure_exists>`.
231 :returns: log directory tied to the user
238 ensure_exists
=ensure_exists
,
242 def user_documents_dir() -> str:
243 """:returns: documents directory tied to the user"""
244 return PlatformDirs().user_documents_dir
247 def user_downloads_dir() -> str:
248 """:returns: downloads directory tied to the user"""
249 return PlatformDirs().user_downloads_dir
252 def user_pictures_dir() -> str:
253 """:returns: pictures directory tied to the user"""
254 return PlatformDirs().user_pictures_dir
257 def user_videos_dir() -> str:
258 """:returns: videos directory tied to the user"""
259 return PlatformDirs().user_videos_dir
262 def user_music_dir() -> str:
263 """:returns: music directory tied to the user"""
264 return PlatformDirs().user_music_dir
267 def user_runtime_dir(
268 appname
: str |
None = None,
269 appauthor
: str |
None | Literal
[False] = None,
270 version
: str |
None = None,
271 opinion
: bool = True, # noqa: FBT001, FBT002
272 ensure_exists
: bool = False, # noqa: FBT001, FBT002
275 :param appname: See `appname <platformdirs.api.PlatformDirsABC.appname>`.
276 :param appauthor: See `appauthor <platformdirs.api.PlatformDirsABC.appauthor>`.
277 :param version: See `version <platformdirs.api.PlatformDirsABC.version>`.
278 :param opinion: See `opinion <platformdirs.api.PlatformDirsABC.opinion>`.
279 :param ensure_exists: See `ensure_exists <platformdirs.api.PlatformDirsABC.ensure_exists>`.
280 :returns: runtime directory tied to the user
287 ensure_exists
=ensure_exists
,
292 appname
: str |
None = None,
293 appauthor
: str |
None | Literal
[False] = None,
294 version
: str |
None = None,
295 roaming
: bool = False, # noqa: FBT001, FBT002
296 ensure_exists
: bool = False, # noqa: FBT001, FBT002
299 :param appname: See `appname <platformdirs.api.PlatformDirsABC.appname>`.
300 :param appauthor: See `appauthor <platformdirs.api.PlatformDirsABC.appauthor>`.
301 :param version: See `version <platformdirs.api.PlatformDirsABC.version>`.
302 :param roaming: See `roaming <platformdirs.api.PlatformDirsABC.roaming>`.
303 :param ensure_exists: See `ensure_exists <platformdirs.api.PlatformDirsABC.ensure_exists>`.
304 :returns: data path tied to the user
311 ensure_exists
=ensure_exists
,
316 appname
: str |
None = None,
317 appauthor
: str |
None | Literal
[False] = None,
318 version
: str |
None = None,
319 multipath
: bool = False, # noqa: FBT001, FBT002
320 ensure_exists
: bool = False, # noqa: FBT001, FBT002
323 :param appname: See `appname <platformdirs.api.PlatformDirsABC.appname>`.
324 :param appauthor: See `appauthor <platformdirs.api.PlatformDirsABC.appauthor>`.
325 :param version: See `version <platformdirs.api.PlatformDirsABC.version>`.
326 :param multipath: See `multipath <platformdirs.api.PlatformDirsABC.multipath>`.
327 :param ensure_exists: See `ensure_exists <platformdirs.api.PlatformDirsABC.ensure_exists>`.
328 :returns: data path shared by users
335 ensure_exists
=ensure_exists
,
339 def user_config_path(
340 appname
: str |
None = None,
341 appauthor
: str |
None | Literal
[False] = None,
342 version
: str |
None = None,
343 roaming
: bool = False, # noqa: FBT001, FBT002
344 ensure_exists
: bool = False, # noqa: FBT001, FBT002
347 :param appname: See `appname <platformdirs.api.PlatformDirsABC.appname>`.
348 :param appauthor: See `appauthor <platformdirs.api.PlatformDirsABC.appauthor>`.
349 :param version: See `version <platformdirs.api.PlatformDirsABC.version>`.
350 :param roaming: See `roaming <platformdirs.api.PlatformDirsABC.roaming>`.
351 :param ensure_exists: See `ensure_exists <platformdirs.api.PlatformDirsABC.ensure_exists>`.
352 :returns: config path tied to the user
359 ensure_exists
=ensure_exists
,
363 def site_config_path(
364 appname
: str |
None = None,
365 appauthor
: str |
None | Literal
[False] = None,
366 version
: str |
None = None,
367 multipath
: bool = False, # noqa: FBT001, FBT002
368 ensure_exists
: bool = False, # noqa: FBT001, FBT002
371 :param appname: See `appname <platformdirs.api.PlatformDirsABC.appname>`.
372 :param appauthor: See `appauthor <platformdirs.api.PlatformDirsABC.appauthor>`.
373 :param version: See `version <platformdirs.api.PlatformDirsABC.version>`.
374 :param multipath: See `roaming <platformdirs.api.PlatformDirsABC.multipath>`.
375 :param ensure_exists: See `ensure_exists <platformdirs.api.PlatformDirsABC.ensure_exists>`.
376 :returns: config path shared by the users
383 ensure_exists
=ensure_exists
,
388 appname
: str |
None = None,
389 appauthor
: str |
None | Literal
[False] = None,
390 version
: str |
None = None,
391 opinion
: bool = True, # noqa: FBT001, FBT002
392 ensure_exists
: bool = False, # noqa: FBT001, FBT002
395 :param appname: See `appname <platformdirs.api.PlatformDirsABC.appname>`.
396 :param appauthor: See `appauthor <platformdirs.api.PlatformDirsABC.appauthor>`.
397 :param version: See `version <platformdirs.api.PlatformDirsABC.version>`.
398 :param opinion: See `opinion <platformdirs.api.PlatformDirsABC.opinion>`.
399 :param ensure_exists: See `ensure_exists <platformdirs.api.PlatformDirsABC.ensure_exists>`.
400 :returns: cache directory tied to the user
407 ensure_exists
=ensure_exists
,
412 appname
: str |
None = None,
413 appauthor
: str |
None | Literal
[False] = None,
414 version
: str |
None = None,
415 opinion
: bool = True, # noqa: FBT001, FBT002
416 ensure_exists
: bool = False, # noqa: FBT001, FBT002
419 :param appname: See `appname <platformdirs.api.PlatformDirsABC.appname>`.
420 :param appauthor: See `appauthor <platformdirs.api.PlatformDirsABC.appauthor>`.
421 :param version: See `version <platformdirs.api.PlatformDirsABC.version>`.
422 :param opinion: See `roaming <platformdirs.api.PlatformDirsABC.opinion>`.
423 :param ensure_exists: See `ensure_exists <platformdirs.api.PlatformDirsABC.ensure_exists>`.
424 :returns: cache path tied to the user
431 ensure_exists
=ensure_exists
,
436 appname
: str |
None = None,
437 appauthor
: str |
None | Literal
[False] = None,
438 version
: str |
None = None,
439 roaming
: bool = False, # noqa: FBT001, FBT002
440 ensure_exists
: bool = False, # noqa: FBT001, FBT002
443 :param appname: See `appname <platformdirs.api.PlatformDirsABC.appname>`.
444 :param appauthor: See `appauthor <platformdirs.api.PlatformDirsABC.appauthor>`.
445 :param version: See `version <platformdirs.api.PlatformDirsABC.version>`.
446 :param roaming: See `roaming <platformdirs.api.PlatformDirsABC.roaming>`.
447 :param ensure_exists: See `ensure_exists <platformdirs.api.PlatformDirsABC.ensure_exists>`.
448 :returns: state path tied to the user
455 ensure_exists
=ensure_exists
,
460 appname
: str |
None = None,
461 appauthor
: str |
None | Literal
[False] = None,
462 version
: str |
None = None,
463 opinion
: bool = True, # noqa: FBT001, FBT002
464 ensure_exists
: bool = False, # noqa: FBT001, FBT002
467 :param appname: See `appname <platformdirs.api.PlatformDirsABC.appname>`.
468 :param appauthor: See `appauthor <platformdirs.api.PlatformDirsABC.appauthor>`.
469 :param version: See `version <platformdirs.api.PlatformDirsABC.version>`.
470 :param opinion: See `roaming <platformdirs.api.PlatformDirsABC.opinion>`.
471 :param ensure_exists: See `ensure_exists <platformdirs.api.PlatformDirsABC.ensure_exists>`.
472 :returns: log path tied to the user
479 ensure_exists
=ensure_exists
,
483 def user_documents_path() -> Path
:
484 """:returns: documents path tied to the user"""
485 return PlatformDirs().user_documents_path
488 def user_downloads_path() -> Path
:
489 """:returns: downloads path tied to the user"""
490 return PlatformDirs().user_downloads_path
493 def user_pictures_path() -> Path
:
494 """:returns: pictures path tied to the user"""
495 return PlatformDirs().user_pictures_path
498 def user_videos_path() -> Path
:
499 """:returns: videos path tied to the user"""
500 return PlatformDirs().user_videos_path
503 def user_music_path() -> Path
:
504 """:returns: music path tied to the user"""
505 return PlatformDirs().user_music_path
508 def user_runtime_path(
509 appname
: str |
None = None,
510 appauthor
: str |
None | Literal
[False] = None,
511 version
: str |
None = None,
512 opinion
: bool = True, # noqa: FBT001, FBT002
513 ensure_exists
: bool = False, # noqa: FBT001, FBT002
516 :param appname: See `appname <platformdirs.api.PlatformDirsABC.appname>`.
517 :param appauthor: See `appauthor <platformdirs.api.PlatformDirsABC.appauthor>`.
518 :param version: See `version <platformdirs.api.PlatformDirsABC.version>`.
519 :param opinion: See `opinion <platformdirs.api.PlatformDirsABC.opinion>`.
520 :param ensure_exists: See `ensure_exists <platformdirs.api.PlatformDirsABC.ensure_exists>`.
521 :returns: runtime path tied to the user
528 ensure_exists
=ensure_exists
,
543 "user_documents_dir",
544 "user_downloads_dir",
557 "user_documents_path",
558 "user_downloads_path",
559 "user_pictures_path",