26 lines
685 B
Python
26 lines
685 B
Python
|
import yaml
|
||
|
|
||
|
from config import Config
|
||
|
from renderer import Renderer
|
||
|
from structure import Structure
|
||
|
|
||
|
class InstructionSetSchema:
|
||
|
def __init__(self, path: str) -> None:
|
||
|
self.config = Config()
|
||
|
self.path = path
|
||
|
self.load()
|
||
|
|
||
|
def load(self) -> None:
|
||
|
with open(self.path, "r") as f:
|
||
|
schema = yaml.safe_load(f)
|
||
|
|
||
|
self.structures = {}
|
||
|
|
||
|
for id_, data in schema["structures"].items():
|
||
|
id_ = str(id_)
|
||
|
self.structures[id_] = Structure.load(id_, data)
|
||
|
|
||
|
def save(self, path: str) -> None:
|
||
|
renderer = Renderer(self.config)
|
||
|
renderer.render(self)
|
||
|
renderer.save(path)
|