Laerinok / VS_ModsUpdater

Easily update your favorite mods
MIT License
2 stars 3 forks source link

Using defined location for config, fixed some regex #39

Open Zetabite opened 6 months ago

Zetabite commented 6 months ago

Also fixes the issue of #38

Zetabite commented 6 months ago

Note, this does not copy the original config.ini over. If that is a wished behavior, that could be arranged. Also, may i suggest adding a field for the version of the config file? then we can prevent issues like missing keys not being added, as we know that those keys havent existed and would be needed to be added

Laerinok commented 6 months ago

Thanks for this. I will study it and try to understand what you made different. As I should have already said, I am a beginer, it's my first script and before this script I knew nothing about programming or Python ;) Because of adding features over the times and the lack of knowledges, I am aware that there are some redundancies and many things to improve. Maybe one day I will write a new script or clean this one, but... one day

Zetabite commented 6 months ago

Getter for Paths

For one part, i removed class variables several times where you set paths, as you are not giving them as parameter, you were using the same all over the place. so instead of being a part of the class, every class can now utilize global functions that handle it. This also causes classes to be easier to read, as there are now less variables for classes to keep track off, and saves on applying the same checks several times, well, in the way that those are handled in the function now and not separately in the classes.

Default Paths

Additionally by default, logs, temp folder and config are no longer saved in the same folder as the executable. This is, so this can be shipped as standalone program to be installed, as at least for most linux systems, programs cant write to their own folder. It also unifies were to find stuff. But ofc, one might want to use other configs for other modpacks, so i made an option to use another file.

regexes

Furthermore, some regexes were broken, at least to what i understood.

A look to the future

Type Hinting

A thing i want to target next is type hinting, cause as the codebase grows, its gets harder and harder to understand what type a function expects and/or returns.

Pretty printing

Also, all the pretty printing you are doing is causing lines to be very long and increasingly harder to read, you might wanna consider to make templates for the printing part.

Modulization

Since this has grown a lot since its beginnings, you should think about putting the handling of different parts of the program into separate modules that you utilize in the main file.

Laerinok commented 6 months ago

Hello, Thanks again for your time and explanations. But keep in mind that I know "nothing". I am a great beginner. I don't have the logical of a programer. When I started I had no idea of was a class nor what programing was. And yet now, I am not confortable with all these notions. But each issue /new idea bring a lot of comprehension. I am aware that there are many things that are not "good", "conventional" or "optimized". There're many things I won't do in the same way for sure.

I won't merge the code for now, because If I add code I didn't make I won't understand and I will be lost. But it will be very useful to learn and understand and... change later. My main aim is a functional script I've made. Later, with more knowledges, I will try to optimize or make things cleaner.

Most of things/terms you use are very abstract for me. What you said in "A look to the future" are things that I am starting to realize. But it is too abstract for me to change things in this script. It would be a big mess ans I would break everything and will shall spend too many time. Probably I should think to rewrite all the script. Maybe a v2.0 will come one day. According time, feeling...

Also, may i suggest adding a field for the version of the config file?

Well it's already there. Or I didn't understand what you mean.

[ModsUpdater]
# info about the creation of the config.ini file
ver = 1.4.0

programs cant write to their own folder.

I didn't know this. I am not a linux user ;) At the first begining, the config.ini was in the Vintagestorydata folder. But I didn't think that we could use another datapath. So I decided to put files in the program folder. And Linux version came later.

I could use system temp folder for temp. But where do you put the config.ini ? (I didn't yet have a look at your code). Because , probably a Windows thought, but I think that the config.ini is a at the right place in the program folder.

Zetabite commented 6 months ago

I won't merge the code for now, because If I add code I didn't make I won't understand and I will be lost.

Totally valid. Better that than being lost. For not knowing how to program, that script is already pretty good. This PR will be here as long as you want.

Well it's already there. Or I didn't understand what you mean.

Actually a fair point.

I could use system temp folder for temp.

Honestly the better way, I personally just don't know myself how you would do it.

I think that the config.ini is a at the right place in the program folder

You could make a config.ini that has the defaults for it, then just copy it to desired location and make changes.

As to what type hinting is: Basically glorified commenting. You use some certain syntax to describe what type a value should be, similary how you would set a function type, parameter type and return type in other programming languages, but less strict, due to pythons duck typing (yes, that is what pythons typing system is)

Again, if you have any questions, dont hesitate to ask. (tho probably not via this github thread, but rather some other way of communication)