specfile
specfile copied to clipboard
Create Specfile from a virtual file
Currently, it is possible to create an object of Specfile like this:
# using an absolute path
specfile = Specfile('/tmp/test.spec')
# using a relative path and a different sourcedir
specfile = Specfile('test.spec', sourcedir='/tmp/sources')
It would be nice to be able to create it also like this
with open('/tmp/test.spec', 'r') as fp:
specfile = Specfile(fp)
This alone is not so interesting, but it allows for creating Specfile from a virtual file
from io import StringIO
fp = StringIO()
fp.write("Name: foo\nVersion: 1.0\nRelease: 1\n...")
specfile = Specfile(fp)
Of course, I am interested in the feature, not the exact syntax. My suggestion will probably have an issue with the .save() method so if it is done like
specfile = Specfile(fp=fp)
# or
specfile = Specfile.from_fp(fp)
It is all fine with me :-)
This shouldn't be a problem, I'd probably go with adding a fp argument to the constructor. However, sourcedir would have to be specified when using fp.
Still relevant but low priority.
@FrostyX is this still useful for you?
Still relevant but low priority. @FrostyX is this still useful for you?
No problem with me. Somewhere (if I could only remember where) I wanted to do this and couldn't, so I workarounded it by saving the specfile from a variable to a temporary file and using Specfile the standard way.
I still think it is useful but I agree with the low priority since it can be easily workarounded.
Still relevant, but not a high priority since we can workaround this...
Hi, I'm interested in working on this issue as part of my GSoC preparation. I'm learning Fedora packaging and Python, and this looks like a good way to understand how spec files are parsed. I'd like to implement this feature by adding new attributes (license_files, doc_files) to the Specfile class and update the parsing logic accordingly.
@kaosiso This issue has been fixed and closed, there is nothing to do here.