How does this compare to the existing appdirs module on PyPI?
On Mon, 30 Sep 2019 at 13:15, Barry Scott <ba...@barrys-emacs.org> wrote: > > See https://pypi.org/project/config-path/ for documentation. > > Install using pip: > > python -m pip install config-path > > I write tools that run on macOS, Unix and Windows systems. > Each operating system has its own conventions on where config > files should be stored. Following the conventions is not always > straight forward. > > After a question raised here on Python users about config file locations > I was inspired to write this module to help with that problem. > > config_path library works out which path to use for configuration folders > and files in an operating system independent way. > > Each operating system has particular conventions for where an application > is expected to stores it configuration. The information provided to ConfigPath > is used to figure out an appropriate file path or folder path for the > application's > configuration data. > > Supports Windows, macOS and most unix systems using the 'XDG Base Directory > Specification'. > > Example for the "widget" app from "example.com" that uses JSON for its config: > > from config_path import ConfigPath > conf_path = ConfigPath( 'example.com', 'widget', '.json' ) > > path = conf_path.saveFilePath( mkdir=True ) > with path.open() as f: > f.write( config_data ) > > And to read the config: > > path = conf_path.readFilePath() > if path is not None: > # path exists and config can be read > with path.open() as f: > config = json.loads( f ) > else: > config = default_config > > Barry > > > -- > https://mail.python.org/mailman/listinfo/python-list -- https://mail.python.org/mailman/listinfo/python-list