Hi,
Many thanks for Python4Capella Fabulous addon!!
following the Exporting Values with Python4Capella - #10 by StephaneLacrampe item:
Extracts Requirements Attributes and Values
if req.get_java_object().getOwnedAttributes() != None:
for att in req.get_java_object().getOwnedAttributes():
print("- Attribute: “+att.getDefinition().getReqIFLongName()+”, value: "+str(att.getValue()))
I would like to export an enumeration value attribute like this (rather than a string value attribute):
This API has been improved in the last release. You can now use:
for att in req.get_owned_attributes():
print("- Attribute: “+att.get_definition().getReqIFLongName()+”, value: "+att.get_value())
attr.get_value() will return the value as its primitive type of the Java object corresponding to the EnumerationValueAttribute value. You can then use value.getName()
Your loop could become something like this:
for att in req.get_owned_attributes():
if attr.get_java_object().eClass().getName() == "EnumerationValueAttribute":
print("- Attribute: “+att.get_definition().getReqIFLongName()+”, value: "+att.get_value().getName())
else:
print("- Attribute: “+att.get_definition().getReqIFLongName()+”, value: "+att.get_value())
You can also create new Attribute by passing the type of attribute you want:
Hi,
I try to implement your script but it fails. I can extract StringValueAttribute, Boolean Value Attribute but it fails on a EnumerationValueAttribute (ProgressStatus has 8 values).
This is just an FYI. I was still having issues running Attribute.get_value() for an EnumerationValueAttribute. It looks like the issue you raised was marked as resolved, but I think it might not be quite complete. What I discovered was that the ReqIFElement and EnumValue classes were updated in requirement.py per your recommendations, but the Attribute.get_value() method in my sample_scripts was not updated with the following lines.
Thanks @YvanLussaud! I have limited experience with Github, is something like opening issues limited to people who are involved with the actual development, or is it something I should get familiar with? I’m more than happy to contribute to issue reports as I encounter them rather than bothering you!
You can open new issues on your own via this page. The fisrt step should be to search for an already existing issue. But I prefer to filter out duplicates than miss something. When you open an issue there is a template to guide you through important information, if needed you can also read the github documentation.
And don’t worry that doesn’t bother me. Discussing issues here or on github is important for the good health of Python4Capella.