aboutsummaryrefslogtreecommitdiffstats
path: root/libbe/storage
diff options
context:
space:
mode:
authorW. Trevor King <wking@tremily.us>2012-10-26 08:00:31 -0400
committerW. Trevor King <wking@tremily.us>2012-10-26 08:16:33 -0400
commit3b8cf46403e0a827a2a4b3f81b654323c821f5b1 (patch)
treee7c2880b8b51f1e55b999cda666d00f158694a19 /libbe/storage
parent1c5079bdbb762a98bb7cf2efda14d8a74ac65fb4 (diff)
downloadbugseverywhere-3b8cf46403e0a827a2a4b3f81b654323c821f5b1.tar.gz
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.
Diffstat (limited to 'libbe/storage')
-rw-r--r--libbe/storage/util/config.py15
1 files changed, 13 insertions, 2 deletions
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.