diff --git a/beets/ui/__init__.py b/beets/ui/__init__.py index 9c0279d79..15a244aa8 100644 --- a/beets/ui/__init__.py +++ b/beets/ui/__init__.py @@ -405,9 +405,9 @@ def get_replacements(): """Confit validation function that reads regex/string pairs. """ replacements = [] - for pattern, view in config['replace'].items(): + for pattern, repl in config['replace'].get(dict).items(): try: - replacements.append((re.compile(pattern), view.get(unicode))) + replacements.append((re.compile(pattern), repl)) except re.error: raise UserError( u'malformed regular expression in replace: {0}'.format( diff --git a/beets/util/confit.py b/beets/util/confit.py index 1ab06b980..e3425404c 100644 --- a/beets/util/confit.py +++ b/beets/util/confit.py @@ -195,14 +195,16 @@ class ConfigView(object): # Dictionary emulation methods. def keys(self): - """Returns an iterable containing all the keys available as - subviews of the current views. This enumerates all the keys in - *all* dictionaries matching the current view, in contrast to - ``dict(view).keys()``, which gets all the keys for the *first* - dict matching the view. If the object for this view in any - source is not a dict, then a ConfigTypeError is raised. + """Returns a list containing all the keys available as subviews + of the current views. This enumerates all the keys in *all* + dictionaries matching the current view, in contrast to + ``view.get(dict).keys()``, which gets all the keys for the + *first* dict matching the view. If the object for this view in + any source is not a dict, then a ConfigTypeError is raised. The + keys are ordered according to how they appear in each source. """ - keys = set() + keys = [] + for dic in self.get_all(): try: cur_keys = dic.keys() @@ -212,7 +214,11 @@ class ConfigView(object): self.name, type(dic).__name__ ) ) - keys.update(cur_keys) + + for key in cur_keys: + if key not in keys: + keys.append(key) + return keys def items(self):