diff options
| author | Dario Nieuwenhuis <[email protected]> | 2021-06-12 20:20:09 +0200 |
|---|---|---|
| committer | GitHub <[email protected]> | 2021-06-12 20:20:09 +0200 |
| commit | 85f172dd93227e637724d37e76bbcd7d886678f9 (patch) | |
| tree | 2043a222409efb13c37460c8b313c685754ec7da | |
| parent | 97e2f1066527975c7e7f79b2f112317c20396da0 (diff) | |
| parent | 9edb6e41ce3ad6ca3c280d71a065f325eae30db9 (diff) | |
Merge pull request #244 from Tiwalun/fix-gen-macos
Make gen.py work without CSafeLoader
| -rw-r--r-- | embassy-stm32/gen.py | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/embassy-stm32/gen.py b/embassy-stm32/gen.py index 2736cd69d..779389cac 100644 --- a/embassy-stm32/gen.py +++ b/embassy-stm32/gen.py | |||
| @@ -4,6 +4,12 @@ import re | |||
| 4 | import os | 4 | import os |
| 5 | import re | 5 | import re |
| 6 | 6 | ||
| 7 | try: | ||
| 8 | from yaml import CSafeLoader as SafeLoader | ||
| 9 | except ImportError: | ||
| 10 | from yaml import SafeLoader | ||
| 11 | |||
| 12 | |||
| 7 | abspath = os.path.abspath(__file__) | 13 | abspath = os.path.abspath(__file__) |
| 8 | dname = os.path.dirname(abspath) | 14 | dname = os.path.dirname(abspath) |
| 9 | os.chdir(dname) | 15 | os.chdir(dname) |
| @@ -18,11 +24,11 @@ except: | |||
| 18 | # ======= load chip | 24 | # ======= load chip |
| 19 | chip_name = chip_name.upper() | 25 | chip_name = chip_name.upper() |
| 20 | with open(f'{data_path}/chips/{chip_name}.yaml', 'r') as f: | 26 | with open(f'{data_path}/chips/{chip_name}.yaml', 'r') as f: |
| 21 | chip = yaml.load(f, Loader=yaml.CSafeLoader) | 27 | chip = yaml.load(f, Loader=SafeLoader) |
| 22 | 28 | ||
| 23 | # ======= load GPIO AF | 29 | # ======= load GPIO AF |
| 24 | with open(f'{data_path}/gpio_af/{chip["gpio_af"]}.yaml', 'r') as f: | 30 | with open(f'{data_path}/gpio_af/{chip["gpio_af"]}.yaml', 'r') as f: |
| 25 | af = yaml.load(f, Loader=yaml.CSafeLoader) | 31 | af = yaml.load(f, Loader=SafeLoader) |
| 26 | 32 | ||
| 27 | # ======= Generate! | 33 | # ======= Generate! |
| 28 | with open(output_file, 'w') as f: | 34 | with open(output_file, 'w') as f: |
