Add a conditional around the config file parsing attempt

This commit is contained in:
Scott Wallace 2021-05-27 08:04:55 +01:00
parent b6fa8e6632
commit 9f86ea1f30
Signed by: scott
GPG key ID: AA742FDC5AFE2A72

View file

@ -30,13 +30,14 @@ class Config:
logging.debug('Parsing config') logging.debug('Parsing config')
parsed = {} parsed = {}
try: if configfile is not None:
with open(configfile, 'r') as file: try:
parsed = yaml.safe_load(file.read()) with open(configfile, 'r') as file:
except FileNotFoundError as error: parsed = yaml.safe_load(file.read())
logging.warning('No config file found (%s)', error.filename) except FileNotFoundError as error:
except TypeError: logging.warning('No config file found (%s)', error.filename)
logging.warning('No config file provided.') except TypeError:
logging.warning('No config file provided.')
# Iterate over the config defaults and check for environment variable # Iterate over the config defaults and check for environment variable
# overrides, then check for any items in the config, otherwise # overrides, then check for any items in the config, otherwise