""" Greenery catalog SPDX - License - Identifier: LGPL - 3.0 - or -later Copyright © 2022 Project Author Guille Gutierrez guillermo.gutierrezmorote@concordia.ca """ from pyecore.resources import ResourceSet, URI from catalogs.greenery.ecore_greenery.greenerycatalog import GreeneryCatalog as gc from catalogs.catalog import Catalog from pathlib import Path class GreeneryCatalog(Catalog): def __init__(self, path): base_path = Path(Path(__file__).parent / 'ecore_greenery' / 'greenerycatalog_no_quantities.ecore') resource_set = ResourceSet() data_model = resource_set.get_resource(URI(str(base_path))) data_model_root = data_model.contents[0] resource_set.metamodel_registry[data_model_root.nsURI] = data_model_root resource = resource_set.get_resource(URI(str(path))) catalog_data: gc = resource.contents[0] self._data = {'vegetation': []} vegetation = [] for vegetation_category in catalog_data.vegetationCategories: vegetation.append({vegetation_category.name: []}) self._data['vegetation'] = vegetation @property def names(self): """ :parm: """ _names = [] for category in self._data: for value in self._data[category]: for key in value.keys(): _names.append(key) return _names