]>
jfr.im git - dlqueue.git/blob - venv/lib/python3.11/site-packages/pkg_resources/_vendor/platformdirs/api.py
1 from __future__
import annotations
5 from abc
import ABC
, abstractmethod
6 from pathlib
import Path
8 if sys
.version_info
>= (3, 8): # pragma: no branch
9 from typing
import Literal
# pragma: no cover
12 class PlatformDirsABC(ABC
):
14 Abstract base class for platform directories.
19 appname
: str |
None = None,
20 appauthor
: str |
None | Literal
[False] = None,
21 version
: str |
None = None,
22 roaming
: bool = False,
23 multipath
: bool = False,
27 Create a new platform directory.
29 :param appname: See `appname`.
30 :param appauthor: See `appauthor`.
31 :param version: See `version`.
32 :param roaming: See `roaming`.
33 :param multipath: See `multipath`.
34 :param opinion: See `opinion`.
36 self
.appname
= appname
#: The name of application.
37 self
.appauthor
= appauthor
39 The name of the app author or distributing body for this application. Typically, it is the owning company name.
40 Defaults to `appname`. You may pass ``False`` to disable it.
42 self
.version
= version
44 An optional version path element to append to the path. You might want to use this if you want multiple versions
45 of your app to be able to run independently. If used, this would typically be ``<major>.<minor>``.
47 self
.roaming
= roaming
49 Whether to use the roaming appdata directory on Windows. That means that for users on a Windows network setup
50 for roaming profiles, this user data will be synced on login (see
51 `here <http://technet.microsoft.com/en-us/library/cc766489(WS.10).aspx>`_).
53 self
.multipath
= multipath
55 An optional parameter only applicable to Unix/Linux which indicates that the entire list of data dirs should be
56 returned. By default, the first item would only be returned.
58 self
.opinion
= opinion
#: A flag to indicating to use opinionated values.
60 def _append_app_name_and_version(self
, *base
: str) -> str:
61 params
= list(base
[1:])
63 params
.append(self
.appname
)
65 params
.append(self
.version
)
66 return os
.path
.join(base
[0], *params
)
70 def user_data_dir(self
) -> str:
71 """:return: data directory tied to the user"""
75 def site_data_dir(self
) -> str:
76 """:return: data directory shared by users"""
80 def user_config_dir(self
) -> str:
81 """:return: config directory tied to the user"""
85 def site_config_dir(self
) -> str:
86 """:return: config directory shared by the users"""
90 def user_cache_dir(self
) -> str:
91 """:return: cache directory tied to the user"""
95 def user_state_dir(self
) -> str:
96 """:return: state directory tied to the user"""
100 def user_log_dir(self
) -> str:
101 """:return: log directory tied to the user"""
105 def user_documents_dir(self
) -> str:
106 """:return: documents directory tied to the user"""
110 def user_runtime_dir(self
) -> str:
111 """:return: runtime directory tied to the user"""
114 def user_data_path(self
) -> Path
:
115 """:return: data path tied to the user"""
116 return Path(self
.user_data_dir
)
119 def site_data_path(self
) -> Path
:
120 """:return: data path shared by users"""
121 return Path(self
.site_data_dir
)
124 def user_config_path(self
) -> Path
:
125 """:return: config path tied to the user"""
126 return Path(self
.user_config_dir
)
129 def site_config_path(self
) -> Path
:
130 """:return: config path shared by the users"""
131 return Path(self
.site_config_dir
)
134 def user_cache_path(self
) -> Path
:
135 """:return: cache path tied to the user"""
136 return Path(self
.user_cache_dir
)
139 def user_state_path(self
) -> Path
:
140 """:return: state path tied to the user"""
141 return Path(self
.user_state_dir
)
144 def user_log_path(self
) -> Path
:
145 """:return: log path tied to the user"""
146 return Path(self
.user_log_dir
)
149 def user_documents_path(self
) -> Path
:
150 """:return: documents path tied to the user"""
151 return Path(self
.user_documents_dir
)
154 def user_runtime_path(self
) -> Path
:
155 """:return: runtime path tied to the user"""
156 return Path(self
.user_runtime_dir
)