mirror of
https://github.com/beetbox/beets.git
synced 2025-12-24 17:43:52 +01:00
Config: implement redacted fields more idiomatic
- `add_redacted_fields(self, *field_names)` to use argument unpacking - foo =| bar instead of foo = foo | bar
This commit is contained in:
parent
f4ed3e16b1
commit
944d38064d
4 changed files with 8 additions and 12 deletions
|
|
@ -405,11 +405,8 @@ class RootView(ConfigView):
|
|||
def root(self):
|
||||
return self
|
||||
|
||||
def add_redacted_fields(self, field_names):
|
||||
if not isinstance(field_names, list):
|
||||
field_names = [field_names]
|
||||
|
||||
self.redacted_fields = self.redacted_fields | set(field_names)
|
||||
def add_redacted_fields(self, *field_names):
|
||||
self.redacted_fields |= set(field_names)
|
||||
|
||||
|
||||
class Subview(ConfigView):
|
||||
|
|
@ -462,8 +459,8 @@ class Subview(ConfigView):
|
|||
def root(self):
|
||||
return self.parent.root()
|
||||
|
||||
def add_redacted_fields(self, field_names):
|
||||
self.parent.add_redacted_fields(field_names)
|
||||
def add_redacted_fields(self, *field_names):
|
||||
self.parent.add_redacted_fields(*field_names)
|
||||
|
||||
|
||||
# Config file paths, including platform-specific paths and in-package
|
||||
|
|
@ -821,8 +818,7 @@ class Configuration(RootView):
|
|||
out_dict = RootView(sources).flatten()
|
||||
|
||||
if redact_fields:
|
||||
Dumper.redacted_fields = Dumper.redacted_fields | \
|
||||
self.redacted_fields
|
||||
Dumper.redacted_fields |= self.redacted_fields
|
||||
else:
|
||||
Dumper.redacted_fields = set()
|
||||
|
||||
|
|
|
|||
|
|
@ -56,7 +56,7 @@ class DiscogsPlugin(BeetsPlugin):
|
|||
'tokenfile': 'discogs_token.json',
|
||||
'source_weight': 0.5,
|
||||
})
|
||||
self.config.add_redacted_fields(['apikey', 'apisecret'])
|
||||
self.config.add_redacted_fields('apikey', 'apisecret')
|
||||
self.discogs_client = None
|
||||
self.register_listener('import_begin', self.setup)
|
||||
|
||||
|
|
|
|||
|
|
@ -135,7 +135,7 @@ class EchonestMetadataPlugin(plugins.BeetsPlugin):
|
|||
'truncate': True,
|
||||
})
|
||||
self.config.add(ATTRIBUTES)
|
||||
self.config.add_redacted_fields(['apikey'])
|
||||
self.config.add_redacted_fields('apikey')
|
||||
|
||||
pyechonest.config.ECHO_NEST_API_KEY = \
|
||||
self.config['apikey'].get(unicode)
|
||||
|
|
|
|||
|
|
@ -463,7 +463,7 @@ class LyricsPlugin(plugins.BeetsPlugin):
|
|||
'force': False,
|
||||
'sources': self.SOURCES,
|
||||
})
|
||||
self.config.add_redacted_fields(['google_API_key', 'google_engine_ID'])
|
||||
self.config.add_redacted_fields('google_API_key', 'google_engine_ID')
|
||||
|
||||
available_sources = list(self.SOURCES)
|
||||
if not self.config['google_API_key'].get() and \
|
||||
|
|
|
|||
Loading…
Reference in a new issue