Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Whitespace after section header messes up with section namings #417

Open
1 of 2 tasks
hroncok opened this issue Sep 30, 2024 · 4 comments
Open
1 of 2 tasks

Whitespace after section header messes up with section namings #417

hroncok opened this issue Sep 30, 2024 · 4 comments
Labels
area/fedora Related to Fedora ecosystem complexity/single-task Regular task, should be done within days. gain/low This doesn't bring that much value to users. impact/low This issue impacts only a few users. kind/bug Something isn't working.

Comments

@hroncok
Copy link
Contributor

hroncok commented Sep 30, 2024

What happened? What is the problem?

Hello, I was wondering why there isn't a build or install section found in flowblade.spec.

When I parse the spec, I get:

>>> from specfile import Specfile
>>> specfile = Specfile('flowblade.spec')
>>> with specfile.sections() as sections:
...     for section in sections:
...         print(section.name, section.options)
... 
package 
description 
prep 
generate_buildrequires 
build 
install 
check 
files -f flowblade-trunk/%{name}.lang
changelog 
>>> with specfile.sections() as sections:
...     print("build" in sections)
...     print("install" in sections)
... 
False
False

I examined the specfile, and I found it has:

%build[space here]
...

%install[spec here]

Indeed, sections.get("build ") works.

I did not expect this to obfuscate the result of "build" in sections or sections.build. This means the only reliable way to get the build section is to iterate all the sections and look at the name.

What did you expect to happen?

I expected the insignificant trailing whitespace to be ignored.

Example URL(s)

https://src.fedoraproject.org/rpms/flowblade/blob/50cab22e213a45b84a6f839057b436f6430e422f/f/flowblade.spec

Steps to reproduce

See above

Workaround

  • There is an existing workaround that can be used until this issue is fixed.

Participation

  • I am willing to submit a pull request for this issue. (Packit team is happy to help!)
@nforro
Copy link
Member

nforro commented Oct 1, 2024

This means the only reliable way to get the build section is to iterate all the sections and look at the name.

That's true, unfortunately. I think the original intention for this behavior was to be able to do e.g. sections.get("package doc"), but it makes more sense for the unique sections to be accessible without iterating through all.

@lbarcziova lbarcziova added the kind/bug Something isn't working. label Oct 1, 2024
@lbarcziova lbarcziova self-assigned this Oct 1, 2024
@lbarcziova
Copy link
Member

hi @hroncok. When discussing this within the team, we were not able to decide the priority of this issue, we would like to ask you whether this is a blocking issue for you/what is your use case for this functionality. Thanks in advance!

@hroncok
Copy link
Contributor Author

hroncok commented Oct 1, 2024

It's just my honest this-was-unexpected bug report.

I am writing a tool that converts spec files from the old Python guidelines to the new.

flowblade.spec is the only one form the ~1.6k affected Fedora spec files that has this problem. I can easily work around it, by integrating over all the sections, but I won't -- I'd rather remove the spaces from flowblade.

So no, this is not blocking me in any way, but I thought you might be interested in the report anyway.

@lbarcziova
Copy link
Member

Sure, we appreciate it. Thanks for the explanation, this helps us a lot with the followup planning decisions.

@lbarcziova lbarcziova removed their assignment Oct 2, 2024
@lbarcziova lbarcziova added gain/low This doesn't bring that much value to users. impact/low This issue impacts only a few users. area/fedora Related to Fedora ecosystem complexity/single-task Regular task, should be done within days. labels Oct 3, 2024
@lbarcziova lbarcziova moved this from new to backlog in Packit Kanban Board Oct 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/fedora Related to Fedora ecosystem complexity/single-task Regular task, should be done within days. gain/low This doesn't bring that much value to users. impact/low This issue impacts only a few users. kind/bug Something isn't working.
Projects
Status: backlog
Development

No branches or pull requests

3 participants