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
"""
def __init__(self, path):
def __init__(
self, path,
archetypes='nrcan_archetypes.json',
constructions='nrcan_constructions.json'):
self._path = Path(path)
self._archetypes = self._load_archetypes()
self._constructions = self._load_constructions()
self.archetypes = archetypes
self.constructions = constructions
@property
def archetypes(self):
return self._archetypes
@archetypes.setter
def archetypes(self, archetypes):
archetypes_path = (self._path / archetypes).resolve()
self._archetypes = json.loads(archetypes_path.read_text())
@property
def constructions(self):
return self._constructions
def _load_archetypes(self):
archetypes_path = (self._path / 'nrcan_archetypes.json').resolve()
return json.loads(archetypes_path.read_text())
def _load_constructions(self):
constructions_path = (self._path / 'nrcan_constructions.json').resolve()
return json.loads(constructions_path.read_text())
@constructions.setter
def constructions(self, constructions):
constructions_path = (self._path / constructions).resolve()
self._constructions = json.loads(constructions_path.read_text())
def layers(self, opaque_surface_code, component_type):
for opaque_surface in self.constructions['opaque_surfaces']:
@ -56,4 +61,4 @@ class AccessNrcanCatalog:
elif archetype['climate_zone'] != climate_zone:
continue
else:
return archetype['constructions']['OutdoorsWall']['opaque_surface_name']
return archetype['constructions']['OutdoorsWall']['opaque_surface_name']