-
Notifications
You must be signed in to change notification settings - Fork 2
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
[FEATURE] Wrap this into a class that can be imported into other projects #2
Comments
I shall have a look at this over the weekend. :-) |
Hm, so the thing is, I never messed with OOP other than a bit in theory. And the way I see it, at least some of the code would have to be rewritten and much would have to be restructured, wouldn't it? For example, the program's main function, unless -1/--stdout is given, would directly write the output CU2 sheet. Would the class still do that? I wouldn't want a pull request at this time because I'd still need to understand what happens when and how, in case I need to modify things later. ;-) |
On Mon, Apr 19, 2021 at 6:34 AM NRGDEAD ***@***.***> wrote:
Hm, so the thing is, I never messed with OOP other than a bit in theory.
And the way I see it, at least some of the code would have to be rewritten
and much would have to be restructured, wouldn't it?
Some, but it would mostly be mechanical work I think, mostly shifting code
a round a bit and into methods.
I imagine most of the work would be to move almost all of it just into a
class and a method, lets call it convert()
and also move the argument parsing and store it inside the new
if __name__ == "__main__":
block. This would have the effect that the args variable will no longer be
global so you would probably
need to add setters for these fields to the class, so htat inside main()
after you have parsed and verified all the arguments
you would create an initial cue2cu2 object and then use the setter
functions to set the arguments one by one.
This means you would have to change a lot of args.offset_select and similar
to instead be self._offset_select
That would be a lot of changes but it is mostly mechanical so not complex.
For example, the program's main function, unless -1/--stdout is given,
would directly write the output CU2 sheet. Would the class still do that?
Probably. You could either pass a filename to the class and it would open
that file and write to it, or you could pass an open IO handle to the
class and tell it
to "write the converted data here".
Maybe it could look something like :
c = cue2cu2()
c.offset_select = args.offset_select
...
c.open(cue-file) # opens the cue file and processes it
c.convert(cu2-filename) # opens the destination file and writes the cu2 to it
I wouldn't want a pull request at this time because I'd still need to
understand what happens when and how, in case I need to modify things
later. ;-)
fair enough
… —
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#2 (comment)>, or
unsubscribe
<https://github.com/notifications/unsubscribe-auth/AADY3EHSV3SNQCDFUS2Y5LLTJM64LANCNFSM43BKXKVA>
.
|
I'll see if I can implement this in the near future. But I can't give an ETA at the moment. :-) |
Ok, Looking forward to see what you can come up with since it would be nice to have a more close integration. |
Do you have any plans of making this useful also to be imported as a class into other projects and not only a standalone executable?
I ask because I am putting together a universal psx installer program for all platforms psx games can be played over at:
https://github.com/sahlberg/pop-fe
Excuse the hyperbole of mine, but PSIO is one beloved target that I want to support and CUE2CU2 suport would be nice.
I support PSIO right now in the sense it automatically discovers the game-id, game-name and fetches box art for it, and installs it onto the sd-card for psio, with boxart and also with MULTIDISC.LTS if it is a multidisc game. But adding cue2cu2 would make i t even bettar.
If you want to see what I mean with making it into a class, please see my repo for pop-fe and sor example bchunk.py, which is a version on bchunk in python3, but it is designed in such a way that it can either be run as an independent program :
if name == "main":
Or, as I use it from pop-fe, also be used as "import bchunk" and then I programatically do the same thing from my main program.
If you have no plans of this, would you be willing to take a pull request if I make those changes to cue2cu2 ?
Great work though. PS1 Is awesome and everyone that works on making it even awesomerer is great!
The text was updated successfully, but these errors were encountered: