> On 15 Dec 2021, at 13:45, JGoutin via Python-ideas <python-ideas@python.org> 
> wrote:
> 
> Hello,
> 
> The idea is to add 3 functions to get "config", "data" and "cache" 
> directories that are commonly used to store application files in user home / 
> system.
> 
> This look very straightforward to get theses directories path, but in 
> practices it depends on many factors like OS, environnement variables, user 
> or system dir.
> 
> For instance, with the "config" directory:
> * Linux, user: os.path.join(os.getenv("XDG_CONFIG_HOME", 
> os.path.expanduser("~/.config")), app_name)
> * Linux, system: os.path.join("/etc", app_name)
> * Windows, user: os.path.join(os.path.expandvars("%APPDATA%"), app_name)
> * Windows, system: os.path.join(os.path.expandvars("%CSIDL_COMMON_APPDATA%"), 
> app_name)
> 
> For linux, the full spec is here: 
> https://specifications.freedesktop.org/basedir-spec/basedir-spec-latest.html
> 
> I see many applications that just use "~/.app_name" to not have to handle 
> theses cases.
> 
> 
> The functions prototypes may look like and may be added to "shutil" (or 
> "os.path" ?):
> 
> def getcachedir(app_name: str=None, system: bool=False):
> 
> With
> * app_name: The application name
> * system: If the required directory is the systemd directory or user 
> direcotry.
> 
> 
> This may also be implemented as an external library, but I am not sure I 
> would like add add a dependency to my projects "just for this".
> 
> 
> I can implement this if people are interested with this feature.

I wrote this https://pypi.org/project/config-path/ to solve the problem for 
macOs, windows and unix.

There are subtle points to consider on each platform.

Barry



> _______________________________________________
> Python-ideas mailing list -- python-ideas@python.org
> To unsubscribe send an email to python-ideas-le...@python.org
> https://mail.python.org/mailman3/lists/python-ideas.python.org/
> Message archived at 
> https://mail.python.org/archives/list/python-ideas@python.org/message/MHEWO4U6SBDU7OU3JH4A62EWCANDM7I2/
> Code of Conduct: http://python.org/psf/codeofconduct/
> 
_______________________________________________
Python-ideas mailing list -- python-ideas@python.org
To unsubscribe send an email to python-ideas-le...@python.org
https://mail.python.org/mailman3/lists/python-ideas.python.org/
Message archived at 
https://mail.python.org/archives/list/python-ideas@python.org/message/LZP4ISNMJETVHCVMOTQR4YKBRY3RODEU/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to