/ skill2yaml.py
skill2yaml.py
 1  #!/usr/bin/env python3
 2  """Convert all the SKILL files to yaml files"""
 3  # SPDX-License-Identifier: AGPL-3.0-or-later OR GPL-2.0-or-later OR CERN-OHL-S-2.0+ OR Apache-2.0
 4  import yaml
 5  
 6  from files import techfiles, assurafiles, ilfiles, displayfiles
 7  from pdkmaster.io.parsing import SkillFile, TechFile, AssuraFile, DisplayFile
 8  
 9  # techfiles
10  for techfile, yamlfile in techfiles:
11      print("Converting -> "+yamlfile)
12      with open(techfile, "r", encoding="latin1") as f:
13          text = f.read()
14  
15      tf = TechFile.parse_string(text)
16  
17      with open("tf_yaml/"+yamlfile, "w") as f:
18          yaml.dump(tf.value, f, sort_keys=False)
19  
20  # assurafiles
21  for assurafile, yamlfile in assurafiles:
22      print("Converting -> "+yamlfile)
23      with open(assurafile, "r", encoding="latin1") as f:
24          text = f.read()
25  
26      assf = AssuraFile.parse_string(text)
27  
28      with open("assura_yaml/"+yamlfile, "w") as f:
29          yaml.dump(assf.value, f, sort_keys=False)
30  
31  # displayfiles
32  for displayfile, yamlfile in displayfiles:
33      print("Converting -> "+yamlfile)
34      with open(displayfile, "r", encoding="latin1") as f:
35          text = f.read()
36  
37      dispf = DisplayFile.parse_string(text)
38  
39      with open("display_yaml/"+yamlfile, "w") as f:
40          yaml.dump(dispf.value, f, sort_keys=False)
41  
42  # TODO ilfiles