__init__.py 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631
  1. """
  2. Utilities for determining application-specific dirs.
  3. See <https://github.com/platformdirs/platformdirs> for details and usage.
  4. """
  5. from __future__ import annotations
  6. import os
  7. import sys
  8. from typing import TYPE_CHECKING
  9. from .api import PlatformDirsABC
  10. from .version import __version__
  11. from .version import __version_tuple__ as __version_info__
  12. if TYPE_CHECKING:
  13. from pathlib import Path
  14. from typing import Literal
  15. if sys.platform == "win32":
  16. from platformdirs.windows import Windows as _Result
  17. elif sys.platform == "darwin":
  18. from platformdirs.macos import MacOS as _Result
  19. else:
  20. from platformdirs.unix import Unix as _Result
  21. def _set_platform_dir_class() -> type[PlatformDirsABC]:
  22. if os.getenv("ANDROID_DATA") == "/data" and os.getenv("ANDROID_ROOT") == "/system":
  23. if os.getenv("SHELL") or os.getenv("PREFIX"):
  24. return _Result
  25. from platformdirs.android import _android_folder # noqa: PLC0415
  26. if _android_folder() is not None:
  27. from platformdirs.android import Android # noqa: PLC0415
  28. return Android # return to avoid redefinition of a result
  29. return _Result
  30. if TYPE_CHECKING:
  31. # Work around mypy issue: https://github.com/python/mypy/issues/10962
  32. PlatformDirs = _Result
  33. else:
  34. PlatformDirs = _set_platform_dir_class() #: Currently active platform
  35. AppDirs = PlatformDirs #: Backwards compatibility with appdirs
  36. def user_data_dir(
  37. appname: str | None = None,
  38. appauthor: str | None | Literal[False] = None,
  39. version: str | None = None,
  40. roaming: bool = False, # noqa: FBT001, FBT002
  41. ensure_exists: bool = False, # noqa: FBT001, FBT002
  42. ) -> str:
  43. """
  44. :param appname: See `appname <platformdirs.api.PlatformDirsABC.appname>`.
  45. :param appauthor: See `appauthor <platformdirs.api.PlatformDirsABC.appauthor>`.
  46. :param version: See `version <platformdirs.api.PlatformDirsABC.version>`.
  47. :param roaming: See `roaming <platformdirs.api.PlatformDirsABC.roaming>`.
  48. :param ensure_exists: See `ensure_exists <platformdirs.api.PlatformDirsABC.ensure_exists>`.
  49. :returns: data directory tied to the user
  50. """
  51. return PlatformDirs(
  52. appname=appname,
  53. appauthor=appauthor,
  54. version=version,
  55. roaming=roaming,
  56. ensure_exists=ensure_exists,
  57. ).user_data_dir
  58. def site_data_dir(
  59. appname: str | None = None,
  60. appauthor: str | None | Literal[False] = None,
  61. version: str | None = None,
  62. multipath: bool = False, # noqa: FBT001, FBT002
  63. ensure_exists: bool = False, # noqa: FBT001, FBT002
  64. ) -> str:
  65. """
  66. :param appname: See `appname <platformdirs.api.PlatformDirsABC.appname>`.
  67. :param appauthor: See `appauthor <platformdirs.api.PlatformDirsABC.appauthor>`.
  68. :param version: See `version <platformdirs.api.PlatformDirsABC.version>`.
  69. :param multipath: See `roaming <platformdirs.api.PlatformDirsABC.multipath>`.
  70. :param ensure_exists: See `ensure_exists <platformdirs.api.PlatformDirsABC.ensure_exists>`.
  71. :returns: data directory shared by users
  72. """
  73. return PlatformDirs(
  74. appname=appname,
  75. appauthor=appauthor,
  76. version=version,
  77. multipath=multipath,
  78. ensure_exists=ensure_exists,
  79. ).site_data_dir
  80. def user_config_dir(
  81. appname: str | None = None,
  82. appauthor: str | None | Literal[False] = None,
  83. version: str | None = None,
  84. roaming: bool = False, # noqa: FBT001, FBT002
  85. ensure_exists: bool = False, # noqa: FBT001, FBT002
  86. ) -> str:
  87. """
  88. :param appname: See `appname <platformdirs.api.PlatformDirsABC.appname>`.
  89. :param appauthor: See `appauthor <platformdirs.api.PlatformDirsABC.appauthor>`.
  90. :param version: See `version <platformdirs.api.PlatformDirsABC.version>`.
  91. :param roaming: See `roaming <platformdirs.api.PlatformDirsABC.roaming>`.
  92. :param ensure_exists: See `ensure_exists <platformdirs.api.PlatformDirsABC.ensure_exists>`.
  93. :returns: config directory tied to the user
  94. """
  95. return PlatformDirs(
  96. appname=appname,
  97. appauthor=appauthor,
  98. version=version,
  99. roaming=roaming,
  100. ensure_exists=ensure_exists,
  101. ).user_config_dir
  102. def site_config_dir(
  103. appname: str | None = None,
  104. appauthor: str | None | Literal[False] = None,
  105. version: str | None = None,
  106. multipath: bool = False, # noqa: FBT001, FBT002
  107. ensure_exists: bool = False, # noqa: FBT001, FBT002
  108. ) -> str:
  109. """
  110. :param appname: See `appname <platformdirs.api.PlatformDirsABC.appname>`.
  111. :param appauthor: See `appauthor <platformdirs.api.PlatformDirsABC.appauthor>`.
  112. :param version: See `version <platformdirs.api.PlatformDirsABC.version>`.
  113. :param multipath: See `roaming <platformdirs.api.PlatformDirsABC.multipath>`.
  114. :param ensure_exists: See `ensure_exists <platformdirs.api.PlatformDirsABC.ensure_exists>`.
  115. :returns: config directory shared by the users
  116. """
  117. return PlatformDirs(
  118. appname=appname,
  119. appauthor=appauthor,
  120. version=version,
  121. multipath=multipath,
  122. ensure_exists=ensure_exists,
  123. ).site_config_dir
  124. def user_cache_dir(
  125. appname: str | None = None,
  126. appauthor: str | None | Literal[False] = None,
  127. version: str | None = None,
  128. opinion: bool = True, # noqa: FBT001, FBT002
  129. ensure_exists: bool = False, # noqa: FBT001, FBT002
  130. ) -> str:
  131. """
  132. :param appname: See `appname <platformdirs.api.PlatformDirsABC.appname>`.
  133. :param appauthor: See `appauthor <platformdirs.api.PlatformDirsABC.appauthor>`.
  134. :param version: See `version <platformdirs.api.PlatformDirsABC.version>`.
  135. :param opinion: See `roaming <platformdirs.api.PlatformDirsABC.opinion>`.
  136. :param ensure_exists: See `ensure_exists <platformdirs.api.PlatformDirsABC.ensure_exists>`.
  137. :returns: cache directory tied to the user
  138. """
  139. return PlatformDirs(
  140. appname=appname,
  141. appauthor=appauthor,
  142. version=version,
  143. opinion=opinion,
  144. ensure_exists=ensure_exists,
  145. ).user_cache_dir
  146. def site_cache_dir(
  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
  152. ) -> str:
  153. """
  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 `opinion <platformdirs.api.PlatformDirsABC.opinion>`.
  158. :param ensure_exists: See `ensure_exists <platformdirs.api.PlatformDirsABC.ensure_exists>`.
  159. :returns: cache directory tied to the user
  160. """
  161. return PlatformDirs(
  162. appname=appname,
  163. appauthor=appauthor,
  164. version=version,
  165. opinion=opinion,
  166. ensure_exists=ensure_exists,
  167. ).site_cache_dir
  168. def user_state_dir(
  169. appname: str | None = None,
  170. appauthor: str | None | Literal[False] = None,
  171. version: str | None = None,
  172. roaming: bool = False, # noqa: FBT001, FBT002
  173. ensure_exists: bool = False, # noqa: FBT001, FBT002
  174. ) -> str:
  175. """
  176. :param appname: See `appname <platformdirs.api.PlatformDirsABC.appname>`.
  177. :param appauthor: See `appauthor <platformdirs.api.PlatformDirsABC.appauthor>`.
  178. :param version: See `version <platformdirs.api.PlatformDirsABC.version>`.
  179. :param roaming: See `roaming <platformdirs.api.PlatformDirsABC.roaming>`.
  180. :param ensure_exists: See `ensure_exists <platformdirs.api.PlatformDirsABC.ensure_exists>`.
  181. :returns: state directory tied to the user
  182. """
  183. return PlatformDirs(
  184. appname=appname,
  185. appauthor=appauthor,
  186. version=version,
  187. roaming=roaming,
  188. ensure_exists=ensure_exists,
  189. ).user_state_dir
  190. def user_log_dir(
  191. appname: str | None = None,
  192. appauthor: str | None | Literal[False] = None,
  193. version: str | None = None,
  194. opinion: bool = True, # noqa: FBT001, FBT002
  195. ensure_exists: bool = False, # noqa: FBT001, FBT002
  196. ) -> str:
  197. """
  198. :param appname: See `appname <platformdirs.api.PlatformDirsABC.appname>`.
  199. :param appauthor: See `appauthor <platformdirs.api.PlatformDirsABC.appauthor>`.
  200. :param version: See `version <platformdirs.api.PlatformDirsABC.version>`.
  201. :param opinion: See `roaming <platformdirs.api.PlatformDirsABC.opinion>`.
  202. :param ensure_exists: See `ensure_exists <platformdirs.api.PlatformDirsABC.ensure_exists>`.
  203. :returns: log directory tied to the user
  204. """
  205. return PlatformDirs(
  206. appname=appname,
  207. appauthor=appauthor,
  208. version=version,
  209. opinion=opinion,
  210. ensure_exists=ensure_exists,
  211. ).user_log_dir
  212. def user_documents_dir() -> str:
  213. """:returns: documents directory tied to the user"""
  214. return PlatformDirs().user_documents_dir
  215. def user_downloads_dir() -> str:
  216. """:returns: downloads directory tied to the user"""
  217. return PlatformDirs().user_downloads_dir
  218. def user_pictures_dir() -> str:
  219. """:returns: pictures directory tied to the user"""
  220. return PlatformDirs().user_pictures_dir
  221. def user_videos_dir() -> str:
  222. """:returns: videos directory tied to the user"""
  223. return PlatformDirs().user_videos_dir
  224. def user_music_dir() -> str:
  225. """:returns: music directory tied to the user"""
  226. return PlatformDirs().user_music_dir
  227. def user_desktop_dir() -> str:
  228. """:returns: desktop directory tied to the user"""
  229. return PlatformDirs().user_desktop_dir
  230. def user_runtime_dir(
  231. appname: str | None = None,
  232. appauthor: str | None | Literal[False] = None,
  233. version: str | None = None,
  234. opinion: bool = True, # noqa: FBT001, FBT002
  235. ensure_exists: bool = False, # noqa: FBT001, FBT002
  236. ) -> str:
  237. """
  238. :param appname: See `appname <platformdirs.api.PlatformDirsABC.appname>`.
  239. :param appauthor: See `appauthor <platformdirs.api.PlatformDirsABC.appauthor>`.
  240. :param version: See `version <platformdirs.api.PlatformDirsABC.version>`.
  241. :param opinion: See `opinion <platformdirs.api.PlatformDirsABC.opinion>`.
  242. :param ensure_exists: See `ensure_exists <platformdirs.api.PlatformDirsABC.ensure_exists>`.
  243. :returns: runtime directory tied to the user
  244. """
  245. return PlatformDirs(
  246. appname=appname,
  247. appauthor=appauthor,
  248. version=version,
  249. opinion=opinion,
  250. ensure_exists=ensure_exists,
  251. ).user_runtime_dir
  252. def site_runtime_dir(
  253. appname: str | None = None,
  254. appauthor: str | None | Literal[False] = None,
  255. version: str | None = None,
  256. opinion: bool = True, # noqa: FBT001, FBT002
  257. ensure_exists: bool = False, # noqa: FBT001, FBT002
  258. ) -> str:
  259. """
  260. :param appname: See `appname <platformdirs.api.PlatformDirsABC.appname>`.
  261. :param appauthor: See `appauthor <platformdirs.api.PlatformDirsABC.appauthor>`.
  262. :param version: See `version <platformdirs.api.PlatformDirsABC.version>`.
  263. :param opinion: See `opinion <platformdirs.api.PlatformDirsABC.opinion>`.
  264. :param ensure_exists: See `ensure_exists <platformdirs.api.PlatformDirsABC.ensure_exists>`.
  265. :returns: runtime directory shared by users
  266. """
  267. return PlatformDirs(
  268. appname=appname,
  269. appauthor=appauthor,
  270. version=version,
  271. opinion=opinion,
  272. ensure_exists=ensure_exists,
  273. ).site_runtime_dir
  274. def user_data_path(
  275. appname: str | None = None,
  276. appauthor: str | None | Literal[False] = None,
  277. version: str | None = None,
  278. roaming: bool = False, # noqa: FBT001, FBT002
  279. ensure_exists: bool = False, # noqa: FBT001, FBT002
  280. ) -> Path:
  281. """
  282. :param appname: See `appname <platformdirs.api.PlatformDirsABC.appname>`.
  283. :param appauthor: See `appauthor <platformdirs.api.PlatformDirsABC.appauthor>`.
  284. :param version: See `version <platformdirs.api.PlatformDirsABC.version>`.
  285. :param roaming: See `roaming <platformdirs.api.PlatformDirsABC.roaming>`.
  286. :param ensure_exists: See `ensure_exists <platformdirs.api.PlatformDirsABC.ensure_exists>`.
  287. :returns: data path tied to the user
  288. """
  289. return PlatformDirs(
  290. appname=appname,
  291. appauthor=appauthor,
  292. version=version,
  293. roaming=roaming,
  294. ensure_exists=ensure_exists,
  295. ).user_data_path
  296. def site_data_path(
  297. appname: str | None = None,
  298. appauthor: str | None | Literal[False] = None,
  299. version: str | None = None,
  300. multipath: bool = False, # noqa: FBT001, FBT002
  301. ensure_exists: bool = False, # noqa: FBT001, FBT002
  302. ) -> Path:
  303. """
  304. :param appname: See `appname <platformdirs.api.PlatformDirsABC.appname>`.
  305. :param appauthor: See `appauthor <platformdirs.api.PlatformDirsABC.appauthor>`.
  306. :param version: See `version <platformdirs.api.PlatformDirsABC.version>`.
  307. :param multipath: See `multipath <platformdirs.api.PlatformDirsABC.multipath>`.
  308. :param ensure_exists: See `ensure_exists <platformdirs.api.PlatformDirsABC.ensure_exists>`.
  309. :returns: data path shared by users
  310. """
  311. return PlatformDirs(
  312. appname=appname,
  313. appauthor=appauthor,
  314. version=version,
  315. multipath=multipath,
  316. ensure_exists=ensure_exists,
  317. ).site_data_path
  318. def user_config_path(
  319. appname: str | None = None,
  320. appauthor: str | None | Literal[False] = None,
  321. version: str | None = None,
  322. roaming: bool = False, # noqa: FBT001, FBT002
  323. ensure_exists: bool = False, # noqa: FBT001, FBT002
  324. ) -> Path:
  325. """
  326. :param appname: See `appname <platformdirs.api.PlatformDirsABC.appname>`.
  327. :param appauthor: See `appauthor <platformdirs.api.PlatformDirsABC.appauthor>`.
  328. :param version: See `version <platformdirs.api.PlatformDirsABC.version>`.
  329. :param roaming: See `roaming <platformdirs.api.PlatformDirsABC.roaming>`.
  330. :param ensure_exists: See `ensure_exists <platformdirs.api.PlatformDirsABC.ensure_exists>`.
  331. :returns: config path tied to the user
  332. """
  333. return PlatformDirs(
  334. appname=appname,
  335. appauthor=appauthor,
  336. version=version,
  337. roaming=roaming,
  338. ensure_exists=ensure_exists,
  339. ).user_config_path
  340. def site_config_path(
  341. appname: str | None = None,
  342. appauthor: str | None | Literal[False] = None,
  343. version: str | None = None,
  344. multipath: bool = False, # noqa: FBT001, FBT002
  345. ensure_exists: bool = False, # noqa: FBT001, FBT002
  346. ) -> Path:
  347. """
  348. :param appname: See `appname <platformdirs.api.PlatformDirsABC.appname>`.
  349. :param appauthor: See `appauthor <platformdirs.api.PlatformDirsABC.appauthor>`.
  350. :param version: See `version <platformdirs.api.PlatformDirsABC.version>`.
  351. :param multipath: See `roaming <platformdirs.api.PlatformDirsABC.multipath>`.
  352. :param ensure_exists: See `ensure_exists <platformdirs.api.PlatformDirsABC.ensure_exists>`.
  353. :returns: config path shared by the users
  354. """
  355. return PlatformDirs(
  356. appname=appname,
  357. appauthor=appauthor,
  358. version=version,
  359. multipath=multipath,
  360. ensure_exists=ensure_exists,
  361. ).site_config_path
  362. def site_cache_path(
  363. appname: str | None = None,
  364. appauthor: str | None | Literal[False] = None,
  365. version: str | None = None,
  366. opinion: bool = True, # noqa: FBT001, FBT002
  367. ensure_exists: bool = False, # noqa: FBT001, FBT002
  368. ) -> Path:
  369. """
  370. :param appname: See `appname <platformdirs.api.PlatformDirsABC.appname>`.
  371. :param appauthor: See `appauthor <platformdirs.api.PlatformDirsABC.appauthor>`.
  372. :param version: See `version <platformdirs.api.PlatformDirsABC.version>`.
  373. :param opinion: See `opinion <platformdirs.api.PlatformDirsABC.opinion>`.
  374. :param ensure_exists: See `ensure_exists <platformdirs.api.PlatformDirsABC.ensure_exists>`.
  375. :returns: cache directory tied to the user
  376. """
  377. return PlatformDirs(
  378. appname=appname,
  379. appauthor=appauthor,
  380. version=version,
  381. opinion=opinion,
  382. ensure_exists=ensure_exists,
  383. ).site_cache_path
  384. def user_cache_path(
  385. appname: str | None = None,
  386. appauthor: str | None | Literal[False] = None,
  387. version: str | None = None,
  388. opinion: bool = True, # noqa: FBT001, FBT002
  389. ensure_exists: bool = False, # noqa: FBT001, FBT002
  390. ) -> Path:
  391. """
  392. :param appname: See `appname <platformdirs.api.PlatformDirsABC.appname>`.
  393. :param appauthor: See `appauthor <platformdirs.api.PlatformDirsABC.appauthor>`.
  394. :param version: See `version <platformdirs.api.PlatformDirsABC.version>`.
  395. :param opinion: See `roaming <platformdirs.api.PlatformDirsABC.opinion>`.
  396. :param ensure_exists: See `ensure_exists <platformdirs.api.PlatformDirsABC.ensure_exists>`.
  397. :returns: cache path tied to the user
  398. """
  399. return PlatformDirs(
  400. appname=appname,
  401. appauthor=appauthor,
  402. version=version,
  403. opinion=opinion,
  404. ensure_exists=ensure_exists,
  405. ).user_cache_path
  406. def user_state_path(
  407. appname: str | None = None,
  408. appauthor: str | None | Literal[False] = None,
  409. version: str | None = None,
  410. roaming: bool = False, # noqa: FBT001, FBT002
  411. ensure_exists: bool = False, # noqa: FBT001, FBT002
  412. ) -> Path:
  413. """
  414. :param appname: See `appname <platformdirs.api.PlatformDirsABC.appname>`.
  415. :param appauthor: See `appauthor <platformdirs.api.PlatformDirsABC.appauthor>`.
  416. :param version: See `version <platformdirs.api.PlatformDirsABC.version>`.
  417. :param roaming: See `roaming <platformdirs.api.PlatformDirsABC.roaming>`.
  418. :param ensure_exists: See `ensure_exists <platformdirs.api.PlatformDirsABC.ensure_exists>`.
  419. :returns: state path tied to the user
  420. """
  421. return PlatformDirs(
  422. appname=appname,
  423. appauthor=appauthor,
  424. version=version,
  425. roaming=roaming,
  426. ensure_exists=ensure_exists,
  427. ).user_state_path
  428. def user_log_path(
  429. appname: str | None = None,
  430. appauthor: str | None | Literal[False] = None,
  431. version: str | None = None,
  432. opinion: bool = True, # noqa: FBT001, FBT002
  433. ensure_exists: bool = False, # noqa: FBT001, FBT002
  434. ) -> Path:
  435. """
  436. :param appname: See `appname <platformdirs.api.PlatformDirsABC.appname>`.
  437. :param appauthor: See `appauthor <platformdirs.api.PlatformDirsABC.appauthor>`.
  438. :param version: See `version <platformdirs.api.PlatformDirsABC.version>`.
  439. :param opinion: See `roaming <platformdirs.api.PlatformDirsABC.opinion>`.
  440. :param ensure_exists: See `ensure_exists <platformdirs.api.PlatformDirsABC.ensure_exists>`.
  441. :returns: log path tied to the user
  442. """
  443. return PlatformDirs(
  444. appname=appname,
  445. appauthor=appauthor,
  446. version=version,
  447. opinion=opinion,
  448. ensure_exists=ensure_exists,
  449. ).user_log_path
  450. def user_documents_path() -> Path:
  451. """:returns: documents a path tied to the user"""
  452. return PlatformDirs().user_documents_path
  453. def user_downloads_path() -> Path:
  454. """:returns: downloads path tied to the user"""
  455. return PlatformDirs().user_downloads_path
  456. def user_pictures_path() -> Path:
  457. """:returns: pictures path tied to the user"""
  458. return PlatformDirs().user_pictures_path
  459. def user_videos_path() -> Path:
  460. """:returns: videos path tied to the user"""
  461. return PlatformDirs().user_videos_path
  462. def user_music_path() -> Path:
  463. """:returns: music path tied to the user"""
  464. return PlatformDirs().user_music_path
  465. def user_desktop_path() -> Path:
  466. """:returns: desktop path tied to the user"""
  467. return PlatformDirs().user_desktop_path
  468. def user_runtime_path(
  469. appname: str | None = None,
  470. appauthor: str | None | Literal[False] = None,
  471. version: str | None = None,
  472. opinion: bool = True, # noqa: FBT001, FBT002
  473. ensure_exists: bool = False, # noqa: FBT001, FBT002
  474. ) -> Path:
  475. """
  476. :param appname: See `appname <platformdirs.api.PlatformDirsABC.appname>`.
  477. :param appauthor: See `appauthor <platformdirs.api.PlatformDirsABC.appauthor>`.
  478. :param version: See `version <platformdirs.api.PlatformDirsABC.version>`.
  479. :param opinion: See `opinion <platformdirs.api.PlatformDirsABC.opinion>`.
  480. :param ensure_exists: See `ensure_exists <platformdirs.api.PlatformDirsABC.ensure_exists>`.
  481. :returns: runtime path tied to the user
  482. """
  483. return PlatformDirs(
  484. appname=appname,
  485. appauthor=appauthor,
  486. version=version,
  487. opinion=opinion,
  488. ensure_exists=ensure_exists,
  489. ).user_runtime_path
  490. def site_runtime_path(
  491. appname: str | None = None,
  492. appauthor: str | None | Literal[False] = None,
  493. version: str | None = None,
  494. opinion: bool = True, # noqa: FBT001, FBT002
  495. ensure_exists: bool = False, # noqa: FBT001, FBT002
  496. ) -> Path:
  497. """
  498. :param appname: See `appname <platformdirs.api.PlatformDirsABC.appname>`.
  499. :param appauthor: See `appauthor <platformdirs.api.PlatformDirsABC.appauthor>`.
  500. :param version: See `version <platformdirs.api.PlatformDirsABC.version>`.
  501. :param opinion: See `opinion <platformdirs.api.PlatformDirsABC.opinion>`.
  502. :param ensure_exists: See `ensure_exists <platformdirs.api.PlatformDirsABC.ensure_exists>`.
  503. :returns: runtime path shared by users
  504. """
  505. return PlatformDirs(
  506. appname=appname,
  507. appauthor=appauthor,
  508. version=version,
  509. opinion=opinion,
  510. ensure_exists=ensure_exists,
  511. ).site_runtime_path
  512. __all__ = [
  513. "AppDirs",
  514. "PlatformDirs",
  515. "PlatformDirsABC",
  516. "__version__",
  517. "__version_info__",
  518. "site_cache_dir",
  519. "site_cache_path",
  520. "site_config_dir",
  521. "site_config_path",
  522. "site_data_dir",
  523. "site_data_path",
  524. "site_runtime_dir",
  525. "site_runtime_path",
  526. "user_cache_dir",
  527. "user_cache_path",
  528. "user_config_dir",
  529. "user_config_path",
  530. "user_data_dir",
  531. "user_data_path",
  532. "user_desktop_dir",
  533. "user_desktop_path",
  534. "user_documents_dir",
  535. "user_documents_path",
  536. "user_downloads_dir",
  537. "user_downloads_path",
  538. "user_log_dir",
  539. "user_log_path",
  540. "user_music_dir",
  541. "user_music_path",
  542. "user_pictures_dir",
  543. "user_pictures_path",
  544. "user_runtime_dir",
  545. "user_runtime_path",
  546. "user_state_dir",
  547. "user_state_path",
  548. "user_videos_dir",
  549. "user_videos_path",
  550. ]