GuidanceOfGrace / CLASSIC-Fallout4

Crash Log Auto-Scanner & Setup Integrity Checker for Fallout 4 / Buffout 4. Tool that extensively scans Fallout 4 game & mod files and Buffout 4 crash logs, then provides troubleshooting advice depending on what it finds.
8 stars 4 forks source link

RFC: Code Vacuuming and Reworking #38

Closed evildarkarchon closed 1 year ago

evildarkarchon commented 1 year ago

This is a big one and some of the stuff here requires Python >=3.10 (which is what is already reccomend on the nexus page). I moved all class definitions to a new file called CLASlib.py to clean up the other scripts a bit.

I switched a lot of if statements to match-case statements, I got a little carried away in Scan_Crashlogs but I believe using match-case in appropriate situations can make the code more readable and possibly make for mpre precise tests.

I added a dataclass that will store variables that were previously global, it's a better practice to do something like this and helps prevent accidental globals :)

I added a class that will hold the text, lines list, and file handle to make creation of convenience functions easier. I created a convenience function to use write or writelines depending on the type of object given to it (write for a string, writelines for an iterable)

I split crash_template to a write and read version because I wanted the write functionality to be handled by the new class.

This will probably need some more polish, but I've run my normal tests and it performed well. Although running with FCX mode on with a testbed of around 300 logs does take a minute or two. :)

I appoligize for the code overload.

evildarkarchon commented 1 year ago

Some commit messages may not be entirely accurate because I wrote them thinking I already committed other code that is in those commits.

evildarkarchon commented 1 year ago

There is an issue with stat reporting that I can only replicate when using a pyinstaller exe, when I run from the regular python command, it gives me accurate stats. I know the stats that the pyinstaller exe is giving me is incorrect because I keep track of a couple in particular (bad meshes and precombines, they are the most frequent crashes that I encounter) and they doubled for reasons unknown, and some were zero when I knew there was at least a couple of them. I also wouldn't be surprised if I got some of the test logic wrong, I will probably need to go over the main branch version and probably revert some of my changes.