ActiveState / appdirs

A small Python module for determining appropriate platform-specific dirs, e.g. a "user data dir".
http://pypi.python.org/pypi/appdirs
MIT License
1.05k stars 98 forks source link

pathlib support #120

Open LucidOne opened 5 years ago

LucidOne commented 5 years ago

Any thoughts on pathlib support?

pmiddend commented 5 years ago

I'd appreciate that, too.

McSinyx commented 5 years ago

@pmiddend #123 is working on it, but there's a design issue.

keturn commented 4 years ago

Hmm. Path does not implement str, so having functions that return different types in different environments (as #123 does) would be real rough on compatibility and type checking (e.g. #75).

My inclination would be to add a new parallel interface. So for anyone doing from appdirs import import AppDirs it'll keep working like it always has, and people who want Paths can do from appdirs.paths import AppPaths or somesuch.

The stinker is, when writing code to provide both Path and string version of things, it's usually easier and safer to start with the Path version and then convert to string when necessary, instead of doing most of the path building old string-manipulation style. But this library is quite careful about always using the os.path functions and the inputs are going to be hard-coded values from the application instead of scary user input, so it's probably fine to build strings and convert.

[…keturn does some experiments…]

Wait, what?

pathlib.Path does not throw InsecurePath if you do something like user_state_dir().joinpath('saves', '/etc/passwd')?

HECK okay fine forget anything I said about "safety." Carry on!

McSinyx commented 3 years ago

I made a fork embracing pathlib called loca. Cc @clbarnes and @untzag.