mirror of
https://github.com/lrnselfreliance/wrolpi.git
synced 2026-10-26 19:01:39 -04:00
Using slower loader for old configs.
This commit is contained in:
parent
da6e62ee45
commit
b8eaac8ec1
1 changed files with 6 additions and 1 deletions
|
|
@ -537,7 +537,12 @@ class ConfigFile:
|
|||
def read_config_file(self, file: pathlib.Path = None) -> dict:
|
||||
file = file or self.get_file()
|
||||
with file.open('rt') as fh:
|
||||
config_data = yaml.load(fh, Loader=yaml.CSafeLoader)
|
||||
try:
|
||||
config_data = yaml.load(fh, Loader=yaml.CSafeLoader)
|
||||
except yaml.constructor.ConstructorError:
|
||||
logger_.warning(f'Config file contains Python objects, using slow loader: {file}')
|
||||
fh.seek(0)
|
||||
config_data = yaml.load(fh, Loader=yaml.Loader)
|
||||
if not isinstance(config_data, dict):
|
||||
raise InvalidConfig(f'Config file is invalid: {file}')
|
||||
return config_data
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue