From 4d07a188a1ea8bc61d509623a5b592c8cd2fe4a9 Mon Sep 17 00:00:00 2001 From: Chris Wild Date: Wed, 27 Jul 2016 22:01:09 +0100 Subject: [PATCH] config parsing clean-ups (#1240) --- pokecli.py | 23 ++++++----------------- 1 file changed, 6 insertions(+), 17 deletions(-) diff --git a/pokecli.py b/pokecli.py index 8af664b807..008b01719b 100755 --- a/pokecli.py +++ b/pokecli.py @@ -185,24 +185,13 @@ def init_config(): config.password = getpass("Password: ") # Passed in arguments should trump - for key in config.__dict__: - if key in load and load[key]: - config.__dict__[key] = load[key] + for key, value in load.iteritems(): + if key in config and value: + setattr(config, key, value) - if 'catch' in load: - config.catch = load['catch'] - else: - config.catch = {} - - if 'release' in load: - config.release = load['release'] - else: - config.release = {} - - if 'item_filter' in load: - config.item_filter = load['item_filter'] - else: - config.item_filter = {} + config.catch = load.get('catch', {}) + config.release = load.get('release', {}) + config.item_filter = load.get('item_filter', {}) if config.auth_service not in ['ptc', 'google']: logging.error("Invalid Auth service specified! ('ptc' or 'google')")