1"""Utilities for determining application-specific dirs.
2
3Provides convenience functions (e.g. :func:`user_data_dir`, :func:`user_config_path`), a :data:`PlatformDirs` class that
4auto-detects the current platform, and the :class:`~platformdirs.api.PlatformDirsABC` base class.
5
6See <https://github.com/platformdirs/platformdirs> for details and usage.
7
8"""
9
10from __future__ import annotations
11
12import os
13import sys
14from typing import TYPE_CHECKING
15
16from .api import PlatformDirsABC
17from .version import __version__
18from .version import __version_tuple__ as __version_info__
19
20if TYPE_CHECKING:
21 from pathlib import Path
22 from typing import Literal
23
24if sys.platform == "win32":
25 from platformdirs.windows import Windows as _Result
26elif sys.platform == "darwin":
27 from platformdirs.macos import MacOS as _Result
28else:
29 from platformdirs.unix import Unix as _Result
30
31
32def _set_platform_dir_class() -> type[PlatformDirsABC]:
33 if os.getenv("ANDROID_DATA") == "/data" and os.getenv("ANDROID_ROOT") == "/system":
34 if os.getenv("SHELL") or os.getenv("PREFIX"):
35 return _Result
36
37 from platformdirs.android import _android_folder # noqa: PLC0415
38
39 if _android_folder() is not None:
40 from platformdirs.android import Android # noqa: PLC0415
41
42 return Android # return to avoid redefinition of a result
43
44 return _Result
45
46
47if TYPE_CHECKING:
48 # Work around mypy issue: https://github.com/python/mypy/issues/10962
49 PlatformDirs = _Result
50else:
51 PlatformDirs = _set_platform_dir_class() #: Currently active platform
52AppDirs = PlatformDirs #: Backwards compatibility with appdirs
53
54
55def user_data_dir( # noqa: PLR0913, PLR0917
56 appname: str | None = None,
57 appauthor: str | Literal[False] | None = None,
58 version: str | None = None,
59 roaming: bool = False, # noqa: FBT001, FBT002
60 ensure_exists: bool = False, # noqa: FBT001, FBT002
61 use_site_for_root: bool = False, # noqa: FBT001, FBT002
62) -> str:
63 """:param appname: See `appname <platformdirs.api.PlatformDirsABC.appname>`.
64 :param appauthor: See `appauthor <platformdirs.api.PlatformDirsABC.appauthor>`.
65 :param version: See `version <platformdirs.api.PlatformDirsABC.version>`.
66 :param roaming: See `roaming <platformdirs.api.PlatformDirsABC.roaming>`.
67 :param ensure_exists: See `ensure_exists <platformdirs.api.PlatformDirsABC.ensure_exists>`.
68 :param use_site_for_root: See `use_site_for_root <platformdirs.api.PlatformDirsABC.use_site_for_root>`.
69
70 :returns: data directory tied to the user
71
72 """
73 return PlatformDirs(
74 appname=appname,
75 appauthor=appauthor,
76 version=version,
77 roaming=roaming,
78 ensure_exists=ensure_exists,
79 use_site_for_root=use_site_for_root,
80 ).user_data_dir
81
82
83def site_data_dir(
84 appname: str | None = None,
85 appauthor: str | Literal[False] | None = None,
86 version: str | None = None,
87 multipath: bool = False, # noqa: FBT001, FBT002
88 ensure_exists: bool = False, # noqa: FBT001, FBT002
89) -> str:
90 """:param appname: See `appname <platformdirs.api.PlatformDirsABC.appname>`.
91 :param appauthor: See `appauthor <platformdirs.api.PlatformDirsABC.appauthor>`.
92 :param version: See `version <platformdirs.api.PlatformDirsABC.version>`.
93 :param multipath: See `multipath <platformdirs.api.PlatformDirsABC.multipath>`.
94 :param ensure_exists: See `ensure_exists <platformdirs.api.PlatformDirsABC.ensure_exists>`.
95
96 :returns: data directory shared by users
97
98 """
99 return PlatformDirs(
100 appname=appname,
101 appauthor=appauthor,
102 version=version,
103 multipath=multipath,
104 ensure_exists=ensure_exists,
105 ).site_data_dir
106
107
108def user_config_dir( # noqa: PLR0913, PLR0917
109 appname: str | None = None,
110 appauthor: str | Literal[False] | None = None,
111 version: str | None = None,
112 roaming: bool = False, # noqa: FBT001, FBT002
113 ensure_exists: bool = False, # noqa: FBT001, FBT002
114 use_site_for_root: bool = False, # noqa: FBT001, FBT002
115) -> str:
116 """:param appname: See `appname <platformdirs.api.PlatformDirsABC.appname>`.
117 :param appauthor: See `appauthor <platformdirs.api.PlatformDirsABC.appauthor>`.
118 :param version: See `version <platformdirs.api.PlatformDirsABC.version>`.
119 :param roaming: See `roaming <platformdirs.api.PlatformDirsABC.roaming>`.
120 :param ensure_exists: See `ensure_exists <platformdirs.api.PlatformDirsABC.ensure_exists>`.
121 :param use_site_for_root: See `use_site_for_root <platformdirs.api.PlatformDirsABC.use_site_for_root>`.
122
123 :returns: config directory tied to the user
124
125 """
126 return PlatformDirs(
127 appname=appname,
128 appauthor=appauthor,
129 version=version,
130 roaming=roaming,
131 ensure_exists=ensure_exists,
132 use_site_for_root=use_site_for_root,
133 ).user_config_dir
134
135
136def site_config_dir(
137 appname: str | None = None,
138 appauthor: str | Literal[False] | None = None,
139 version: str | None = None,
140 multipath: bool = False, # noqa: FBT001, FBT002
141 ensure_exists: bool = False, # noqa: FBT001, FBT002
142) -> str:
143 """:param appname: See `appname <platformdirs.api.PlatformDirsABC.appname>`.
144 :param appauthor: See `appauthor <platformdirs.api.PlatformDirsABC.appauthor>`.
145 :param version: See `version <platformdirs.api.PlatformDirsABC.version>`.
146 :param multipath: See `multipath <platformdirs.api.PlatformDirsABC.multipath>`.
147 :param ensure_exists: See `ensure_exists <platformdirs.api.PlatformDirsABC.ensure_exists>`.
148
149 :returns: config directory shared by users
150
151 """
152 return PlatformDirs(
153 appname=appname,
154 appauthor=appauthor,
155 version=version,
156 multipath=multipath,
157 ensure_exists=ensure_exists,
158 ).site_config_dir
159
160
161def user_cache_dir( # noqa: PLR0913, PLR0917
162 appname: str | None = None,
163 appauthor: str | Literal[False] | None = None,
164 version: str | None = None,
165 opinion: bool = True, # noqa: FBT001, FBT002
166 ensure_exists: bool = False, # noqa: FBT001, FBT002
167 use_site_for_root: bool = False, # noqa: FBT001, FBT002
168) -> str:
169 """:param appname: See `appname <platformdirs.api.PlatformDirsABC.appname>`.
170 :param appauthor: See `appauthor <platformdirs.api.PlatformDirsABC.appauthor>`.
171 :param version: See `version <platformdirs.api.PlatformDirsABC.version>`.
172 :param opinion: See `opinion <platformdirs.api.PlatformDirsABC.opinion>`.
173 :param ensure_exists: See `ensure_exists <platformdirs.api.PlatformDirsABC.ensure_exists>`.
174 :param use_site_for_root: See `use_site_for_root <platformdirs.api.PlatformDirsABC.use_site_for_root>`.
175
176 :returns: cache directory tied to the user
177
178 """
179 return PlatformDirs(
180 appname=appname,
181 appauthor=appauthor,
182 version=version,
183 opinion=opinion,
184 ensure_exists=ensure_exists,
185 use_site_for_root=use_site_for_root,
186 ).user_cache_dir
187
188
189def site_cache_dir(
190 appname: str | None = None,
191 appauthor: str | Literal[False] | None = None,
192 version: str | None = None,
193 opinion: bool = True, # noqa: FBT001, FBT002
194 ensure_exists: bool = False, # noqa: FBT001, FBT002
195) -> str:
196 """:param appname: See `appname <platformdirs.api.PlatformDirsABC.appname>`.
197 :param appauthor: See `appauthor <platformdirs.api.PlatformDirsABC.appauthor>`.
198 :param version: See `version <platformdirs.api.PlatformDirsABC.version>`.
199 :param opinion: See `opinion <platformdirs.api.PlatformDirsABC.opinion>`.
200 :param ensure_exists: See `ensure_exists <platformdirs.api.PlatformDirsABC.ensure_exists>`.
201
202 :returns: cache directory shared by users
203
204 """
205 return PlatformDirs(
206 appname=appname,
207 appauthor=appauthor,
208 version=version,
209 opinion=opinion,
210 ensure_exists=ensure_exists,
211 ).site_cache_dir
212
213
214def user_state_dir( # noqa: PLR0913, PLR0917
215 appname: str | None = None,
216 appauthor: str | Literal[False] | None = None,
217 version: str | None = None,
218 roaming: bool = False, # noqa: FBT001, FBT002
219 ensure_exists: bool = False, # noqa: FBT001, FBT002
220 use_site_for_root: bool = False, # noqa: FBT001, FBT002
221) -> str:
222 """:param appname: See `appname <platformdirs.api.PlatformDirsABC.appname>`.
223 :param appauthor: See `appauthor <platformdirs.api.PlatformDirsABC.appauthor>`.
224 :param version: See `version <platformdirs.api.PlatformDirsABC.version>`.
225 :param roaming: See `roaming <platformdirs.api.PlatformDirsABC.roaming>`.
226 :param ensure_exists: See `ensure_exists <platformdirs.api.PlatformDirsABC.ensure_exists>`.
227 :param use_site_for_root: See `use_site_for_root <platformdirs.api.PlatformDirsABC.use_site_for_root>`.
228
229 :returns: state directory tied to the user
230
231 """
232 return PlatformDirs(
233 appname=appname,
234 appauthor=appauthor,
235 version=version,
236 roaming=roaming,
237 ensure_exists=ensure_exists,
238 use_site_for_root=use_site_for_root,
239 ).user_state_dir
240
241
242def site_state_dir(
243 appname: str | None = None,
244 appauthor: str | Literal[False] | None = None,
245 version: str | None = None,
246 ensure_exists: bool = False, # noqa: FBT001, FBT002
247) -> str:
248 """:param appname: See `appname <platformdirs.api.PlatformDirsABC.appname>`.
249 :param appauthor: See `appauthor <platformdirs.api.PlatformDirsABC.appauthor>`.
250 :param version: See `version <platformdirs.api.PlatformDirsABC.version>`.
251 :param ensure_exists: See `ensure_exists <platformdirs.api.PlatformDirsABC.ensure_exists>`.
252
253 :returns: state directory shared by users
254
255 """
256 return PlatformDirs(
257 appname=appname,
258 appauthor=appauthor,
259 version=version,
260 ensure_exists=ensure_exists,
261 ).site_state_dir
262
263
264def user_log_dir( # noqa: PLR0913, PLR0917
265 appname: str | None = None,
266 appauthor: str | Literal[False] | None = None,
267 version: str | None = None,
268 opinion: bool = True, # noqa: FBT001, FBT002
269 ensure_exists: bool = False, # noqa: FBT001, FBT002
270 use_site_for_root: bool = False, # noqa: FBT001, FBT002
271) -> str:
272 """:param appname: See `appname <platformdirs.api.PlatformDirsABC.appname>`.
273 :param appauthor: See `appauthor <platformdirs.api.PlatformDirsABC.appauthor>`.
274 :param version: See `version <platformdirs.api.PlatformDirsABC.version>`.
275 :param opinion: See `opinion <platformdirs.api.PlatformDirsABC.opinion>`.
276 :param ensure_exists: See `ensure_exists <platformdirs.api.PlatformDirsABC.ensure_exists>`.
277 :param use_site_for_root: See `use_site_for_root <platformdirs.api.PlatformDirsABC.use_site_for_root>`.
278
279 :returns: log directory tied to the user
280
281 """
282 return PlatformDirs(
283 appname=appname,
284 appauthor=appauthor,
285 version=version,
286 opinion=opinion,
287 ensure_exists=ensure_exists,
288 use_site_for_root=use_site_for_root,
289 ).user_log_dir
290
291
292def site_log_dir(
293 appname: str | None = None,
294 appauthor: str | Literal[False] | None = None,
295 version: str | None = None,
296 opinion: bool = True, # noqa: FBT001, FBT002
297 ensure_exists: bool = False, # noqa: FBT001, FBT002
298) -> str:
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 opinion: See `opinion <platformdirs.api.PlatformDirsABC.opinion>`.
303 :param ensure_exists: See `ensure_exists <platformdirs.api.PlatformDirsABC.ensure_exists>`.
304
305 :returns: log directory shared by users
306
307 """
308 return PlatformDirs(
309 appname=appname,
310 appauthor=appauthor,
311 version=version,
312 opinion=opinion,
313 ensure_exists=ensure_exists,
314 ).site_log_dir
315
316
317def user_documents_dir() -> str:
318 """:returns: documents directory tied to the user"""
319 return PlatformDirs().user_documents_dir
320
321
322def user_downloads_dir() -> str:
323 """:returns: downloads directory tied to the user"""
324 return PlatformDirs().user_downloads_dir
325
326
327def user_pictures_dir() -> str:
328 """:returns: pictures directory tied to the user"""
329 return PlatformDirs().user_pictures_dir
330
331
332def user_videos_dir() -> str:
333 """:returns: videos directory tied to the user"""
334 return PlatformDirs().user_videos_dir
335
336
337def user_music_dir() -> str:
338 """:returns: music directory tied to the user"""
339 return PlatformDirs().user_music_dir
340
341
342def user_desktop_dir() -> str:
343 """:returns: desktop directory tied to the user"""
344 return PlatformDirs().user_desktop_dir
345
346
347def user_projects_dir() -> str:
348 """:returns: projects directory tied to the user"""
349 return PlatformDirs().user_projects_dir
350
351
352def user_publicshare_dir() -> str:
353 """:returns: public share directory tied to the user"""
354 return PlatformDirs().user_publicshare_dir
355
356
357def user_templates_dir() -> str:
358 """:returns: templates directory tied to the user"""
359 return PlatformDirs().user_templates_dir
360
361
362def user_fonts_dir() -> str:
363 """:returns: fonts directory tied to the user"""
364 return PlatformDirs().user_fonts_dir
365
366
367def user_preference_dir() -> str:
368 """:returns: preference directory tied to the user"""
369 return PlatformDirs().user_preference_dir
370
371
372def user_bin_dir() -> str:
373 """:returns: bin directory tied to the user"""
374 return PlatformDirs().user_bin_dir
375
376
377def site_bin_dir() -> str:
378 """:returns: bin directory shared by users"""
379 return PlatformDirs().site_bin_dir
380
381
382def user_applications_dir() -> str:
383 """:returns: applications directory tied to the user"""
384 return PlatformDirs().user_applications_dir
385
386
387def site_applications_dir(
388 multipath: bool = False, # noqa: FBT001, FBT002
389 ensure_exists: bool = False, # noqa: FBT001, FBT002
390) -> str:
391 """:param multipath: See `multipath <platformdirs.api.PlatformDirsABC.multipath>`.
392 :param ensure_exists: See `ensure_exists <platformdirs.api.PlatformDirsABC.ensure_exists>`.
393
394 :returns: applications directory shared by users
395
396 """
397 return PlatformDirs(
398 multipath=multipath,
399 ensure_exists=ensure_exists,
400 ).site_applications_dir
401
402
403def user_runtime_dir( # noqa: PLR0913, PLR0917
404 appname: str | None = None,
405 appauthor: str | Literal[False] | None = None,
406 version: str | None = None,
407 opinion: bool = True, # noqa: FBT001, FBT002
408 ensure_exists: bool = False, # noqa: FBT001, FBT002
409 use_site_for_root: bool = False, # noqa: FBT001, FBT002
410) -> str:
411 """:param appname: See `appname <platformdirs.api.PlatformDirsABC.appname>`.
412 :param appauthor: See `appauthor <platformdirs.api.PlatformDirsABC.appauthor>`.
413 :param version: See `version <platformdirs.api.PlatformDirsABC.version>`.
414 :param opinion: See `opinion <platformdirs.api.PlatformDirsABC.opinion>`.
415 :param ensure_exists: See `ensure_exists <platformdirs.api.PlatformDirsABC.ensure_exists>`.
416 :param use_site_for_root: See `use_site_for_root <platformdirs.api.PlatformDirsABC.use_site_for_root>`.
417
418 :returns: runtime directory tied to the user
419
420 """
421 return PlatformDirs(
422 appname=appname,
423 appauthor=appauthor,
424 version=version,
425 opinion=opinion,
426 ensure_exists=ensure_exists,
427 use_site_for_root=use_site_for_root,
428 ).user_runtime_dir
429
430
431def site_runtime_dir(
432 appname: str | None = None,
433 appauthor: str | Literal[False] | None = None,
434 version: str | None = None,
435 opinion: bool = True, # noqa: FBT001, FBT002
436 ensure_exists: bool = False, # noqa: FBT001, FBT002
437) -> str:
438 """:param appname: See `appname <platformdirs.api.PlatformDirsABC.appname>`.
439 :param appauthor: See `appauthor <platformdirs.api.PlatformDirsABC.appauthor>`.
440 :param version: See `version <platformdirs.api.PlatformDirsABC.version>`.
441 :param opinion: See `opinion <platformdirs.api.PlatformDirsABC.opinion>`.
442 :param ensure_exists: See `ensure_exists <platformdirs.api.PlatformDirsABC.ensure_exists>`.
443
444 :returns: runtime directory shared by users
445
446 """
447 return PlatformDirs(
448 appname=appname,
449 appauthor=appauthor,
450 version=version,
451 opinion=opinion,
452 ensure_exists=ensure_exists,
453 ).site_runtime_dir
454
455
456def user_data_path( # noqa: PLR0913, PLR0917
457 appname: str | None = None,
458 appauthor: str | Literal[False] | None = None,
459 version: str | None = None,
460 roaming: bool = False, # noqa: FBT001, FBT002
461 ensure_exists: bool = False, # noqa: FBT001, FBT002
462 use_site_for_root: bool = False, # noqa: FBT001, FBT002
463) -> Path:
464 """:param appname: See `appname <platformdirs.api.PlatformDirsABC.appname>`.
465 :param appauthor: See `appauthor <platformdirs.api.PlatformDirsABC.appauthor>`.
466 :param version: See `version <platformdirs.api.PlatformDirsABC.version>`.
467 :param roaming: See `roaming <platformdirs.api.PlatformDirsABC.roaming>`.
468 :param ensure_exists: See `ensure_exists <platformdirs.api.PlatformDirsABC.ensure_exists>`.
469 :param use_site_for_root: See `use_site_for_root <platformdirs.api.PlatformDirsABC.use_site_for_root>`.
470
471 :returns: data path tied to the user
472
473 """
474 return PlatformDirs(
475 appname=appname,
476 appauthor=appauthor,
477 version=version,
478 roaming=roaming,
479 ensure_exists=ensure_exists,
480 use_site_for_root=use_site_for_root,
481 ).user_data_path
482
483
484def site_data_path(
485 appname: str | None = None,
486 appauthor: str | Literal[False] | None = None,
487 version: str | None = None,
488 multipath: bool = False, # noqa: FBT001, FBT002
489 ensure_exists: bool = False, # noqa: FBT001, FBT002
490) -> Path:
491 """:param appname: See `appname <platformdirs.api.PlatformDirsABC.appname>`.
492 :param appauthor: See `appauthor <platformdirs.api.PlatformDirsABC.appauthor>`.
493 :param version: See `version <platformdirs.api.PlatformDirsABC.version>`.
494 :param multipath: See `multipath <platformdirs.api.PlatformDirsABC.multipath>`.
495 :param ensure_exists: See `ensure_exists <platformdirs.api.PlatformDirsABC.ensure_exists>`.
496
497 :returns: data path shared by users
498
499 """
500 return PlatformDirs(
501 appname=appname,
502 appauthor=appauthor,
503 version=version,
504 multipath=multipath,
505 ensure_exists=ensure_exists,
506 ).site_data_path
507
508
509def user_config_path( # noqa: PLR0913, PLR0917
510 appname: str | None = None,
511 appauthor: str | Literal[False] | None = None,
512 version: str | None = None,
513 roaming: bool = False, # noqa: FBT001, FBT002
514 ensure_exists: bool = False, # noqa: FBT001, FBT002
515 use_site_for_root: bool = False, # noqa: FBT001, FBT002
516) -> Path:
517 """:param appname: See `appname <platformdirs.api.PlatformDirsABC.appname>`.
518 :param appauthor: See `appauthor <platformdirs.api.PlatformDirsABC.appauthor>`.
519 :param version: See `version <platformdirs.api.PlatformDirsABC.version>`.
520 :param roaming: See `roaming <platformdirs.api.PlatformDirsABC.roaming>`.
521 :param ensure_exists: See `ensure_exists <platformdirs.api.PlatformDirsABC.ensure_exists>`.
522 :param use_site_for_root: See `use_site_for_root <platformdirs.api.PlatformDirsABC.use_site_for_root>`.
523
524 :returns: config path tied to the user
525
526 """
527 return PlatformDirs(
528 appname=appname,
529 appauthor=appauthor,
530 version=version,
531 roaming=roaming,
532 ensure_exists=ensure_exists,
533 use_site_for_root=use_site_for_root,
534 ).user_config_path
535
536
537def site_config_path(
538 appname: str | None = None,
539 appauthor: str | Literal[False] | None = None,
540 version: str | None = None,
541 multipath: bool = False, # noqa: FBT001, FBT002
542 ensure_exists: bool = False, # noqa: FBT001, FBT002
543) -> Path:
544 """:param appname: See `appname <platformdirs.api.PlatformDirsABC.appname>`.
545 :param appauthor: See `appauthor <platformdirs.api.PlatformDirsABC.appauthor>`.
546 :param version: See `version <platformdirs.api.PlatformDirsABC.version>`.
547 :param multipath: See `multipath <platformdirs.api.PlatformDirsABC.multipath>`.
548 :param ensure_exists: See `ensure_exists <platformdirs.api.PlatformDirsABC.ensure_exists>`.
549
550 :returns: config path shared by users
551
552 """
553 return PlatformDirs(
554 appname=appname,
555 appauthor=appauthor,
556 version=version,
557 multipath=multipath,
558 ensure_exists=ensure_exists,
559 ).site_config_path
560
561
562def site_cache_path(
563 appname: str | None = None,
564 appauthor: str | Literal[False] | None = None,
565 version: str | None = None,
566 opinion: bool = True, # noqa: FBT001, FBT002
567 ensure_exists: bool = False, # noqa: FBT001, FBT002
568) -> Path:
569 """:param appname: See `appname <platformdirs.api.PlatformDirsABC.appname>`.
570 :param appauthor: See `appauthor <platformdirs.api.PlatformDirsABC.appauthor>`.
571 :param version: See `version <platformdirs.api.PlatformDirsABC.version>`.
572 :param opinion: See `opinion <platformdirs.api.PlatformDirsABC.opinion>`.
573 :param ensure_exists: See `ensure_exists <platformdirs.api.PlatformDirsABC.ensure_exists>`.
574
575 :returns: cache path shared by users
576
577 """
578 return PlatformDirs(
579 appname=appname,
580 appauthor=appauthor,
581 version=version,
582 opinion=opinion,
583 ensure_exists=ensure_exists,
584 ).site_cache_path
585
586
587def user_cache_path( # noqa: PLR0913, PLR0917
588 appname: str | None = None,
589 appauthor: str | Literal[False] | None = None,
590 version: str | None = None,
591 opinion: bool = True, # noqa: FBT001, FBT002
592 ensure_exists: bool = False, # noqa: FBT001, FBT002
593 use_site_for_root: bool = False, # noqa: FBT001, FBT002
594) -> Path:
595 """:param appname: See `appname <platformdirs.api.PlatformDirsABC.appname>`.
596 :param appauthor: See `appauthor <platformdirs.api.PlatformDirsABC.appauthor>`.
597 :param version: See `version <platformdirs.api.PlatformDirsABC.version>`.
598 :param opinion: See `opinion <platformdirs.api.PlatformDirsABC.opinion>`.
599 :param ensure_exists: See `ensure_exists <platformdirs.api.PlatformDirsABC.ensure_exists>`.
600 :param use_site_for_root: See `use_site_for_root <platformdirs.api.PlatformDirsABC.use_site_for_root>`.
601
602 :returns: cache path tied to the user
603
604 """
605 return PlatformDirs(
606 appname=appname,
607 appauthor=appauthor,
608 version=version,
609 opinion=opinion,
610 ensure_exists=ensure_exists,
611 use_site_for_root=use_site_for_root,
612 ).user_cache_path
613
614
615def user_state_path( # noqa: PLR0913, PLR0917
616 appname: str | None = None,
617 appauthor: str | Literal[False] | None = None,
618 version: str | None = None,
619 roaming: bool = False, # noqa: FBT001, FBT002
620 ensure_exists: bool = False, # noqa: FBT001, FBT002
621 use_site_for_root: bool = False, # noqa: FBT001, FBT002
622) -> Path:
623 """:param appname: See `appname <platformdirs.api.PlatformDirsABC.appname>`.
624 :param appauthor: See `appauthor <platformdirs.api.PlatformDirsABC.appauthor>`.
625 :param version: See `version <platformdirs.api.PlatformDirsABC.version>`.
626 :param roaming: See `roaming <platformdirs.api.PlatformDirsABC.roaming>`.
627 :param ensure_exists: See `ensure_exists <platformdirs.api.PlatformDirsABC.ensure_exists>`.
628 :param use_site_for_root: See `use_site_for_root <platformdirs.api.PlatformDirsABC.use_site_for_root>`.
629
630 :returns: state path tied to the user
631
632 """
633 return PlatformDirs(
634 appname=appname,
635 appauthor=appauthor,
636 version=version,
637 roaming=roaming,
638 ensure_exists=ensure_exists,
639 use_site_for_root=use_site_for_root,
640 ).user_state_path
641
642
643def site_state_path(
644 appname: str | None = None,
645 appauthor: str | Literal[False] | None = None,
646 version: str | None = None,
647 ensure_exists: bool = False, # noqa: FBT001, FBT002
648) -> Path:
649 """:param appname: See `appname <platformdirs.api.PlatformDirsABC.appname>`.
650 :param appauthor: See `appauthor <platformdirs.api.PlatformDirsABC.appauthor>`.
651 :param version: See `version <platformdirs.api.PlatformDirsABC.version>`.
652 :param ensure_exists: See `ensure_exists <platformdirs.api.PlatformDirsABC.ensure_exists>`.
653
654 :returns: state path shared by users
655
656 """
657 return PlatformDirs(
658 appname=appname,
659 appauthor=appauthor,
660 version=version,
661 ensure_exists=ensure_exists,
662 ).site_state_path
663
664
665def user_log_path( # noqa: PLR0913, PLR0917
666 appname: str | None = None,
667 appauthor: str | Literal[False] | None = None,
668 version: str | None = None,
669 opinion: bool = True, # noqa: FBT001, FBT002
670 ensure_exists: bool = False, # noqa: FBT001, FBT002
671 use_site_for_root: bool = False, # noqa: FBT001, FBT002
672) -> Path:
673 """:param appname: See `appname <platformdirs.api.PlatformDirsABC.appname>`.
674 :param appauthor: See `appauthor <platformdirs.api.PlatformDirsABC.appauthor>`.
675 :param version: See `version <platformdirs.api.PlatformDirsABC.version>`.
676 :param opinion: See `opinion <platformdirs.api.PlatformDirsABC.opinion>`.
677 :param ensure_exists: See `ensure_exists <platformdirs.api.PlatformDirsABC.ensure_exists>`.
678 :param use_site_for_root: See `use_site_for_root <platformdirs.api.PlatformDirsABC.use_site_for_root>`.
679
680 :returns: log path tied to the user
681
682 """
683 return PlatformDirs(
684 appname=appname,
685 appauthor=appauthor,
686 version=version,
687 opinion=opinion,
688 ensure_exists=ensure_exists,
689 use_site_for_root=use_site_for_root,
690 ).user_log_path
691
692
693def site_log_path(
694 appname: str | None = None,
695 appauthor: str | Literal[False] | None = None,
696 version: str | None = None,
697 opinion: bool = True, # noqa: FBT001, FBT002
698 ensure_exists: bool = False, # noqa: FBT001, FBT002
699) -> Path:
700 """:param appname: See `appname <platformdirs.api.PlatformDirsABC.appname>`.
701 :param appauthor: See `appauthor <platformdirs.api.PlatformDirsABC.appauthor>`.
702 :param version: See `version <platformdirs.api.PlatformDirsABC.version>`.
703 :param opinion: See `opinion <platformdirs.api.PlatformDirsABC.opinion>`.
704 :param ensure_exists: See `ensure_exists <platformdirs.api.PlatformDirsABC.ensure_exists>`.
705
706 :returns: log path shared by users
707
708 """
709 return PlatformDirs(
710 appname=appname,
711 appauthor=appauthor,
712 version=version,
713 opinion=opinion,
714 ensure_exists=ensure_exists,
715 ).site_log_path
716
717
718def user_documents_path() -> Path:
719 """:returns: documents path tied to the user"""
720 return PlatformDirs().user_documents_path
721
722
723def user_downloads_path() -> Path:
724 """:returns: downloads path tied to the user"""
725 return PlatformDirs().user_downloads_path
726
727
728def user_pictures_path() -> Path:
729 """:returns: pictures path tied to the user"""
730 return PlatformDirs().user_pictures_path
731
732
733def user_videos_path() -> Path:
734 """:returns: videos path tied to the user"""
735 return PlatformDirs().user_videos_path
736
737
738def user_music_path() -> Path:
739 """:returns: music path tied to the user"""
740 return PlatformDirs().user_music_path
741
742
743def user_desktop_path() -> Path:
744 """:returns: desktop path tied to the user"""
745 return PlatformDirs().user_desktop_path
746
747
748def user_projects_path() -> Path:
749 """:returns: projects path tied to the user"""
750 return PlatformDirs().user_projects_path
751
752
753def user_publicshare_path() -> Path:
754 """:returns: public share path tied to the user"""
755 return PlatformDirs().user_publicshare_path
756
757
758def user_templates_path() -> Path:
759 """:returns: templates path tied to the user"""
760 return PlatformDirs().user_templates_path
761
762
763def user_fonts_path() -> Path:
764 """:returns: fonts path tied to the user"""
765 return PlatformDirs().user_fonts_path
766
767
768def user_preference_path() -> Path:
769 """:returns: preference path tied to the user"""
770 return PlatformDirs().user_preference_path
771
772
773def user_bin_path() -> Path:
774 """:returns: bin path tied to the user"""
775 return PlatformDirs().user_bin_path
776
777
778def site_bin_path() -> Path:
779 """:returns: bin path shared by users"""
780 return PlatformDirs().site_bin_path
781
782
783def user_applications_path() -> Path:
784 """:returns: applications path tied to the user"""
785 return PlatformDirs().user_applications_path
786
787
788def site_applications_path(
789 multipath: bool = False, # noqa: FBT001, FBT002
790 ensure_exists: bool = False, # noqa: FBT001, FBT002
791) -> Path:
792 """:param multipath: See `multipath <platformdirs.api.PlatformDirsABC.multipath>`.
793 :param ensure_exists: See `ensure_exists <platformdirs.api.PlatformDirsABC.ensure_exists>`.
794
795 :returns: applications path shared by users
796
797 """
798 return PlatformDirs(
799 multipath=multipath,
800 ensure_exists=ensure_exists,
801 ).site_applications_path
802
803
804def user_runtime_path( # noqa: PLR0913, PLR0917
805 appname: str | None = None,
806 appauthor: str | Literal[False] | None = None,
807 version: str | None = None,
808 opinion: bool = True, # noqa: FBT001, FBT002
809 ensure_exists: bool = False, # noqa: FBT001, FBT002
810 use_site_for_root: bool = False, # noqa: FBT001, FBT002
811) -> Path:
812 """:param appname: See `appname <platformdirs.api.PlatformDirsABC.appname>`.
813 :param appauthor: See `appauthor <platformdirs.api.PlatformDirsABC.appauthor>`.
814 :param version: See `version <platformdirs.api.PlatformDirsABC.version>`.
815 :param opinion: See `opinion <platformdirs.api.PlatformDirsABC.opinion>`.
816 :param ensure_exists: See `ensure_exists <platformdirs.api.PlatformDirsABC.ensure_exists>`.
817 :param use_site_for_root: See `use_site_for_root <platformdirs.api.PlatformDirsABC.use_site_for_root>`.
818
819 :returns: runtime path tied to the user
820
821 """
822 return PlatformDirs(
823 appname=appname,
824 appauthor=appauthor,
825 version=version,
826 opinion=opinion,
827 ensure_exists=ensure_exists,
828 use_site_for_root=use_site_for_root,
829 ).user_runtime_path
830
831
832def site_runtime_path(
833 appname: str | None = None,
834 appauthor: str | Literal[False] | None = None,
835 version: str | None = None,
836 opinion: bool = True, # noqa: FBT001, FBT002
837 ensure_exists: bool = False, # noqa: FBT001, FBT002
838) -> Path:
839 """:param appname: See `appname <platformdirs.api.PlatformDirsABC.appname>`.
840 :param appauthor: See `appauthor <platformdirs.api.PlatformDirsABC.appauthor>`.
841 :param version: See `version <platformdirs.api.PlatformDirsABC.version>`.
842 :param opinion: See `opinion <platformdirs.api.PlatformDirsABC.opinion>`.
843 :param ensure_exists: See `ensure_exists <platformdirs.api.PlatformDirsABC.ensure_exists>`.
844
845 :returns: runtime path shared by users
846
847 """
848 return PlatformDirs(
849 appname=appname,
850 appauthor=appauthor,
851 version=version,
852 opinion=opinion,
853 ensure_exists=ensure_exists,
854 ).site_runtime_path
855
856
857__all__ = [
858 "AppDirs",
859 "PlatformDirs",
860 "PlatformDirsABC",
861 "__version__",
862 "__version_info__",
863 "site_applications_dir",
864 "site_applications_path",
865 "site_bin_dir",
866 "site_bin_path",
867 "site_cache_dir",
868 "site_cache_path",
869 "site_config_dir",
870 "site_config_path",
871 "site_data_dir",
872 "site_data_path",
873 "site_log_dir",
874 "site_log_path",
875 "site_runtime_dir",
876 "site_runtime_path",
877 "site_state_dir",
878 "site_state_path",
879 "user_applications_dir",
880 "user_applications_path",
881 "user_bin_dir",
882 "user_bin_path",
883 "user_cache_dir",
884 "user_cache_path",
885 "user_config_dir",
886 "user_config_path",
887 "user_data_dir",
888 "user_data_path",
889 "user_desktop_dir",
890 "user_desktop_path",
891 "user_documents_dir",
892 "user_documents_path",
893 "user_downloads_dir",
894 "user_downloads_path",
895 "user_fonts_dir",
896 "user_fonts_path",
897 "user_log_dir",
898 "user_log_path",
899 "user_music_dir",
900 "user_music_path",
901 "user_pictures_dir",
902 "user_pictures_path",
903 "user_preference_dir",
904 "user_preference_path",
905 "user_projects_dir",
906 "user_projects_path",
907 "user_publicshare_dir",
908 "user_publicshare_path",
909 "user_runtime_dir",
910 "user_runtime_path",
911 "user_state_dir",
912 "user_state_path",
913 "user_templates_dir",
914 "user_templates_path",
915 "user_videos_dir",
916 "user_videos_path",
917]