config.py 文件源码

python
阅读 37 收藏 0 点赞 0 评论 0

项目:email-actions 作者: shantanugoel 项目源码 文件源码
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
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号