a01337c7764e1e1aba1f3ba378a1c9241f31806d
[SubU] /
1 from __future__ import annotations
2
3 import os
4
5 from .api import PlatformDirsABC
6
7
8 class MacOS(PlatformDirsABC):
9     """
10     Platform directories for the macOS operating system. Follows the guidance from `Apple documentation
11     <https://developer.apple.com/library/archive/documentation/FileManagement/Conceptual/FileSystemProgrammingGuide/MacOSXDirectories/MacOSXDirectories.html>`_.
12     Makes use of the `appname <platformdirs.api.PlatformDirsABC.appname>` and
13     `version <platformdirs.api.PlatformDirsABC.version>`.
14     """
15
16     @property
17     def user_data_dir(self) -> str:
18         """:return: data directory tied to the user, e.g. ``~/Library/Application Support/$appname/$version``"""
19         return self._append_app_name_and_version(os.path.expanduser("~/Library/Application Support/"))
20
21     @property
22     def site_data_dir(self) -> str:
23         """:return: data directory shared by users, e.g. ``/Library/Application Support/$appname/$version``"""
24         return self._append_app_name_and_version("/Library/Application Support")
25
26     @property
27     def user_config_dir(self) -> str:
28         """:return: config directory tied to the user, e.g. ``~/Library/Preferences/$appname/$version``"""
29         return self._append_app_name_and_version(os.path.expanduser("~/Library/Preferences/"))
30
31     @property
32     def site_config_dir(self) -> str:
33         """:return: config directory shared by the users, e.g. ``/Library/Preferences/$appname``"""
34         return self._append_app_name_and_version("/Library/Preferences")
35
36     @property
37     def user_cache_dir(self) -> str:
38         """:return: cache directory tied to the user, e.g. ``~/Library/Caches/$appname/$version``"""
39         return self._append_app_name_and_version(os.path.expanduser("~/Library/Caches"))
40
41     @property
42     def user_state_dir(self) -> str:
43         """:return: state directory tied to the user, same as `user_data_dir`"""
44         return self.user_data_dir
45
46     @property
47     def user_log_dir(self) -> str:
48         """:return: log directory tied to the user, e.g. ``~/Library/Logs/$appname/$version``"""
49         return self._append_app_name_and_version(os.path.expanduser("~/Library/Logs"))
50
51     @property
52     def user_documents_dir(self) -> str:
53         """:return: documents directory tied to the user, e.g. ``~/Documents``"""
54         return os.path.expanduser("~/Documents")
55
56     @property
57     def user_runtime_dir(self) -> str:
58         """:return: runtime directory tied to the user, e.g. ``~/Library/Caches/TemporaryItems/$appname/$version``"""
59         return self._append_app_name_and_version(os.path.expanduser("~/Library/Caches/TemporaryItems"))
60
61
62 __all__ = [
63     "MacOS",
64 ]