On Wed, Dec 15, 2021 at 7:35 PM Finn Mason <finnjavie...@gmail.com> wrote:

> 4. Should this also be added to pathlib? I say definitely, probably in the
>> form of class constructors (e.g. Path.user_data()).
>>
>
putting it in pathlib makes a lot of sense, but I wouldn't make them a
bunch of Path classmethods -- why thot their own names, but would return
Path objects?

Despite "flat being better than nested" I kind of like a namespace for the
standar paths"

path.lib.standard_paths.user_data

or some such.

As for the names themselves -- prior art -- I think there were two
packages on PyPi with some of this, if they are popular, let's use those
names.

Here's appdirs:

https://github.com/ActiveState/appdirs

pathlib.appdirs.user_data_dir()

done :-)

-CHB

+1 for appdirs.  It's a shame that more projects don't yet use it.
>>>>>
>>>>
>>> I agree -- I've wanted something like that for years in the stdlib.
>>>
>>> wxPython has wx.StandardPaths -- and it's really handy. But a wrapper
>>> around a C++ version, so not useful outside of wx.
>>>
>>> -CHB
>>>
>>>
>>>>
>>>>> On Wednesday, December 15, 2021 at 9:03:07 AM UTC-5 Matt del Valle
>>>>> wrote:
>>>>>
>>>>>> There is appdirs which does precisely what you're looking for:
>>>>>>
>>>>>> https://pypi.org/project/appdirs/
>>>>>>
>>>>>> That said, it does seem to be a core bit of functionality that would
>>>>>> be nice to have in the os and pathlib modules without needing an external
>>>>>> dependency. I'm not going to weigh in on the pros/cons of adding it to 
>>>>>> the
>>>>>> stdlib, I'll leave that to others who I'm sure will have strong opinions 
>>>>>> on
>>>>>> the matter :)
>>>>>>
>>>>>> On Wed, Dec 15, 2021 at 1:47 PM JGoutin via Python-ideas <
>>>>>> python...@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.
>>>>>>> _______________________________________________
>>>>>>> Python-ideas mailing list -- python...@python.org
>>>>>>> To unsubscribe send an email to python-id...@python.org
>>>>>>> https://mail.python.org/mailman3/lists/python-ideas.python.org/
>>>>>>> Message archived at
>>>>>>> https://mail.python.org/archives/list/python...@python.org/message/MHEWO4U6SBDU7OU3JH4A62EWCANDM7I2/
>>>>>>> <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/IV3W2LRZ2KRYERYOYOGYWLI4TO7NXUHI/
>>>>> Code of Conduct: http://python.org/psf/codeofconduct/
>>>>>
>>>>
>>>>
>>>> --
>>>> Christopher Barker, PhD (Chris)
>>>>
>>>> Python Language Consulting
>>>>   - Teaching
>>>>   - Scientific Software Development
>>>>   - Desktop GUI and Web Development
>>>>   - wxPython, numpy, scipy, Cython
>>>>
>>>
>>>
>>> --
>>> Christopher Barker, PhD (Chris)
>>>
>>> Python Language Consulting
>>>   - Teaching
>>>   - Scientific Software Development
>>>   - Desktop GUI and Web Development
>>>   - wxPython, numpy, scipy, Cython
>>> _______________________________________________
>>> 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/PNFWSYYXR5MXVXWOKEV2B26TABVZYL6A/
>>> Code of Conduct: http://python.org/psf/codeofconduct/
>>>
>>

-- 
Christopher Barker, PhD (Chris)

Python Language Consulting
  - Teaching
  - Scientific Software Development
  - Desktop GUI and Web Development
  - wxPython, numpy, scipy, Cython
_______________________________________________
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/K2HTT2SUSQQ7BGCJEDGG3ISC3OCHX6KF/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to