DSD-DBS / py-capellambse

A Python 3 headless implementation of the Capella modeling tool.
https://dsd-dbs.github.io/py-capellambse/
Apache License 2.0
52 stars 9 forks source link

More useful `__repr__`s for reqif #219

Closed ewuerger closed 1 month ago

ewuerger commented 1 year ago

While working on synthesis of commit statements I stumpled upon the representation of reqif.AttributeValues. For example:

>>> f"{attr!r}"
EnumerationValueAttribute 37a8a7bb-2f01-466f-ae42-09b7fcedf812

is missing a key information (its .value or .values). I propose that this __repr__ is extended by this kind of information. reqif.EnumValues for example incorporate its (only) information already (because its their long_name):

>>> f"{ev!r}"
EnumValue applicable
Wuestengecko commented 1 year ago

Please provide a minimal, reproducible example. I tried the following, and it looks very different from what you describe:

============================== Model exploration ===============================
`model` is '5_0' from tests/data/melodymodel/5_0/Melody Model Test.aird

>>> attr = model.search("EnumerationValueAttribute")[0]
>>> print(repr(attr))
<EnumerationValueAttribute 'MultiEnum' (148bdf2f-6dc2-4a83-833b-596886ce5b07)>
Wuestengecko commented 1 month ago

I supposed we can close this now. The repr() in reqif has evolved even more, and if you have further ideas for improvement, just open a new issue.