55from __future__ import annotations
66
77import os
8- from typing import Literal
8+ import pathlib
9+ from functools import cached_property
10+ from typing import Protocol
911
10- from platformdirs import PlatformDirs , PlatformDirsABC
12+ from platformdirs import PlatformDirs
1113
1214
13- def _resolve_platform_dirs () -> PlatformDirsABC :
15+ class PlatformDirsProto (Protocol ):
16+ @property
17+ def user_config_path (self ) -> pathlib .Path :
18+ ...
19+
20+
21+ def _resolve_platform_dirs () -> PlatformDirsProto :
1422 """Decide on what PlatformDirs class to use.
1523
1624 In case a folder exists (which can be customized with the environmental
@@ -40,7 +48,7 @@ def _resolve_platform_dirs() -> PlatformDirsABC:
4048 return PlatformDirs (** platformdir_kwargs )
4149
4250
43- class SFPlatformDirs ( PlatformDirsABC ) :
51+ class SFPlatformDirs :
4452 """Single folder platformdirs.
4553
4654 This class introduces a PlatformDir class where everything is placed into a
@@ -51,91 +59,11 @@ class SFPlatformDirs(PlatformDirsABC):
5159 def __init__ (
5260 self ,
5361 single_dir : str ,
54- appname : str | None = None ,
55- appauthor : str | None | Literal [False ] = None ,
56- version : str | None = None ,
57- roaming : bool = False ,
58- multipath : bool = False ,
59- opinion : bool = True ,
60- ensure_exists : bool = False ,
62+ ** kwargs ,
6163 ) -> None :
62- super ().__init__ (
63- appname = appname ,
64- appauthor = appauthor ,
65- version = version ,
66- roaming = roaming ,
67- multipath = multipath ,
68- opinion = opinion ,
69- ensure_exists = ensure_exists ,
70- )
71- self .single_dir = single_dir
64+ self .single_dir = pathlib .Path (single_dir )
7265
73- @property
74- def user_data_dir (self ) -> str :
66+ @cached_property
67+ def user_config_path (self ) -> str :
7568 """data directory tied to to the user"""
7669 return self .single_dir
77-
78- @property
79- def site_data_dir (self ) -> str :
80- """data directory shared by users"""
81- return self .user_data_dir
82-
83- @property
84- def user_config_dir (self ) -> str :
85- """config directory tied to the user"""
86- return self .user_data_dir
87-
88- @property
89- def site_config_dir (self ) -> str :
90- """config directory shared by the users"""
91- return self .user_data_dir
92-
93- @property
94- def user_cache_dir (self ) -> str :
95- """cache directory tied to the user"""
96- return self .user_data_dir
97-
98- @property
99- def site_cache_dir (self ) -> str :
100- """cache directory shared by users"""
101- return self .user_data_dir
102-
103- @property
104- def user_state_dir (self ) -> str :
105- """state directory tied to the user"""
106- return self .user_data_dir
107-
108- @property
109- def user_log_dir (self ) -> str :
110- """log directory tied to the user"""
111- return self .user_data_dir
112-
113- @property
114- def user_documents_dir (self ) -> str :
115- """documents directory tied to the user"""
116- return self .user_data_dir
117-
118- @property
119- def user_runtime_dir (self ) -> str :
120- """runtime directory tied to the user"""
121- return self .user_data_dir
122-
123- @property
124- def user_music_dir (self ) -> str :
125- """music directory tied to the user"""
126- return self .user_data_dir
127-
128- @property
129- def user_pictures_dir (self ) -> str :
130- """pictures directory tied to the user"""
131- return self .user_data_dir
132-
133- @property
134- def user_videos_dir (self ) -> str :
135- """videos directory tied to the user"""
136- return self .user_data_dir
137-
138- @property
139- def user_downloads_dir (self ) -> str :
140- """downloads directory tied to the user"""
141- return self .user_data_dir
0 commit comments