def check_config(path):
if not os.path.exists(path):
logging.warning('Config file %s doesn\'t exist. Trying to create'
% (path))
if create_config(path):
logging.warning('Created new config file %s. Edit it first to '
'configure your settings correctly & then run '
'program again' % (path))
return False
else:
global cfg
try:
with open(path, "r") as config_file:
cfg = yaml.load(config_file)
except IOError as e:
logging.critical('Error while reading config_file %s: %s'
% (path, str(e)))
logging.critical('Check the config file path and try again')
return False
if not cfg or 'filters' not in cfg or not cfg['filters']:
logging.critical('Empty or malformed config_file %s' % (path))
logging.critical('Check the config file path and try again')
return False
return True
评论列表
文章目录