[prev in list] [next in list] [prev in thread] [next in thread] 

List:       python-ideas
Subject:    [Python-ideas] Applications user/system directories functions
From:       JGoutin  via Python-ideas <python-ideas () python ! org>
Date:       2021-12-14 20:40:51
Message-ID: 163951445192.5815.16137765516629438270 () mail ! python ! org
[Download RAW message or body]

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.
_______________________________________________
Python-ideas mailing list -- python-ideas@python.org
To unsubscribe send an email to python-ideas-leave@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/


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic