forked from SiEPIC/openEBL-2024-07-Si-Heaters
-
Notifications
You must be signed in to change notification settings - Fork 1
/
run_yaml_verification.py
46 lines (35 loc) · 1013 Bytes
/
run_yaml_verification.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
import os, sys, yaml
"""
Load YAML file and check that the format is correct
"""
num_errors = 0
print('Checking YAML file:')
# YAML file to run verification on
if len(sys.argv)>1:
yaml_file = sys.argv[1]
else:
# debugging:
import os
yaml_file = os.path.join(os.path.dirname(os.path.realpath(__file__)), 'submissions/Example.yaml')
try:
with open(yaml_file, 'r') as file:
yaml_data = yaml.safe_load(file)
except:
print(' - Error loading layout: %s' % yaml_file)
num_errors += 1
try:
print(' - number of Devices: %s' % len(yaml_data['Devices']))
for r in yaml_data['Devices']:
print(' - Device: %s' % r)
except:
print(" - No 'Devices' found.")
num_errors += 1
try:
print(' - number of Sequences: %s' % len(yaml_data['Sequences']))
for r in yaml_data['Sequences']:
print(' - Sequence: %s' % r)
except:
print(" - No 'Sequence' found.")
num_errors += 1
# Print the result value to standard output
print(num_errors)