def load_config(self):
import yaml
from yaml.scanner import ScannerError
try:
with open(self.args.config_file) as config_file:
configs = yaml.load(config_file.read())
except IOError:
raise BadConfig('No config file %s found!' % self.args.config_file)
except ScannerError:
raise BadConfig('Bad config file syntax')
else:
try:
self._dict = configs[self.args.config]
except KeyError:
raise BadConfig('No config named %s found!' % self.args.config)
评论列表
文章目录