From 2d45df57f11f7f88f60b7bb5ab631e21ec9fcc1a Mon Sep 17 00:00:00 2001 From: Hartmut Goebel Date: Tue, 16 Apr 2019 13:53:00 +0200 Subject: [PATCH] Minor code cleanup. Preset config values when reading config file. This is to ease introducing new options (like the next commit will do). --- feediverse.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/feediverse.py b/feediverse.py index 72a0a32..47040a8 100755 --- a/feediverse.py +++ b/feediverse.py @@ -69,14 +69,14 @@ def save_config(config, config_file, toot_old_posts=False): fh.write(yaml.dump(copy, default_flow_style=False)) def read_config(config_file): - config = {} + config = { + 'updated': datetime(MINYEAR, 1, 1, 0, 0, 0, 0, timezone.utc), + } with open(config_file) as fh: - config = yaml.load(fh, yaml.SafeLoader) - if 'updated' in config: - config['updated'] = dateutil.parser.parse(config['updated']) - else: - config['updated'] = datetime(MINYEAR, 1, 1, - 0, 0, 0, 0, timezone.utc) + cfg = yaml.load(fh, yaml.SafeLoader) + if 'updated' in cfg: + cfg['updated'] = dateutil.parser.parse(cfg['updated']) + config.update(cfg) return config def detect_generator(feed):