Coverage for /pythoncovmergedfiles/medio/medio/usr/local/lib/python3.11/site-packages/platformdirs/__init__.py: 1%

Shortcuts on this page

r m x   toggle line displays

j k   next/prev highlighted chunk

0   (zero) top of page

1   (one) first highlighted chunk

138 statements  

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 # ruff:ignore[import-outside-top-level] 

38 

39 if _android_folder() is not None: 

40 from platformdirs.android import Android # ruff:ignore[import-outside-top-level] 

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( # ruff:ignore[too-many-arguments, too-many-positional-arguments] 

56 appname: str | None = None, 

57 appauthor: str | Literal[False] | None = None, 

58 version: str | None = None, 

59 roaming: bool = False, # ruff:ignore[boolean-type-hint-positional-argument, boolean-default-value-positional-argument] 

60 ensure_exists: bool = False, # ruff:ignore[boolean-type-hint-positional-argument, boolean-default-value-positional-argument] 

61 use_site_for_root: bool = False, # ruff:ignore[boolean-type-hint-positional-argument, boolean-default-value-positional-argument] 

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, # ruff:ignore[boolean-type-hint-positional-argument, boolean-default-value-positional-argument] 

88 ensure_exists: bool = False, # ruff:ignore[boolean-type-hint-positional-argument, boolean-default-value-positional-argument] 

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( # ruff:ignore[too-many-arguments, too-many-positional-arguments] 

109 appname: str | None = None, 

110 appauthor: str | Literal[False] | None = None, 

111 version: str | None = None, 

112 roaming: bool = False, # ruff:ignore[boolean-type-hint-positional-argument, boolean-default-value-positional-argument] 

113 ensure_exists: bool = False, # ruff:ignore[boolean-type-hint-positional-argument, boolean-default-value-positional-argument] 

114 use_site_for_root: bool = False, # ruff:ignore[boolean-type-hint-positional-argument, boolean-default-value-positional-argument] 

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, # ruff:ignore[boolean-type-hint-positional-argument, boolean-default-value-positional-argument] 

141 ensure_exists: bool = False, # ruff:ignore[boolean-type-hint-positional-argument, boolean-default-value-positional-argument] 

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( # ruff:ignore[too-many-arguments, too-many-positional-arguments] 

162 appname: str | None = None, 

163 appauthor: str | Literal[False] | None = None, 

164 version: str | None = None, 

165 opinion: bool = True, # ruff:ignore[boolean-type-hint-positional-argument, boolean-default-value-positional-argument] 

166 ensure_exists: bool = False, # ruff:ignore[boolean-type-hint-positional-argument, boolean-default-value-positional-argument] 

167 use_site_for_root: bool = False, # ruff:ignore[boolean-type-hint-positional-argument, boolean-default-value-positional-argument] 

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, # ruff:ignore[boolean-type-hint-positional-argument, boolean-default-value-positional-argument] 

194 ensure_exists: bool = False, # ruff:ignore[boolean-type-hint-positional-argument, boolean-default-value-positional-argument] 

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( # ruff:ignore[too-many-arguments, too-many-positional-arguments] 

215 appname: str | None = None, 

216 appauthor: str | Literal[False] | None = None, 

217 version: str | None = None, 

218 roaming: bool = False, # ruff:ignore[boolean-type-hint-positional-argument, boolean-default-value-positional-argument] 

219 ensure_exists: bool = False, # ruff:ignore[boolean-type-hint-positional-argument, boolean-default-value-positional-argument] 

220 use_site_for_root: bool = False, # ruff:ignore[boolean-type-hint-positional-argument, boolean-default-value-positional-argument] 

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, # ruff:ignore[boolean-type-hint-positional-argument, boolean-default-value-positional-argument] 

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( # ruff:ignore[too-many-arguments, too-many-positional-arguments] 

265 appname: str | None = None, 

266 appauthor: str | Literal[False] | None = None, 

267 version: str | None = None, 

268 opinion: bool = True, # ruff:ignore[boolean-type-hint-positional-argument, boolean-default-value-positional-argument] 

269 ensure_exists: bool = False, # ruff:ignore[boolean-type-hint-positional-argument, boolean-default-value-positional-argument] 

270 use_site_for_root: bool = False, # ruff:ignore[boolean-type-hint-positional-argument, boolean-default-value-positional-argument] 

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, # ruff:ignore[boolean-type-hint-positional-argument, boolean-default-value-positional-argument] 

297 ensure_exists: bool = False, # ruff:ignore[boolean-type-hint-positional-argument, boolean-default-value-positional-argument] 

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( # ruff:ignore[too-many-arguments] 

368 appname: str | None = None, 

369 appauthor: str | Literal[False] | None = None, 

370 version: str | None = None, 

371 *, 

372 roaming: bool = False, 

373 ensure_exists: bool = False, 

374 use_site_for_root: bool = False, 

375) -> str: 

376 """:param appname: See `appname <platformdirs.api.PlatformDirsABC.appname>`. 

377 :param appauthor: See `appauthor <platformdirs.api.PlatformDirsABC.appauthor>`. 

378 :param version: See `version <platformdirs.api.PlatformDirsABC.version>`. 

379 :param roaming: See `roaming <platformdirs.api.PlatformDirsABC.roaming>`. 

380 :param ensure_exists: See `ensure_exists <platformdirs.api.PlatformDirsABC.ensure_exists>`. 

381 :param use_site_for_root: See `use_site_for_root <platformdirs.api.PlatformDirsABC.use_site_for_root>`. 

382 

383 :returns: preference directory tied to the user 

384 

385 """ 

386 return PlatformDirs( 

387 appname=appname, 

388 appauthor=appauthor, 

389 version=version, 

390 roaming=roaming, 

391 ensure_exists=ensure_exists, 

392 use_site_for_root=use_site_for_root, 

393 ).user_preference_dir 

394 

395 

396def user_bin_dir(*, use_site_for_root: bool = False) -> str: 

397 """:param use_site_for_root: See `use_site_for_root <platformdirs.api.PlatformDirsABC.use_site_for_root>`. 

398 

399 :returns: bin directory tied to the user 

400 

401 """ 

402 return PlatformDirs(use_site_for_root=use_site_for_root).user_bin_dir 

403 

404 

405def site_bin_dir() -> str: 

406 """:returns: bin directory shared by users""" 

407 return PlatformDirs().site_bin_dir 

408 

409 

410def user_applications_dir( 

411 appname: str | None = None, 

412 appauthor: str | Literal[False] | None = None, 

413 version: str | None = None, 

414 *, 

415 ensure_exists: bool = False, 

416 use_site_for_root: bool = False, 

417) -> str: 

418 """:param appname: See `appname <platformdirs.api.PlatformDirsABC.appname>`. 

419 :param appauthor: See `appauthor <platformdirs.api.PlatformDirsABC.appauthor>`. 

420 :param version: See `version <platformdirs.api.PlatformDirsABC.version>`. 

421 :param ensure_exists: See `ensure_exists <platformdirs.api.PlatformDirsABC.ensure_exists>`. 

422 :param use_site_for_root: See `use_site_for_root <platformdirs.api.PlatformDirsABC.use_site_for_root>`. 

423 

424 :returns: applications directory tied to the user 

425 

426 """ 

427 return PlatformDirs( 

428 appname=appname, 

429 appauthor=appauthor, 

430 version=version, 

431 ensure_exists=ensure_exists, 

432 use_site_for_root=use_site_for_root, 

433 ).user_applications_dir 

434 

435 

436def site_applications_dir( 

437 multipath: bool = False, # ruff:ignore[boolean-type-hint-positional-argument, boolean-default-value-positional-argument] 

438 ensure_exists: bool = False, # ruff:ignore[boolean-type-hint-positional-argument, boolean-default-value-positional-argument] 

439 *, 

440 appname: str | None = None, 

441 appauthor: str | Literal[False] | None = None, 

442 version: str | None = None, 

443) -> str: 

444 """:param multipath: See `multipath <platformdirs.api.PlatformDirsABC.multipath>`. 

445 :param ensure_exists: See `ensure_exists <platformdirs.api.PlatformDirsABC.ensure_exists>`. 

446 :param appname: See `appname <platformdirs.api.PlatformDirsABC.appname>`. 

447 :param appauthor: See `appauthor <platformdirs.api.PlatformDirsABC.appauthor>`. 

448 :param version: See `version <platformdirs.api.PlatformDirsABC.version>`. 

449 

450 :returns: applications directory shared by users 

451 

452 """ 

453 return PlatformDirs( 

454 appname=appname, 

455 appauthor=appauthor, 

456 version=version, 

457 multipath=multipath, 

458 ensure_exists=ensure_exists, 

459 ).site_applications_dir 

460 

461 

462def user_runtime_dir( # ruff:ignore[too-many-arguments, too-many-positional-arguments] 

463 appname: str | None = None, 

464 appauthor: str | Literal[False] | None = None, 

465 version: str | None = None, 

466 opinion: bool = True, # ruff:ignore[boolean-type-hint-positional-argument, boolean-default-value-positional-argument] 

467 ensure_exists: bool = False, # ruff:ignore[boolean-type-hint-positional-argument, boolean-default-value-positional-argument] 

468 use_site_for_root: bool = False, # ruff:ignore[boolean-type-hint-positional-argument, boolean-default-value-positional-argument] 

469) -> str: 

470 """:param appname: See `appname <platformdirs.api.PlatformDirsABC.appname>`. 

471 :param appauthor: See `appauthor <platformdirs.api.PlatformDirsABC.appauthor>`. 

472 :param version: See `version <platformdirs.api.PlatformDirsABC.version>`. 

473 :param opinion: See `opinion <platformdirs.api.PlatformDirsABC.opinion>`. 

474 :param ensure_exists: See `ensure_exists <platformdirs.api.PlatformDirsABC.ensure_exists>`. 

475 :param use_site_for_root: See `use_site_for_root <platformdirs.api.PlatformDirsABC.use_site_for_root>`. 

476 

477 :returns: runtime directory tied to the user 

478 

479 """ 

480 return PlatformDirs( 

481 appname=appname, 

482 appauthor=appauthor, 

483 version=version, 

484 opinion=opinion, 

485 ensure_exists=ensure_exists, 

486 use_site_for_root=use_site_for_root, 

487 ).user_runtime_dir 

488 

489 

490def site_runtime_dir( 

491 appname: str | None = None, 

492 appauthor: str | Literal[False] | None = None, 

493 version: str | None = None, 

494 opinion: bool = True, # ruff:ignore[boolean-type-hint-positional-argument, boolean-default-value-positional-argument] 

495 ensure_exists: bool = False, # ruff:ignore[boolean-type-hint-positional-argument, boolean-default-value-positional-argument] 

496) -> str: 

497 """:param appname: See `appname <platformdirs.api.PlatformDirsABC.appname>`. 

498 :param appauthor: See `appauthor <platformdirs.api.PlatformDirsABC.appauthor>`. 

499 :param version: See `version <platformdirs.api.PlatformDirsABC.version>`. 

500 :param opinion: See `opinion <platformdirs.api.PlatformDirsABC.opinion>`. 

501 :param ensure_exists: See `ensure_exists <platformdirs.api.PlatformDirsABC.ensure_exists>`. 

502 

503 :returns: runtime directory shared by users 

504 

505 """ 

506 return PlatformDirs( 

507 appname=appname, 

508 appauthor=appauthor, 

509 version=version, 

510 opinion=opinion, 

511 ensure_exists=ensure_exists, 

512 ).site_runtime_dir 

513 

514 

515def user_data_path( # ruff:ignore[too-many-arguments, too-many-positional-arguments] 

516 appname: str | None = None, 

517 appauthor: str | Literal[False] | None = None, 

518 version: str | None = None, 

519 roaming: bool = False, # ruff:ignore[boolean-type-hint-positional-argument, boolean-default-value-positional-argument] 

520 ensure_exists: bool = False, # ruff:ignore[boolean-type-hint-positional-argument, boolean-default-value-positional-argument] 

521 use_site_for_root: bool = False, # ruff:ignore[boolean-type-hint-positional-argument, boolean-default-value-positional-argument] 

522) -> Path: 

523 """:param appname: See `appname <platformdirs.api.PlatformDirsABC.appname>`. 

524 :param appauthor: See `appauthor <platformdirs.api.PlatformDirsABC.appauthor>`. 

525 :param version: See `version <platformdirs.api.PlatformDirsABC.version>`. 

526 :param roaming: See `roaming <platformdirs.api.PlatformDirsABC.roaming>`. 

527 :param ensure_exists: See `ensure_exists <platformdirs.api.PlatformDirsABC.ensure_exists>`. 

528 :param use_site_for_root: See `use_site_for_root <platformdirs.api.PlatformDirsABC.use_site_for_root>`. 

529 

530 :returns: data path tied to the user 

531 

532 """ 

533 return PlatformDirs( 

534 appname=appname, 

535 appauthor=appauthor, 

536 version=version, 

537 roaming=roaming, 

538 ensure_exists=ensure_exists, 

539 use_site_for_root=use_site_for_root, 

540 ).user_data_path 

541 

542 

543def site_data_path( 

544 appname: str | None = None, 

545 appauthor: str | Literal[False] | None = None, 

546 version: str | None = None, 

547 multipath: bool = False, # ruff:ignore[boolean-type-hint-positional-argument, boolean-default-value-positional-argument] 

548 ensure_exists: bool = False, # ruff:ignore[boolean-type-hint-positional-argument, boolean-default-value-positional-argument] 

549) -> Path: 

550 """:param appname: See `appname <platformdirs.api.PlatformDirsABC.appname>`. 

551 :param appauthor: See `appauthor <platformdirs.api.PlatformDirsABC.appauthor>`. 

552 :param version: See `version <platformdirs.api.PlatformDirsABC.version>`. 

553 :param multipath: See `multipath <platformdirs.api.PlatformDirsABC.multipath>`. 

554 :param ensure_exists: See `ensure_exists <platformdirs.api.PlatformDirsABC.ensure_exists>`. 

555 

556 :returns: data path shared by users 

557 

558 """ 

559 return PlatformDirs( 

560 appname=appname, 

561 appauthor=appauthor, 

562 version=version, 

563 multipath=multipath, 

564 ensure_exists=ensure_exists, 

565 ).site_data_path 

566 

567 

568def user_config_path( # ruff:ignore[too-many-arguments, too-many-positional-arguments] 

569 appname: str | None = None, 

570 appauthor: str | Literal[False] | None = None, 

571 version: str | None = None, 

572 roaming: bool = False, # ruff:ignore[boolean-type-hint-positional-argument, boolean-default-value-positional-argument] 

573 ensure_exists: bool = False, # ruff:ignore[boolean-type-hint-positional-argument, boolean-default-value-positional-argument] 

574 use_site_for_root: bool = False, # ruff:ignore[boolean-type-hint-positional-argument, boolean-default-value-positional-argument] 

575) -> Path: 

576 """:param appname: See `appname <platformdirs.api.PlatformDirsABC.appname>`. 

577 :param appauthor: See `appauthor <platformdirs.api.PlatformDirsABC.appauthor>`. 

578 :param version: See `version <platformdirs.api.PlatformDirsABC.version>`. 

579 :param roaming: See `roaming <platformdirs.api.PlatformDirsABC.roaming>`. 

580 :param ensure_exists: See `ensure_exists <platformdirs.api.PlatformDirsABC.ensure_exists>`. 

581 :param use_site_for_root: See `use_site_for_root <platformdirs.api.PlatformDirsABC.use_site_for_root>`. 

582 

583 :returns: config path tied to the user 

584 

585 """ 

586 return PlatformDirs( 

587 appname=appname, 

588 appauthor=appauthor, 

589 version=version, 

590 roaming=roaming, 

591 ensure_exists=ensure_exists, 

592 use_site_for_root=use_site_for_root, 

593 ).user_config_path 

594 

595 

596def site_config_path( 

597 appname: str | None = None, 

598 appauthor: str | Literal[False] | None = None, 

599 version: str | None = None, 

600 multipath: bool = False, # ruff:ignore[boolean-type-hint-positional-argument, boolean-default-value-positional-argument] 

601 ensure_exists: bool = False, # ruff:ignore[boolean-type-hint-positional-argument, boolean-default-value-positional-argument] 

602) -> Path: 

603 """:param appname: See `appname <platformdirs.api.PlatformDirsABC.appname>`. 

604 :param appauthor: See `appauthor <platformdirs.api.PlatformDirsABC.appauthor>`. 

605 :param version: See `version <platformdirs.api.PlatformDirsABC.version>`. 

606 :param multipath: See `multipath <platformdirs.api.PlatformDirsABC.multipath>`. 

607 :param ensure_exists: See `ensure_exists <platformdirs.api.PlatformDirsABC.ensure_exists>`. 

608 

609 :returns: config path shared by users 

610 

611 """ 

612 return PlatformDirs( 

613 appname=appname, 

614 appauthor=appauthor, 

615 version=version, 

616 multipath=multipath, 

617 ensure_exists=ensure_exists, 

618 ).site_config_path 

619 

620 

621def site_cache_path( 

622 appname: str | None = None, 

623 appauthor: str | Literal[False] | None = None, 

624 version: str | None = None, 

625 opinion: bool = True, # ruff:ignore[boolean-type-hint-positional-argument, boolean-default-value-positional-argument] 

626 ensure_exists: bool = False, # ruff:ignore[boolean-type-hint-positional-argument, boolean-default-value-positional-argument] 

627) -> Path: 

628 """:param appname: See `appname <platformdirs.api.PlatformDirsABC.appname>`. 

629 :param appauthor: See `appauthor <platformdirs.api.PlatformDirsABC.appauthor>`. 

630 :param version: See `version <platformdirs.api.PlatformDirsABC.version>`. 

631 :param opinion: See `opinion <platformdirs.api.PlatformDirsABC.opinion>`. 

632 :param ensure_exists: See `ensure_exists <platformdirs.api.PlatformDirsABC.ensure_exists>`. 

633 

634 :returns: cache path shared by users 

635 

636 """ 

637 return PlatformDirs( 

638 appname=appname, 

639 appauthor=appauthor, 

640 version=version, 

641 opinion=opinion, 

642 ensure_exists=ensure_exists, 

643 ).site_cache_path 

644 

645 

646def user_cache_path( # ruff:ignore[too-many-arguments, too-many-positional-arguments] 

647 appname: str | None = None, 

648 appauthor: str | Literal[False] | None = None, 

649 version: str | None = None, 

650 opinion: bool = True, # ruff:ignore[boolean-type-hint-positional-argument, boolean-default-value-positional-argument] 

651 ensure_exists: bool = False, # ruff:ignore[boolean-type-hint-positional-argument, boolean-default-value-positional-argument] 

652 use_site_for_root: bool = False, # ruff:ignore[boolean-type-hint-positional-argument, boolean-default-value-positional-argument] 

653) -> Path: 

654 """:param appname: See `appname <platformdirs.api.PlatformDirsABC.appname>`. 

655 :param appauthor: See `appauthor <platformdirs.api.PlatformDirsABC.appauthor>`. 

656 :param version: See `version <platformdirs.api.PlatformDirsABC.version>`. 

657 :param opinion: See `opinion <platformdirs.api.PlatformDirsABC.opinion>`. 

658 :param ensure_exists: See `ensure_exists <platformdirs.api.PlatformDirsABC.ensure_exists>`. 

659 :param use_site_for_root: See `use_site_for_root <platformdirs.api.PlatformDirsABC.use_site_for_root>`. 

660 

661 :returns: cache path tied to the user 

662 

663 """ 

664 return PlatformDirs( 

665 appname=appname, 

666 appauthor=appauthor, 

667 version=version, 

668 opinion=opinion, 

669 ensure_exists=ensure_exists, 

670 use_site_for_root=use_site_for_root, 

671 ).user_cache_path 

672 

673 

674def user_state_path( # ruff:ignore[too-many-arguments, too-many-positional-arguments] 

675 appname: str | None = None, 

676 appauthor: str | Literal[False] | None = None, 

677 version: str | None = None, 

678 roaming: bool = False, # ruff:ignore[boolean-type-hint-positional-argument, boolean-default-value-positional-argument] 

679 ensure_exists: bool = False, # ruff:ignore[boolean-type-hint-positional-argument, boolean-default-value-positional-argument] 

680 use_site_for_root: bool = False, # ruff:ignore[boolean-type-hint-positional-argument, boolean-default-value-positional-argument] 

681) -> Path: 

682 """:param appname: See `appname <platformdirs.api.PlatformDirsABC.appname>`. 

683 :param appauthor: See `appauthor <platformdirs.api.PlatformDirsABC.appauthor>`. 

684 :param version: See `version <platformdirs.api.PlatformDirsABC.version>`. 

685 :param roaming: See `roaming <platformdirs.api.PlatformDirsABC.roaming>`. 

686 :param ensure_exists: See `ensure_exists <platformdirs.api.PlatformDirsABC.ensure_exists>`. 

687 :param use_site_for_root: See `use_site_for_root <platformdirs.api.PlatformDirsABC.use_site_for_root>`. 

688 

689 :returns: state path tied to the user 

690 

691 """ 

692 return PlatformDirs( 

693 appname=appname, 

694 appauthor=appauthor, 

695 version=version, 

696 roaming=roaming, 

697 ensure_exists=ensure_exists, 

698 use_site_for_root=use_site_for_root, 

699 ).user_state_path 

700 

701 

702def site_state_path( 

703 appname: str | None = None, 

704 appauthor: str | Literal[False] | None = None, 

705 version: str | None = None, 

706 ensure_exists: bool = False, # ruff:ignore[boolean-type-hint-positional-argument, boolean-default-value-positional-argument] 

707) -> Path: 

708 """:param appname: See `appname <platformdirs.api.PlatformDirsABC.appname>`. 

709 :param appauthor: See `appauthor <platformdirs.api.PlatformDirsABC.appauthor>`. 

710 :param version: See `version <platformdirs.api.PlatformDirsABC.version>`. 

711 :param ensure_exists: See `ensure_exists <platformdirs.api.PlatformDirsABC.ensure_exists>`. 

712 

713 :returns: state path shared by users 

714 

715 """ 

716 return PlatformDirs( 

717 appname=appname, 

718 appauthor=appauthor, 

719 version=version, 

720 ensure_exists=ensure_exists, 

721 ).site_state_path 

722 

723 

724def user_log_path( # ruff:ignore[too-many-arguments, too-many-positional-arguments] 

725 appname: str | None = None, 

726 appauthor: str | Literal[False] | None = None, 

727 version: str | None = None, 

728 opinion: bool = True, # ruff:ignore[boolean-type-hint-positional-argument, boolean-default-value-positional-argument] 

729 ensure_exists: bool = False, # ruff:ignore[boolean-type-hint-positional-argument, boolean-default-value-positional-argument] 

730 use_site_for_root: bool = False, # ruff:ignore[boolean-type-hint-positional-argument, boolean-default-value-positional-argument] 

731) -> Path: 

732 """:param appname: See `appname <platformdirs.api.PlatformDirsABC.appname>`. 

733 :param appauthor: See `appauthor <platformdirs.api.PlatformDirsABC.appauthor>`. 

734 :param version: See `version <platformdirs.api.PlatformDirsABC.version>`. 

735 :param opinion: See `opinion <platformdirs.api.PlatformDirsABC.opinion>`. 

736 :param ensure_exists: See `ensure_exists <platformdirs.api.PlatformDirsABC.ensure_exists>`. 

737 :param use_site_for_root: See `use_site_for_root <platformdirs.api.PlatformDirsABC.use_site_for_root>`. 

738 

739 :returns: log path tied to the user 

740 

741 """ 

742 return PlatformDirs( 

743 appname=appname, 

744 appauthor=appauthor, 

745 version=version, 

746 opinion=opinion, 

747 ensure_exists=ensure_exists, 

748 use_site_for_root=use_site_for_root, 

749 ).user_log_path 

750 

751 

752def site_log_path( 

753 appname: str | None = None, 

754 appauthor: str | Literal[False] | None = None, 

755 version: str | None = None, 

756 opinion: bool = True, # ruff:ignore[boolean-type-hint-positional-argument, boolean-default-value-positional-argument] 

757 ensure_exists: bool = False, # ruff:ignore[boolean-type-hint-positional-argument, boolean-default-value-positional-argument] 

758) -> Path: 

759 """:param appname: See `appname <platformdirs.api.PlatformDirsABC.appname>`. 

760 :param appauthor: See `appauthor <platformdirs.api.PlatformDirsABC.appauthor>`. 

761 :param version: See `version <platformdirs.api.PlatformDirsABC.version>`. 

762 :param opinion: See `opinion <platformdirs.api.PlatformDirsABC.opinion>`. 

763 :param ensure_exists: See `ensure_exists <platformdirs.api.PlatformDirsABC.ensure_exists>`. 

764 

765 :returns: log path shared by users 

766 

767 """ 

768 return PlatformDirs( 

769 appname=appname, 

770 appauthor=appauthor, 

771 version=version, 

772 opinion=opinion, 

773 ensure_exists=ensure_exists, 

774 ).site_log_path 

775 

776 

777def user_documents_path() -> Path: 

778 """:returns: documents path tied to the user""" 

779 return PlatformDirs().user_documents_path 

780 

781 

782def user_downloads_path() -> Path: 

783 """:returns: downloads path tied to the user""" 

784 return PlatformDirs().user_downloads_path 

785 

786 

787def user_pictures_path() -> Path: 

788 """:returns: pictures path tied to the user""" 

789 return PlatformDirs().user_pictures_path 

790 

791 

792def user_videos_path() -> Path: 

793 """:returns: videos path tied to the user""" 

794 return PlatformDirs().user_videos_path 

795 

796 

797def user_music_path() -> Path: 

798 """:returns: music path tied to the user""" 

799 return PlatformDirs().user_music_path 

800 

801 

802def user_desktop_path() -> Path: 

803 """:returns: desktop path tied to the user""" 

804 return PlatformDirs().user_desktop_path 

805 

806 

807def user_projects_path() -> Path: 

808 """:returns: projects path tied to the user""" 

809 return PlatformDirs().user_projects_path 

810 

811 

812def user_publicshare_path() -> Path: 

813 """:returns: public share path tied to the user""" 

814 return PlatformDirs().user_publicshare_path 

815 

816 

817def user_templates_path() -> Path: 

818 """:returns: templates path tied to the user""" 

819 return PlatformDirs().user_templates_path 

820 

821 

822def user_fonts_path() -> Path: 

823 """:returns: fonts path tied to the user""" 

824 return PlatformDirs().user_fonts_path 

825 

826 

827def user_preference_path( # ruff:ignore[too-many-arguments] 

828 appname: str | None = None, 

829 appauthor: str | Literal[False] | None = None, 

830 version: str | None = None, 

831 *, 

832 roaming: bool = False, 

833 ensure_exists: bool = False, 

834 use_site_for_root: bool = False, 

835) -> Path: 

836 """:param appname: See `appname <platformdirs.api.PlatformDirsABC.appname>`. 

837 :param appauthor: See `appauthor <platformdirs.api.PlatformDirsABC.appauthor>`. 

838 :param version: See `version <platformdirs.api.PlatformDirsABC.version>`. 

839 :param roaming: See `roaming <platformdirs.api.PlatformDirsABC.roaming>`. 

840 :param ensure_exists: See `ensure_exists <platformdirs.api.PlatformDirsABC.ensure_exists>`. 

841 :param use_site_for_root: See `use_site_for_root <platformdirs.api.PlatformDirsABC.use_site_for_root>`. 

842 

843 :returns: preference path tied to the user 

844 

845 """ 

846 return PlatformDirs( 

847 appname=appname, 

848 appauthor=appauthor, 

849 version=version, 

850 roaming=roaming, 

851 ensure_exists=ensure_exists, 

852 use_site_for_root=use_site_for_root, 

853 ).user_preference_path 

854 

855 

856def user_bin_path(*, use_site_for_root: bool = False) -> Path: 

857 """:param use_site_for_root: See `use_site_for_root <platformdirs.api.PlatformDirsABC.use_site_for_root>`. 

858 

859 :returns: bin path tied to the user 

860 

861 """ 

862 return PlatformDirs(use_site_for_root=use_site_for_root).user_bin_path 

863 

864 

865def site_bin_path() -> Path: 

866 """:returns: bin path shared by users""" 

867 return PlatformDirs().site_bin_path 

868 

869 

870def user_applications_path( 

871 appname: str | None = None, 

872 appauthor: str | Literal[False] | None = None, 

873 version: str | None = None, 

874 *, 

875 ensure_exists: bool = False, 

876 use_site_for_root: bool = False, 

877) -> Path: 

878 """:param appname: See `appname <platformdirs.api.PlatformDirsABC.appname>`. 

879 :param appauthor: See `appauthor <platformdirs.api.PlatformDirsABC.appauthor>`. 

880 :param version: See `version <platformdirs.api.PlatformDirsABC.version>`. 

881 :param ensure_exists: See `ensure_exists <platformdirs.api.PlatformDirsABC.ensure_exists>`. 

882 :param use_site_for_root: See `use_site_for_root <platformdirs.api.PlatformDirsABC.use_site_for_root>`. 

883 

884 :returns: applications path tied to the user 

885 

886 """ 

887 return PlatformDirs( 

888 appname=appname, 

889 appauthor=appauthor, 

890 version=version, 

891 ensure_exists=ensure_exists, 

892 use_site_for_root=use_site_for_root, 

893 ).user_applications_path 

894 

895 

896def site_applications_path( 

897 multipath: bool = False, # ruff:ignore[boolean-type-hint-positional-argument, boolean-default-value-positional-argument] 

898 ensure_exists: bool = False, # ruff:ignore[boolean-type-hint-positional-argument, boolean-default-value-positional-argument] 

899 *, 

900 appname: str | None = None, 

901 appauthor: str | Literal[False] | None = None, 

902 version: str | None = None, 

903) -> Path: 

904 """:param multipath: See `multipath <platformdirs.api.PlatformDirsABC.multipath>`. 

905 :param ensure_exists: See `ensure_exists <platformdirs.api.PlatformDirsABC.ensure_exists>`. 

906 :param appname: See `appname <platformdirs.api.PlatformDirsABC.appname>`. 

907 :param appauthor: See `appauthor <platformdirs.api.PlatformDirsABC.appauthor>`. 

908 :param version: See `version <platformdirs.api.PlatformDirsABC.version>`. 

909 

910 :returns: applications path shared by users 

911 

912 """ 

913 return PlatformDirs( 

914 appname=appname, 

915 appauthor=appauthor, 

916 version=version, 

917 multipath=multipath, 

918 ensure_exists=ensure_exists, 

919 ).site_applications_path 

920 

921 

922def user_runtime_path( # ruff:ignore[too-many-arguments, too-many-positional-arguments] 

923 appname: str | None = None, 

924 appauthor: str | Literal[False] | None = None, 

925 version: str | None = None, 

926 opinion: bool = True, # ruff:ignore[boolean-type-hint-positional-argument, boolean-default-value-positional-argument] 

927 ensure_exists: bool = False, # ruff:ignore[boolean-type-hint-positional-argument, boolean-default-value-positional-argument] 

928 use_site_for_root: bool = False, # ruff:ignore[boolean-type-hint-positional-argument, boolean-default-value-positional-argument] 

929) -> Path: 

930 """:param appname: See `appname <platformdirs.api.PlatformDirsABC.appname>`. 

931 :param appauthor: See `appauthor <platformdirs.api.PlatformDirsABC.appauthor>`. 

932 :param version: See `version <platformdirs.api.PlatformDirsABC.version>`. 

933 :param opinion: See `opinion <platformdirs.api.PlatformDirsABC.opinion>`. 

934 :param ensure_exists: See `ensure_exists <platformdirs.api.PlatformDirsABC.ensure_exists>`. 

935 :param use_site_for_root: See `use_site_for_root <platformdirs.api.PlatformDirsABC.use_site_for_root>`. 

936 

937 :returns: runtime path tied to the user 

938 

939 """ 

940 return PlatformDirs( 

941 appname=appname, 

942 appauthor=appauthor, 

943 version=version, 

944 opinion=opinion, 

945 ensure_exists=ensure_exists, 

946 use_site_for_root=use_site_for_root, 

947 ).user_runtime_path 

948 

949 

950def site_runtime_path( 

951 appname: str | None = None, 

952 appauthor: str | Literal[False] | None = None, 

953 version: str | None = None, 

954 opinion: bool = True, # ruff:ignore[boolean-type-hint-positional-argument, boolean-default-value-positional-argument] 

955 ensure_exists: bool = False, # ruff:ignore[boolean-type-hint-positional-argument, boolean-default-value-positional-argument] 

956) -> Path: 

957 """:param appname: See `appname <platformdirs.api.PlatformDirsABC.appname>`. 

958 :param appauthor: See `appauthor <platformdirs.api.PlatformDirsABC.appauthor>`. 

959 :param version: See `version <platformdirs.api.PlatformDirsABC.version>`. 

960 :param opinion: See `opinion <platformdirs.api.PlatformDirsABC.opinion>`. 

961 :param ensure_exists: See `ensure_exists <platformdirs.api.PlatformDirsABC.ensure_exists>`. 

962 

963 :returns: runtime path shared by users 

964 

965 """ 

966 return PlatformDirs( 

967 appname=appname, 

968 appauthor=appauthor, 

969 version=version, 

970 opinion=opinion, 

971 ensure_exists=ensure_exists, 

972 ).site_runtime_path 

973 

974 

975__all__ = [ 

976 "AppDirs", 

977 "PlatformDirs", 

978 "PlatformDirsABC", 

979 "__version__", 

980 "__version_info__", 

981 "site_applications_dir", 

982 "site_applications_path", 

983 "site_bin_dir", 

984 "site_bin_path", 

985 "site_cache_dir", 

986 "site_cache_path", 

987 "site_config_dir", 

988 "site_config_path", 

989 "site_data_dir", 

990 "site_data_path", 

991 "site_log_dir", 

992 "site_log_path", 

993 "site_runtime_dir", 

994 "site_runtime_path", 

995 "site_state_dir", 

996 "site_state_path", 

997 "user_applications_dir", 

998 "user_applications_path", 

999 "user_bin_dir", 

1000 "user_bin_path", 

1001 "user_cache_dir", 

1002 "user_cache_path", 

1003 "user_config_dir", 

1004 "user_config_path", 

1005 "user_data_dir", 

1006 "user_data_path", 

1007 "user_desktop_dir", 

1008 "user_desktop_path", 

1009 "user_documents_dir", 

1010 "user_documents_path", 

1011 "user_downloads_dir", 

1012 "user_downloads_path", 

1013 "user_fonts_dir", 

1014 "user_fonts_path", 

1015 "user_log_dir", 

1016 "user_log_path", 

1017 "user_music_dir", 

1018 "user_music_path", 

1019 "user_pictures_dir", 

1020 "user_pictures_path", 

1021 "user_preference_dir", 

1022 "user_preference_path", 

1023 "user_projects_dir", 

1024 "user_projects_path", 

1025 "user_publicshare_dir", 

1026 "user_publicshare_path", 

1027 "user_runtime_dir", 

1028 "user_runtime_path", 

1029 "user_state_dir", 

1030 "user_state_path", 

1031 "user_templates_dir", 

1032 "user_templates_path", 

1033 "user_videos_dir", 

1034 "user_videos_path", 

1035]