Add replace function to order to prevent from "Unknown tag" errors
- Could you elaborate a little bit on what the issue is, please?
- I am generally not a big fan of putting code into templates. Could we clean those strings up somewhere else?
- Could you elaborate a little bit on what the issue is, please?
- I am generally not a big fan of putting code into templates. Could we clean those strings up somewhere else?
The problem arose when we're dealing with a python package whose license string is not a single line, but contains a whole text. The rpm specification does not allow to put a multi-line string into a tag, giving an unknown error such as 'Unknown tag' when building with rpm-build. Of course, this is an rpm-package specific issue, so I don't think we can clean code from templates up somewhere else.
- Could you elaborate a little bit on what the issue is, please?
- I am generally not a big fan of putting code into templates. Could we clean those strings up somewhere else?
The problem arose when we're dealing with a python package whose license string is not a single line, but contains a whole text. The rpm specification does not allow to put a multi-line string into a tag, giving an unknown error such as 'Unknown tag' when building with rpm-build. Of course, this is an rpm-package specific issue, so I don't think we can clean code from templates up somewhere else.
It's not possible to do this replacement during the data parsing? I think we can just apply this sanitize to the desired fields before calling the render method: https://github.com/openSUSE/py2pack/blob/master/py2pack/init.py#L412
Maybe something like:
...
ONE_LINE_TAGS = ['summary', 'home_page', 'license', 'source_url', 'summary_no_ending_dot']
...
for tag in ONE_LINE_TAGS:
if not tag in data:
continue
data[tag] = data[tag].replace('\n', ' ')
result = template.render(data).encode('utf-8') # render template and encode properly