BEETSCONFIG environment variable (#148)

This commit is contained in:
Adrian Sampson 2011-03-29 21:03:27 -07:00
parent 9ae27b0a05
commit eace62a0f4
2 changed files with 9 additions and 3 deletions

2
NEWS
View file

@ -30,6 +30,8 @@
* Resuming is automatically disabled when the importer is in quiet (-q)
mode. Progress is still saved, however, and the -q flag (above) can
be used to force resuming.
* The BEETSCONFIG environment variable can now be used to specify the
location of the config file that is at ~/.beetsconfig by default.
* Fix a bug where some files would be erroneously interpreted as MP4.
* Fix permission bits applied to album art files.
* Fix malformed MusicBrainz queries caused by null characters.

View file

@ -30,7 +30,8 @@ from beets import library
from beets import plugins
# Constants.
CONFIG_FILE = os.path.expanduser('~/.beetsconfig')
CONFIG_PATH_VAR = 'BEETSCONFIG'
DEFAULT_CONFIG_FILE = os.path.expanduser('~/.beetsconfig')
STATE_FILE = os.path.expanduser('~/.beetsstate')
DEFAULT_LIBRARY = '~/.beetsmusic.blb'
DEFAULT_DIRECTORY = '~/Music'
@ -405,9 +406,12 @@ def main(args=None, configfh=None):
# Read defaults from config file.
config = ConfigParser.SafeConfigParser()
if configfh:
config.readfp(configfh)
pass
elif CONFIG_PATH_VAR in os.environ:
configfh = open(os.path.expanduser(os.environ[CONFIG_PATH_VAR]))
else:
config.read(CONFIG_FILE)
configfh = open(DEFAULT_CONFIG_FILE)
config.readfp(configfh)
# Add plugin paths.
plugpaths = config_val(config, 'beets', 'pluginpath', '')