Minor code cleanup.
Preset config values when reading config file. This is to ease introducing new options (like the next commit will do).
This commit is contained in:
@ -69,14 +69,14 @@ def save_config(config, config_file, toot_old_posts=False):
|
|||||||
fh.write(yaml.dump(copy, default_flow_style=False))
|
fh.write(yaml.dump(copy, default_flow_style=False))
|
||||||
|
|
||||||
def read_config(config_file):
|
def read_config(config_file):
|
||||||
config = {}
|
config = {
|
||||||
|
'updated': datetime(MINYEAR, 1, 1, 0, 0, 0, 0, timezone.utc),
|
||||||
|
}
|
||||||
with open(config_file) as fh:
|
with open(config_file) as fh:
|
||||||
config = yaml.load(fh, yaml.SafeLoader)
|
cfg = yaml.load(fh, yaml.SafeLoader)
|
||||||
if 'updated' in config:
|
if 'updated' in cfg:
|
||||||
config['updated'] = dateutil.parser.parse(config['updated'])
|
cfg['updated'] = dateutil.parser.parse(cfg['updated'])
|
||||||
else:
|
config.update(cfg)
|
||||||
config['updated'] = datetime(MINYEAR, 1, 1,
|
|
||||||
0, 0, 0, 0, timezone.utc)
|
|
||||||
return config
|
return config
|
||||||
|
|
||||||
def detect_generator(feed):
|
def detect_generator(feed):
|
||||||
|
|||||||
Reference in New Issue
Block a user