From 3b8cf46403e0a827a2a4b3f81b654323c821f5b1 Mon Sep 17 00:00:00 2001 From: "W. Trevor King" Date: Fri, 26 Oct 2012 08:00:31 -0400 Subject: storage:util:config: path() now defaults to ~/.config/bugs-everywhere Add a documentation section discussing the config file, respect XDG_CONFIG_HOME, and add BE_CONFIG_PATH. --- libbe/storage/util/config.py | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) (limited to 'libbe/storage/util') diff --git a/libbe/storage/util/config.py b/libbe/storage/util/config.py index 771767f..7f1e33c 100644 --- a/libbe/storage/util/config.py +++ b/libbe/storage/util/config.py @@ -23,6 +23,7 @@ import ConfigParser import codecs +import os import os.path import libbe @@ -40,9 +41,19 @@ Initialized with :func:`libbe.util.encoding.get_text_file_encoding`. def path(): """Return the path to the per-user config file. - Defaults to :file:`~/.bugs_everywhere`. + Defaults to :file:`~/.config/bugs-everywhere`, but you can + override the directory with ``XDG_CONFIG_HOME`` from the `XDG Base + Directory Specification`_. You can also override the entire path + by setting the ``BE_CONFIG_PATH`` environment variable. + + .. _XDG Base Directory Specification: + http://standards.freedesktop.org/basedir-spec/basedir-spec-latest.html """ - return os.path.expanduser(os.path.join('~','.bugs_everywhere')) + default_dir = os.path.join('~', '.config') + dirname = os.path.expanduser( + os.environ.get('XDG_CONFIG_HOME', default_dir)) + default = os.path.join(dirname, 'bugs-everywhere') + return os.path.expanduser(os.environ.get('BE_CONFIG_PATH', default)) def set_val(name, value, section="DEFAULT", encoding=None): """Set a value in the per-user config file. -- cgit