From eda07660427ac40620f6d02ed153268bb6c261c5 Mon Sep 17 00:00:00 2001 From: Thomas Scholtes Date: Wed, 10 Sep 2014 17:56:42 +0200 Subject: [PATCH] Fallback to default path config --- .gitignore | 1 + .travis.yml | 6 ++++-- README.md | 2 +- beetsplug/alternatives.py | 7 ++++++- test/cli_test.py | 1 - 5 files changed, 12 insertions(+), 5 deletions(-) diff --git a/.gitignore b/.gitignore index d8fb904..05fd342 100644 --- a/.gitignore +++ b/.gitignore @@ -6,3 +6,4 @@ build/ coverage/ *.pyc .tox/ +.vimrc diff --git a/.travis.yml b/.travis.yml index 4dd9d6e..9f4675d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -8,8 +8,10 @@ env: # - TOX_ENV=beets-release install: - - "pip install coveralls tox" + - "pip install tox" + - "[ ! -z $COVERAGE ] && pip install coveralls || true" script: "tox -e $TOX_ENV" -after_success: "[ ! -z $COVERAGE ] && coveralls || true" +after_success: + - "[ ! -z $COVERAGE ] && coveralls || true" diff --git a/README.md b/README.md index b268d4f..0f781b8 100644 --- a/README.md +++ b/README.md @@ -125,7 +125,7 @@ line. The values are again dictionaries with the following keys. configuration. * `paths` Path templates for audio files under `directory`. Configured - like [global paths option][config-paths]. + like and defaults to [global paths option][config-paths]. * `query` A [query string][] that determine which tracks belong to the collection. diff --git a/beetsplug/alternatives.py b/beetsplug/alternatives.py index 17bd660..6283abd 100644 --- a/beetsplug/alternatives.py +++ b/beetsplug/alternatives.py @@ -17,6 +17,7 @@ from argparse import ArgumentParser from concurrent import futures +import beets from beets import util from beets.plugins import BeetsPlugin from beets.ui import Subcommand, get_path_formats @@ -79,7 +80,11 @@ class External(object): def __init__(self, name, lib, config): self.lib = lib self.path_key = 'alt.{0}'.format(name) - self.path_formats = get_path_formats(config['paths']) + if config['paths'].exists(): + path_config = config['paths'] + else: + path_config = beets.config['paths'] + self.path_formats = get_path_formats(path_config) self.query, _ = get_query_sort(config['query'].get(unicode), Item) dir = config['directory'].as_filename() diff --git a/test/cli_test.py b/test/cli_test.py index 7b16144..366285c 100644 --- a/test/cli_test.py +++ b/test/cli_test.py @@ -63,7 +63,6 @@ def setUp(self): self.config['alternatives']['external'] = { 'myexternal': { 'directory': external_dir, - 'paths': {'default': '$artist/$title'}, 'query': 'myexternal:true' } }