]>
crepu.dev Git - config.git/blob - djavu-asus/emacs/elpy/rpc-venv/lib/python3.11/site-packages/platformdirs/macos.py
c01ce163648cc3f2201b6af7d4543907c5cb43a3
2 from __future__
import annotations
7 from .api
import PlatformDirsABC
10 class MacOS(PlatformDirsABC
):
12 Platform directories for the macOS operating system. Follows the guidance from `Apple documentation
13 <https://developer.apple.com/library/archive/documentation/FileManagement/Conceptual/FileSystemProgrammingGuide/MacOSXDirectories/MacOSXDirectories.html>`_.
14 Makes use of the `appname <platformdirs.api.PlatformDirsABC.appname>`,
15 `version <platformdirs.api.PlatformDirsABC.version>`,
16 `ensure_exists <platformdirs.api.PlatformDirsABC.ensure_exists>`.
20 def user_data_dir(self
) -> str:
21 """:return: data directory tied to the user, e.g. ``~/Library/Application Support/$appname/$version``"""
22 return self
._append
_app
_name
_and
_version
(os
.path
.expanduser("~/Library/Application Support")) # noqa: PTH111
25 def site_data_dir(self
) -> str:
27 :return: data directory shared by users, e.g. ``/Library/Application Support/$appname/$version``.
28 If we're using a Python binary managed by `Homebrew <https://brew.sh>`_, the directory
29 will be under the Homebrew prefix, e.g. ``/opt/homebrew/share/$appname/$version``.
30 If `multipath <platformdirs.api.PlatformDirsABC.multipath>` is enabled and we're in Homebrew,
31 the response is a multi-path string separated by ":", e.g.
32 ``/opt/homebrew/share/$appname/$version:/Library/Application Support/$appname/$version``
34 is_homebrew
= sys
.prefix
.startswith("/opt/homebrew")
35 path_list
= [self
._append
_app
_name
_and
_version
("/opt/homebrew/share")] if is_homebrew
else []
36 path_list
.append(self
._append
_app
_name
_and
_version
("/Library/Application Support"))
38 return os
.pathsep
.join(path_list
)
42 def user_config_dir(self
) -> str:
43 """:return: config directory tied to the user, same as `user_data_dir`"""
44 return self
.user_data_dir
47 def site_config_dir(self
) -> str:
48 """:return: config directory shared by the users, same as `site_data_dir`"""
49 return self
.site_data_dir
52 def user_cache_dir(self
) -> str:
53 """:return: cache directory tied to the user, e.g. ``~/Library/Caches/$appname/$version``"""
54 return self
._append
_app
_name
_and
_version
(os
.path
.expanduser("~/Library/Caches")) # noqa: PTH111
57 def site_cache_dir(self
) -> str:
59 :return: cache directory shared by users, e.g. ``/Library/Caches/$appname/$version``.
60 If we're using a Python binary managed by `Homebrew <https://brew.sh>`_, the directory
61 will be under the Homebrew prefix, e.g. ``/opt/homebrew/var/cache/$appname/$version``.
62 If `multipath <platformdirs.api.PlatformDirsABC.multipath>` is enabled and we're in Homebrew,
63 the response is a multi-path string separated by ":", e.g.
64 ``/opt/homebrew/var/cache/$appname/$version:/Library/Caches/$appname/$version``
66 is_homebrew
= sys
.prefix
.startswith("/opt/homebrew")
67 path_list
= [self
._append
_app
_name
_and
_version
("/opt/homebrew/var/cache")] if is_homebrew
else []
68 path_list
.append(self
._append
_app
_name
_and
_version
("/Library/Caches"))
70 return os
.pathsep
.join(path_list
)
74 def user_state_dir(self
) -> str:
75 """:return: state directory tied to the user, same as `user_data_dir`"""
76 return self
.user_data_dir
79 def user_log_dir(self
) -> str:
80 """:return: log directory tied to the user, e.g. ``~/Library/Logs/$appname/$version``"""
81 return self
._append
_app
_name
_and
_version
(os
.path
.expanduser("~/Library/Logs")) # noqa: PTH111
84 def user_documents_dir(self
) -> str:
85 """:return: documents directory tied to the user, e.g. ``~/Documents``"""
86 return os
.path
.expanduser("~/Documents") # noqa: PTH111
89 def user_downloads_dir(self
) -> str:
90 """:return: downloads directory tied to the user, e.g. ``~/Downloads``"""
91 return os
.path
.expanduser("~/Downloads") # noqa: PTH111
94 def user_pictures_dir(self
) -> str:
95 """:return: pictures directory tied to the user, e.g. ``~/Pictures``"""
96 return os
.path
.expanduser("~/Pictures") # noqa: PTH111
99 def user_videos_dir(self
) -> str:
100 """:return: videos directory tied to the user, e.g. ``~/Movies``"""
101 return os
.path
.expanduser("~/Movies") # noqa: PTH111
104 def user_music_dir(self
) -> str:
105 """:return: music directory tied to the user, e.g. ``~/Music``"""
106 return os
.path
.expanduser("~/Music") # noqa: PTH111
109 def user_desktop_dir(self
) -> str:
110 """:return: desktop directory tied to the user, e.g. ``~/Desktop``"""
111 return os
.path
.expanduser("~/Desktop") # noqa: PTH111
114 def user_runtime_dir(self
) -> str:
115 """:return: runtime directory tied to the user, e.g. ``~/Library/Caches/TemporaryItems/$appname/$version``"""
116 return self
._append
_app
_name
_and
_version
(os
.path
.expanduser("~/Library/Caches/TemporaryItems")) # noqa: PTH111
119 def site_runtime_dir(self
) -> str:
120 """:return: runtime directory shared by users, same as `user_runtime_dir`"""
121 return self
.user_runtime_dir