diff --git a/src/simapy/sima_writer.py b/src/simapy/sima_writer.py index 577da2b8..b1d77266 100644 --- a/src/simapy/sima_writer.py +++ b/src/simapy/sima_writer.py @@ -15,12 +15,12 @@ class SIMAWriter(): """ Export entites as SIMA objects""" - def write(self, models: Sequence[MOAO], filename: str, indent=0): + def write(self, models: Sequence[MOAO] | MOAO, filename: str, indent=0): """Write SIMA models to file""" content = self.__to_model_content(models) DMTWriter().write(content, filename, indent=indent) - def __to_model_content(self, models: Sequence[Entity]) -> ModelContent: + def __to_model_content(self, models: Sequence[Entity] | Entity) -> ModelContent: content = ModelContent() header = Header() @@ -28,7 +28,10 @@ def __to_model_content(self, models: Sequence[Entity]) -> ModelContent: header.packages.append(PackageInfo(name=name,version=version)) content.header = header - content.contents.extend(models) + if isinstance(models, Entity): + content.contents.append(models) + else: + content.contents.extend(models) return content def to_dict(self, models: Sequence[MOAO]) -> Dict: