Make gen.py work without CSafeLoader

This commit is contained in:
Dominik Boehi 2021-06-12 18:28:21 +02:00
parent 97e2f10665
commit 9edb6e41ce

View File

@ -4,6 +4,12 @@ import re
import os import os
import re import re
try:
from yaml import CSafeLoader as SafeLoader
except ImportError:
from yaml import SafeLoader
abspath = os.path.abspath(__file__) abspath = os.path.abspath(__file__)
dname = os.path.dirname(abspath) dname = os.path.dirname(abspath)
os.chdir(dname) os.chdir(dname)
@ -18,11 +24,11 @@ except:
# ======= load chip # ======= load chip
chip_name = chip_name.upper() chip_name = chip_name.upper()
with open(f'{data_path}/chips/{chip_name}.yaml', 'r') as f: with open(f'{data_path}/chips/{chip_name}.yaml', 'r') as f:
chip = yaml.load(f, Loader=yaml.CSafeLoader) chip = yaml.load(f, Loader=SafeLoader)
# ======= load GPIO AF # ======= load GPIO AF
with open(f'{data_path}/gpio_af/{chip["gpio_af"]}.yaml', 'r') as f: with open(f'{data_path}/gpio_af/{chip["gpio_af"]}.yaml', 'r') as f:
af = yaml.load(f, Loader=yaml.CSafeLoader) af = yaml.load(f, Loader=SafeLoader)
# ======= Generate! # ======= Generate!
with open(output_file, 'w') as f: with open(output_file, 'w') as f: