XDG folders¶
- logging_strict.util.xdg_folder.__all__: tuple[str, ...] = ("DestFolderSite", "DestFolderUser", "_get_path_config")¶
Module object exports
Get XDG user or site folders.
MacOS, to avoid name possible app naming collisions, requires app author
name. If a package doesn’t specify an app author, e.g. selenium, the
code must specify it using class property, appauthor.
appauthor is normalized for use as a folder name.
If a package doesn’t reveal the author, the appauthor is None.
The (relative) folder path becomes [appname]/None. So coder should
use the class property setter, appauthor, to specify what they’d like
the appauthor to be.
Package platformdirs author unilaterally decided that appauthor
is unnecessary; that name collisions are rare enough to be a detail
better left out.
Contend that decision is not the platformdirs author to make.
If OS platform compatability is important then avoid platformdirs.
Get XDG cache dir for typical package
from logging_strict.util.xdg_folder import DestFolderUser
package = "appdirs" # with author attribution
xdg_user = DestFolderUser(package)
assert isinstance(xdg_user.cache_dir, str)
Get XDG cache dir for package without author attribution
from logging_strict.util.xdg_folder import DestFolderUser
package = "selenium" # lacks author attribution
xdg_user = DestFolderUser(package)
xdg_user.appauthor = "John Doe" # MacOS thanks you
assert isinstance(xdg_user.cache_dir, str)
- class logging_strict.util.xdg_folder.DestFolderSite(appname, author_no_period=True, author_no_space=True, author_no_underscore=True, version=None, multipath=False)¶
XDG Site folders
- Variables:
appname (str) – Package name
author_no_period (str) – Default
True.Trueif should remove period from author name otherwiseFalseauthor_no_space (str) – Default
True.Trueif should remove whitespace from author name otherwiseFalseauthor_no_underscore (str) – Default
True.Trueif should remove underscore from author name otherwiseFalseversion (str | None) – Default
None. Possible to have version specific author information. Can specific versionmultipath (bool | None) – Default
False. Could retrieve all possible folders.Truefor multipath.Falsefor first entry in multipath
- _multipath¶
- class logging_strict.util.xdg_folder.DestFolderUser(appname, author_no_period=True, author_no_space=True, author_no_underscore=True, version=None, roaming=False, opinion=True)¶
XDG User folders
- Variables:
appname (str) – Package name
author_no_period (str) – Default
True.Trueif should remove period from author name otherwiseFalseauthor_no_space (str) – Default
True.Trueif should remove whitespace from author name otherwiseFalseauthor_no_underscore (str) – Default
True.Trueif should remove underscore from author name otherwiseFalseversion (str | None) – Default
None. Possible to have version specific author information. Can specific versionroaming (bool | None) – Default
False. Only applicable to Windowsopinion (bool | None) – Default
True. ??
- _opinion¶
- _roaming¶
- logging_strict.util.xdg_folder._get_path_config(package, author_no_period=True, author_no_space=True, author_no_underscore=True, version=None, roaming=False)¶
Mockable module level function. Gets the user data folder, not the user config folder
- Parameters:
- Returns:
user data folder Path
- Return type: