Add setters for archetypes and constructions catalogues

This commit is contained in:
Alireza Adli 2024-07-17 10:31:33 -04:00
parent d41ce5371e
commit 6854b35647

View File

@ -14,26 +14,31 @@ class AccessNrcanCatalog:
""" """
AccessNrcanCatalog class AccessNrcanCatalog class
""" """
def __init__(self, path): def __init__(
self, path,
archetypes='nrcan_archetypes.json',
constructions='nrcan_constructions.json'):
self._path = Path(path) self._path = Path(path)
self._archetypes = self._load_archetypes() self.archetypes = archetypes
self._constructions = self._load_constructions() self.constructions = constructions
@property @property
def archetypes(self): def archetypes(self):
return self._archetypes return self._archetypes
@archetypes.setter
def archetypes(self, archetypes):
archetypes_path = (self._path / archetypes).resolve()
self._archetypes = json.loads(archetypes_path.read_text())
@property @property
def constructions(self): def constructions(self):
return self._constructions return self._constructions
def _load_archetypes(self): @constructions.setter
archetypes_path = (self._path / 'nrcan_archetypes.json').resolve() def constructions(self, constructions):
return json.loads(archetypes_path.read_text()) constructions_path = (self._path / constructions).resolve()
self._constructions = json.loads(constructions_path.read_text())
def _load_constructions(self):
constructions_path = (self._path / 'nrcan_constructions.json').resolve()
return json.loads(constructions_path.read_text())
def layers(self, opaque_surface_code, component_type): def layers(self, opaque_surface_code, component_type):
for opaque_surface in self.constructions['opaque_surfaces']: for opaque_surface in self.constructions['opaque_surfaces']: