From a82002e6c1928d5fd37a574c024d29ad421b5f96 Mon Sep 17 00:00:00 2001 From: Carl Suster Date: Sat, 1 Jun 2019 09:51:56 +1000 Subject: [PATCH] confit: replace with confuse in core beets --- beets/__init__.py | 8 ++++---- beets/plugins.py | 2 +- beets/ui/__init__.py | 7 ++++--- beets/ui/commands.py | 2 +- docs/dev/plugins.rst | 4 ++-- 5 files changed, 12 insertions(+), 11 deletions(-) diff --git a/beets/__init__.py b/beets/__init__.py index a43148ae3..20075073c 100644 --- a/beets/__init__.py +++ b/beets/__init__.py @@ -17,14 +17,14 @@ from __future__ import division, absolute_import, print_function import os -from beets.util import confit +import confuse __version__ = u'1.5.0' __author__ = u'Adrian Sampson ' -class IncludeLazyConfig(confit.LazyConfig): - """A version of Confit's LazyConfig that also merges in data from +class IncludeLazyConfig(confuse.LazyConfig): + """A version of Confuse's LazyConfig that also merges in data from YAML files specified in an `include` setting. """ def read(self, user=True, defaults=True): @@ -35,7 +35,7 @@ class IncludeLazyConfig(confit.LazyConfig): filename = view.as_filename() if os.path.isfile(filename): self.set_file(filename) - except confit.NotFoundError: + except confuse.NotFoundError: pass diff --git a/beets/plugins.py b/beets/plugins.py index edc6d8fe8..7c98225ca 100644 --- a/beets/plugins.py +++ b/beets/plugins.py @@ -526,7 +526,7 @@ def sanitize_choices(choices, choices_all): def sanitize_pairs(pairs, pairs_all): """Clean up a single-element mapping configuration attribute as returned - by `confit`'s `Pairs` template: keep only two-element tuples present in + by Confuse's `Pairs` template: keep only two-element tuples present in pairs_all, remove duplicate elements, expand ('str', '*') and ('*', '*') wildcards while keeping the original order. Note that ('*', '*') and ('*', 'whatever') have the same effect. diff --git a/beets/ui/__init__.py b/beets/ui/__init__.py index 5b8f9680a..a88ed9aef 100644 --- a/beets/ui/__init__.py +++ b/beets/ui/__init__.py @@ -38,10 +38,11 @@ from beets import plugins from beets import util from beets.util.functemplate import template from beets import config -from beets.util import confit, as_string +from beets.util import as_string from beets.autotag import mb from beets.dbcore import query as db_query from beets.dbcore import db +import confuse import six # On Windows platforms, use colorama to support "ANSI" terminal colors. @@ -621,7 +622,7 @@ def get_path_formats(subview=None): def get_replacements(): - """Confit validation function that reads regex/string pairs. + """Confuse validation function that reads regex/string pairs. """ replacements = [] for pattern, repl in config['replace'].get(dict).items(): @@ -1277,7 +1278,7 @@ def main(args=None): log.debug('{}', traceback.format_exc()) log.error('{}', exc) sys.exit(1) - except confit.ConfigError as exc: + except confuse.ConfigError as exc: log.error(u'configuration error: {0}', exc) sys.exit(1) except db_query.InvalidQueryError as exc: diff --git a/beets/ui/commands.py b/beets/ui/commands.py index c89dbb6db..3f540a1fa 100755 --- a/beets/ui/commands.py +++ b/beets/ui/commands.py @@ -39,7 +39,7 @@ from beets.util import syspath, normpath, ancestry, displayable_path, \ from beets import library from beets import config from beets import logging -from beets.util.confit import _package_path +from confuse import _package_path import six from . import _store_dict diff --git a/docs/dev/plugins.rst b/docs/dev/plugins.rst index 7cec77d62..7ff397bc6 100644 --- a/docs/dev/plugins.rst +++ b/docs/dev/plugins.rst @@ -298,10 +298,10 @@ this in their ``config.yaml``:: foo: bar To access this value, say ``self.config['foo'].get()`` at any point in your -plugin's code. The `self.config` object is a *view* as defined by the `Confit`_ +plugin's code. The `self.config` object is a *view* as defined by the `Confuse`_ library. -.. _Confit: http://confit.readthedocs.org/ +.. _Confuse: http://confuse.readthedocs.org/ If you want to access configuration values *outside* of your plugin's section, import the `config` object from the `beets` module. That is, just put ``from