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

Instantiate Specfile with a string #248

Open
2 tasks done
danishprakash opened this issue Jul 10, 2023 · 8 comments
Open
2 tasks done

Instantiate Specfile with a string #248

danishprakash opened this issue Jul 10, 2023 · 8 comments
Assignees
Labels
area/user-experience Usability issue complexity/single-task Regular task, should be done within days. gain/high This brings a lot of value to (not strictly a lot of) users. good first issue Good for newcomers impact/low This issue impacts only a few users. kind/feature New feature or a request for enhancement. workaround-exists There is an existing workaround that can be used in the meantime of implementing the issue.

Comments

@danishprakash
Copy link

Description

Currently, it's possible to do this via a file path. In my use case, all I'm doing is fetching the specfile for multiple packages via OSC API and then trying to parse them using Specfile. I'm currently creating a temp file and then passing it on to the package.

Is this something that can be supported or have there been any discussions in the past about this that ruled it out?

Benefit

No response

Importance

No response

Workaround

  • There is an existing workaround that can be used until this feature is implemented.

Participation

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

nforro commented Jul 10, 2023

This should definitely be possible, let me think about implementation.

@nforro nforro self-assigned this Jul 10, 2023
@nforro nforro moved this from new to backlog in Packit Kanban Board Jul 10, 2023
@nforro nforro added area/user-experience Usability issue complexity/single-task Regular task, should be done within days. gain/high This brings a lot of value to (not strictly a lot of) users. impact/low This issue impacts only a few users. kind/feature New feature or a request for enhancement. workaround-exists There is an existing workaround that can be used in the meantime of implementing the issue. labels Jul 10, 2023
@danishprakash
Copy link
Author

That's great, let me know If I can help with this.

@lachmanfrantisek
Copy link
Member

Still relevant. @danishprakash by any chance, would you be interested in contributing this? (We can definitely help.)

@lachmanfrantisek lachmanfrantisek added the good first issue Good for newcomers label Mar 3, 2025
@p0tat0chip
Copy link

is the usage something like mentioned in #206 ?

@danishprakash
Copy link
Author

My idea is to be able to create an object by passing in a string, this is assuming I have a string buffer with the specfile contents. #206 seems to be suggesting to allow a file handle to be passed to to the constructor.

@p0tat0chip
Copy link

p0tat0chip commented Mar 11, 2025

What i think is the string can be passed from a method with the sourcedir argument from_str(spec_content) like:

spec_content = """\
Name: example
Version: 1.0
Release: 1%{?dist}
Summary: Example Package
"""
specfile = Specfile.from_str(spec_content, sourcedir="/abc")

the method will take string buffer and write to a tempfile to maintain the file behaviour that returns a path and avoid touching parts
like save() and reload() since they operate on files and expect path to be present.
sourcedir will be required.
This is just the same as the workaround.

@nforro
Copy link
Member

nforro commented Mar 11, 2025

Wouldn't it make more sense to first implement #206 and then use a StringIO instance internally and initialize it with a given string?

@p0tat0chip
Copy link

Yeah, that's why i had a thought if #206 is somehow related. If this approach is alright i can work on it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/user-experience Usability issue complexity/single-task Regular task, should be done within days. gain/high This brings a lot of value to (not strictly a lot of) users. good first issue Good for newcomers impact/low This issue impacts only a few users. kind/feature New feature or a request for enhancement. workaround-exists There is an existing workaround that can be used in the meantime of implementing the issue.
Projects
Status: backlog
Development

No branches or pull requests

4 participants