99
1010# see http://technet.microsoft.com/en-us/library/cc766489(WS.10).aspx
1111
12+ import abc
1213import typing
1314
15+ import six
16+
1417from .osfs import OSFS
1518from ._repr import make_repr
1619from appdirs import AppDirs
2932]
3033
3134
35+ class _CopyInitMeta (abc .ABCMeta ):
36+ """A metaclass that performs a hard copy of the `__init__`.
37+
38+ This is a fix for Sphinx, which is a pain to configure in a way that
39+ it documents the ``__init__`` method of a class when it is inherited.
40+ Copying ``__init__`` makes it think it is not inherited, and let us
41+ share the documentation between all the `_AppFS` subclasses.
42+
43+ """
44+
45+ def __new__ (mcls , classname , bases , cls_dict ):
46+ cls_dict .setdefault ("__init__" , bases [0 ].__init__ )
47+ return super ().__new__ (mcls , classname , bases , cls_dict )
48+
49+
50+ @six .add_metaclass (_CopyInitMeta )
3251class _AppFS (OSFS ):
3352 """Abstract base class for an app FS."""
3453
@@ -46,6 +65,19 @@ def __init__(
4665 create = True , # type: bool
4766 ):
4867 # type: (...) -> None
68+ """Create a new application-specific filesystem.
69+
70+ Arguments:
71+ appname (str): The name of the application.
72+ author (str): The name of the author (used on Windows).
73+ version (str): Optional version string, if a unique location
74+ per version of the application is required.
75+ roaming (bool): If `True`, use a *roaming* profile on
76+ Windows.
77+ create (bool): If `True` (the default) the directory
78+ will be created if it does not exist.
79+
80+ """
4981 self .app_dirs = AppDirs (appname , author , version , roaming )
5082 self ._create = create
5183 super (_AppFS , self ).__init__ (
@@ -76,16 +108,6 @@ class UserDataFS(_AppFS):
76108 May also be opened with
77109 ``open_fs('userdata://appname:author:version')``.
78110
79- Arguments:
80- appname (str): The name of the application.
81- author (str): The name of the author (used on Windows).
82- version (str): Optional version string, if a unique location
83- per version of the application is required.
84- roaming (bool): If `True`, use a *roaming* profile on
85- Windows.
86- create (bool): If `True` (the default) the directory
87- will be created if it does not exist.
88-
89111 """
90112
91113 app_dir = "user_data_dir"
@@ -97,16 +119,6 @@ class UserConfigFS(_AppFS):
97119 May also be opened with
98120 ``open_fs('userconf://appname:author:version')``.
99121
100- Arguments:
101- appname (str): The name of the application.
102- author (str): The name of the author (used on Windows).
103- version (str): Optional version string, if a unique location
104- per version of the application is required.
105- roaming (bool): If `True`, use a *roaming* profile on
106- Windows.
107- create (bool): If `True` (the default) the directory
108- will be created if it does not exist.
109-
110122 """
111123
112124 app_dir = "user_config_dir"
@@ -118,16 +130,6 @@ class UserCacheFS(_AppFS):
118130 May also be opened with
119131 ``open_fs('usercache://appname:author:version')``.
120132
121- Arguments:
122- appname (str): The name of the application.
123- author (str): The name of the author (used on Windows).
124- version (str): Optional version string, if a unique location
125- per version of the application is required.
126- roaming (bool): If `True`, use a *roaming* profile on
127- Windows.
128- create (bool): If `True` (the default) the directory
129- will be created if it does not exist.
130-
131133 """
132134
133135 app_dir = "user_cache_dir"
@@ -139,16 +141,6 @@ class SiteDataFS(_AppFS):
139141 May also be opened with
140142 ``open_fs('sitedata://appname:author:version')``.
141143
142- Arguments:
143- appname (str): The name of the application.
144- author (str): The name of the author (used on Windows).
145- version (str): Optional version string, if a unique location
146- per version of the application is required.
147- roaming (bool): If `True`, use a *roaming* profile on
148- Windows.
149- create (bool): If `True` (the default) the directory
150- will be created if it does not exist.
151-
152144 """
153145
154146 app_dir = "site_data_dir"
@@ -160,16 +152,6 @@ class SiteConfigFS(_AppFS):
160152 May also be opened with
161153 ``open_fs('siteconf://appname:author:version')``.
162154
163- Arguments:
164- appname (str): The name of the application.
165- author (str): The name of the author (used on Windows).
166- version (str): Optional version string, if a unique location
167- per version of the application is required.
168- roaming (bool): If `True`, use a *roaming* profile on
169- Windows.
170- create (bool): If `True` (the default) the directory
171- will be created if it does not exist.
172-
173155 """
174156
175157 app_dir = "site_config_dir"
@@ -181,16 +163,6 @@ class UserLogFS(_AppFS):
181163 May also be opened with
182164 ``open_fs('userlog://appname:author:version')``.
183165
184- Arguments:
185- appname (str): The name of the application.
186- author (str): The name of the author (used on Windows).
187- version (str): Optional version string, if a unique location
188- per version of the application is required.
189- roaming (bool): If `True`, use a *roaming* profile on
190- Windows.
191- create (bool): If `True` (the default) the directory
192- will be created if it does not exist.
193-
194166 """
195167
196168 app_dir = "user_log_dir"
0 commit comments