mirror of
https://github.com/beetbox/beets.git
synced 2026-01-03 06:22:48 +01:00
fix ordered dictionary methods on views
This commit is contained in:
parent
55cac36d35
commit
f606827cb9
2 changed files with 16 additions and 10 deletions
|
|
@ -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(
|
||||
|
|
|
|||
|
|
@ -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):
|
||||
|
|
|
|||
Loading…
Reference in a new issue