Support conversion from python types to strings in `unparse_attribute_values`
I just stumbled upon this.
Using the package would be simpler if unparse_attribute_values would automatically convert Python data types to strings according to the ReqIF specification.
Might be that I provide a patch for at least some data types in March 2025.
@torsknod-the-caridian thanks for reporting this! I checked the unparse_attribute_values function and could not understand immediately what you are referring to. Could you explain a little more what you would like to be done?
@stanislaw Sure, e.g. https://github.com/strictdoc-project/reqif/blob/44ca50873a5c95857456c04077c55430a61944f3/reqif/parsers/attribute_value_parser.py#L270-L271 has an assert to only allow strings.
It would be great if it would also take bool and automatically convert it to a proper string.
The sample applies to most other datatypes, which are not strings.
A bit to the background: I am converting another custom format into reqif with your package and thus generating the whole thing from scratch. Having to do all the type conversions in my code, makes it obviously harder to read. And for sure I am writing code, which others probably write in a similar way.
I think I understand now. The interesting thing is that I haven't encountered this before with all real-world ReqIFs that I could collect over time.
Could you make an example of a value that would not be string-based?
In the example above, at line 271, are you saying the object could be a bool value? If yes, then how would this work with a corresponding ReqIF file which only has HTML string attributes, for example, <ATTRIBUTE-VALUE-BOOLEAN THE-VALUE="true">?
convert Python data types to strings according to the ReqIF specification.
Could you provide a quote a specific part of the spec to let me know which kind of conversion is missing?
Thanks for providing a note on what you are actually doing. I am all in for simplifying the API, but I want to keep it correspond to what is in the XML files. Right now, the types are declared
value: Union[str, List[str]],
which is what is seen with XML. I need an example of where this is done differently by the XML.
The thing is that in the ReqIF they are string based, but when creating one from scratch and unparsing it, it gets inconvenient.
In https://github.com/strictdoc-project/reqif/pull/176 I (already) extended one of your integration tests with at least a part.
What you are showing in #176 looks good. Please proceed with implementing it as your time allows.