""" Insel export models to insel format SPDX - License - Identifier: LGPL - 3.0 - or -later Copyright © 2022 Concordia CERC group Project Coder Pilar Monsalvete Alvarez de Uribarri pilar.monsalvete@concordia.ca """ from abc import ABC import os from pathlib import Path class Insel(ABC): def __init__(self, city, path, keep_files=False): self._city = city self._path = path self._results = None self._keep_files = keep_files @staticmethod def _add_block(file, block_number, block_type, inputs='', parameters=''): file += "S " + str(block_number) + " " + block_type + "\n" for block_input in inputs: file += str(block_input) + "\n" if len(parameters) > 0: file += "P " + str(block_number) + "\n" for block_parameter in parameters: file += str(block_parameter) + "\n" return file def run(self, insel_models): for insel_model in insel_models: finish = os.system('insel ' + str(Path(insel_model).resolve())) os.close(finish) if not self._keep_files: os.remove((Path(self._path) / insel_model).resolve()) def results(self, insel_models): raise NotImplementedError def _export(self): raise NotImplementedError