From ecb65a5a4aefb42de3d6d233bf00bdeb24b4579d Mon Sep 17 00:00:00 2001 From: Adrian Sampson Date: Thu, 9 Apr 2015 16:55:18 -0700 Subject: [PATCH] Idiomatic configuration defaults (#1398) Paging @jmwatte: `config.add` is the standard way to specify defaults for configuration options. --- beetsplug/replaygain.py | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/beetsplug/replaygain.py b/beetsplug/replaygain.py index 0886ddb1d..d2cd7421f 100644 --- a/beetsplug/replaygain.py +++ b/beetsplug/replaygain.py @@ -93,16 +93,14 @@ class Bs1770gainBackend(Backend): def __init__(self, config, log): super(Bs1770gainBackend, self).__init__(config, log) - cmd = b'bs1770gain' - try: - self.chunk_at = config['chunk_at'].as_number() - except: - self.chunk_at = 5000 - try: - self.method = b'--' + config['method'].get(str) - except: - self.method = b'--replaygain' + config.add({ + 'chunk_at': 5000, + 'method': 'replaygain', + }) + self.chunk_at = config['chunk_at'].as_number() + self.method = b'--' + bytes(config['method'].get(unicode)) + cmd = b'bs1770gain' try: call([cmd, self.method]) self.command = cmd