2from __future__
import annotations
5from abc
import ABC, abstractmethod
6from pathlib
import Path
7from typing
import TYPE_CHECKING
13 from typing
import Literal
19 """Abstract base class for platform directories."""
23 appname: str |
None =
None,
24 appauthor: str |
None | Literal[
False] =
None,
25 version: str |
None =
None,
26 roaming: bool =
False,
27 multipath: bool =
False,
29 ensure_exists: bool =
False,
32 Create a new platform directory.
34 :param appname: See `appname`.
35 :param appauthor: See `appauthor`.
36 :param version: See `version`.
37 :param roaming: See `roaming`.
38 :param multipath: See `multipath`.
39 :param opinion: See `opinion`.
40 :param ensure_exists: See `ensure_exists`.
45 The name of the app author or distributing body for this application. Typically, it is the owning company name.
46 Defaults to `appname`. You may pass ``False`` to disable it.
50 An optional version path element to append to the path. You might want to use this if you want multiple versions
51 of your app to be able to run independently. If used, this would typically be ``<major>.<minor>``.
55 Whether to use the roaming appdata directory on Windows. That means that for users on a Windows network setup
56 for roaming profiles, this user data will be synced on login (see
57 `here <http://technet.microsoft.com/en-us/library/cc766489(WS.10).aspx>`_).
61 An optional parameter only applicable to Unix/Linux which indicates that the entire list of data dirs should be
62 returned. By default, the first item would only be returned.
67 Optionally create the directory (and any missing parents) upon access if it does not exist.
68 By default, no directories are created.
72 params = list(base[1:])
83 Path(path).mkdir(parents=
True, exist_ok=
True)
88 """:return: data directory tied to the user"""
92 def site_data_dir(self) -> str:
93 """:return: data directory shared by users"""
97 def user_config_dir(self) -> str:
98 """:return: config directory tied to the use
r"""
102 def site_config_dir(self) -> str:
103 """:return: config directory shared by the users"""
107 def user_cache_dir(self) -> str:
108 """:return: cache directory tied to the use
r"""
112 def site_cache_dir(self) -> str:
113 """:return: cache directory shared by users"""
117 def user_state_dir(self) -> str:
118 """:return: state directory tied to the use
r"""
122 def user_log_dir(self) -> str:
123 """:return: log directory tied to the use
r"""
127 def user_documents_dir(self) -> str:
128 """:return: documents directory tied to the use
r"""
132 def user_downloads_dir(self) -> str:
133 """:return: downloads directory tied to the use
r"""
137 def user_pictures_dir(self) -> str:
138 """:return: pictures directory tied to the use
r"""
142 def user_videos_dir(self) -> str:
143 """:return: videos directory tied to the use
r"""
147 def user_music_dir(self) -> str:
148 """:return: music directory tied to the use
r"""
152 def user_runtime_dir(self) -> str:
153 """:return: runtime directory tied to the use
r"""
156 def user_data_path(self) -> Path:
157 """:return: data path tied to the use
r"""
158 return Path(self.user_data_dir)
161 def site_data_path(self) -> Path:
162 """:return: data path shared by users"""
163 return Path(self.site_data_dir)
166 def user_config_path(self) -> Path:
167 """:return: config path tied to the use
r"""
168 return Path(self.user_config_dir)
171 def site_config_path(self) -> Path:
172 """:return: config path shared by the users"""
173 return Path(self.site_config_dir)
176 def user_cache_path(self) -> Path:
177 """:return: cache path tied to the use
r"""
178 return Path(self.user_cache_dir)
181 def site_cache_path(self) -> Path:
182 """:return: cache path shared by users"""
183 return Path(self.site_cache_dir)
186 def user_state_path(self) -> Path:
187 """:return: state path tied to the use
r"""
188 return Path(self.user_state_dir)
191 def user_log_path(self) -> Path:
192 """:return: log path tied to the use
r"""
193 return Path(self.user_log_dir)
196 def user_documents_path(self) -> Path:
197 """:return: documents path tied to the use
r"""
198 return Path(self.user_documents_dir)
201 def user_downloads_path(self) -> Path:
202 """:return: downloads path tied to the use
r"""
203 return Path(self.user_downloads_dir)
206 def user_pictures_path(self) -> Path:
207 """:return: pictures path tied to the use
r"""
208 return Path(self.user_pictures_dir)
211 def user_videos_path(self) -> Path:
212 """:return: videos path tied to the use
r"""
213 return Path(self.user_videos_dir)
216 def user_music_path(self) -> Path:
217 """:return: music path tied to the use
r"""
218 return Path(self.user_music_dir)
221 def user_runtime_path(self) -> Path:
222 """:return: runtime path tied to the use
r"""
223 return Path(self.user_runtime_dir)