mirror of
https://github.com/beetbox/beets.git
synced 2025-12-26 10:34:09 +01:00
confit: replace with confuse in core beets
This commit is contained in:
parent
f1c9b11635
commit
a82002e6c1
5 changed files with 12 additions and 11 deletions
|
|
@ -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 <adrian@radbox.org>'
|
||||
|
||||
|
||||
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
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -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.
|
||||
|
|
|
|||
|
|
@ -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:
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Reference in a new issue