Skip to content

Commit

Permalink
Support single entity in write
Browse files Browse the repository at this point in the history
  • Loading branch information
lassebje committed Jun 12, 2024
1 parent 59d2874 commit 580c7d2
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/simapy/sima_writer.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,20 +15,23 @@
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()

for name,version in packages.items():
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:
Expand Down

0 comments on commit 580c7d2

Please sign in to comment.