:param appname: See `appname`.
:param appauthor: See `appauthor`.
:param version: See `version`.
:param roaming: See `roaming`.
:param multipath: See `multipath`.
:param opinion: See `opinion`.
:param ensure_exists: See `ensure_exists`.
"""
self.appname = appname #: The name of application.
self.appauthor = appauthor """
The name of the app author or distributing body for this application.
Typically, it is the owning company name. Defaults to `appname`. You may pass ``False`` to disable it.
"""
self.version = version """
An optional version path element to append to the path.
You might want to use this if you want multiple versions of your app to be able to run independently. If used,
this would typically be ``<major>.<minor>``.
"""
self.roaming = roaming """
Whether to use the roaming appdata directory on Windows.
"""
self.multipath = multipath """
An optional parameter which indicates that the entire list of data dirs should be returned.
By default, the first item would only be returned.
"""
self.opinion = opinion #: A flag to indicating to use opinionated values.
self.ensure_exists = ensure_exists """
Optionally create the directory (and any missing parents) upon access if it does not exist.
def _optionally_create_directory(self, path: str) -> None: if self.ensure_exists:
Path(path).mkdir(parents=True, exist_ok=True)
def _first_item_as_path_if_multipath(self, directory: str) -> Path: if self.multipath: # If multipath is True, the first path is returned.
directory = directory.split(os.pathsep)[0] return Path(directory)
@property
@abstractmethod def user_data_dir(self) -> str: """:return: data directory tied to the user"""
@property
@abstractmethod def site_data_dir(self) -> str: """:return: data directory shared by users"""
@property
@abstractmethod def user_config_dir(self) -> str: """:return: config directory tied to the user"""
@property
@abstractmethod def site_config_dir(self) -> str: """:return: config directory shared by the users"""
@property
@abstractmethod def user_cache_dir(self) -> str: """:return: cache directory tied to the user"""
def iter_config_dirs(self) -> Iterator[str]: """:yield: all user and site configuration directories.""" yield self.user_config_dir yield self.site_config_dir
def iter_data_dirs(self) -> Iterator[str]: """:yield: all user and site data directories.""" yield self.user_data_dir yield self.site_data_dir
def iter_cache_dirs(self) -> Iterator[str]: """:yield: all user and site cache directories.""" yield self.user_cache_dir yield self.site_cache_dir
def iter_runtime_dirs(self) -> Iterator[str]: """:yield: all user and site runtime directories.""" yield self.user_runtime_dir yield self.site_runtime_dir
def iter_config_paths(self) -> Iterator[Path]: """:yield: all user and site configuration paths.""" for path in self.iter_config_dirs(): yield Path(path)
def iter_data_paths(self) -> Iterator[Path]: """:yield: all user and site data paths.""" for path in self.iter_data_dirs(): yield Path(path)
def iter_cache_paths(self) -> Iterator[Path]: """:yield: all user and site cache paths.""" for path in self.iter_cache_dirs(): yield Path(path)
def iter_runtime_paths(self) -> Iterator[Path]: """:yield: all user and site runtime paths.""" for path in self.iter_runtime_dirs(): yield Path(path)
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung ist noch experimentell.