Crash when enumerating diagrams on a model without diagrams
Wuestengecko opened this issue · comments
Martin Lehmann commented
Trying to enumerate diagrams on a model that does not have any diagrams at all results in the following exception being raised:
>>> model.diagrams
Traceback (most recent call last):
File "<console>", line 1, in <module>
File ".../capellambse/model/diagram.py", line 453, in __get__
descriptors = list(aird.enumerate_diagrams(obj._model._loader))
File ".../capellambse/aird/__init__.py", line 63, in enumerate_diagrams
raise ValueError("Invalid XML: No viewpoints found")
ValueError: Invalid XML: No viewpoints found
This happens because the .aird
file looks quite different if there are no diagrams at all: Instead of the <viewpoint:DAnalysis>
element (which, among others, contains the viewpoint descriptions) being wrapped in a <xmi:XMI>
, it is itself the root element of the XML tree. Once at least one diagram is created, DAnalysis gets siblings, the XMI root element appears, and the error goes away.
(Credit goes to @MoritzWeber0 for finding this issue.)