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

Dipping my toes into the ocean of Regular Expressions #54

Closed evildarkarchon closed 1 year ago

evildarkarchon commented 1 year ago

Did some big things with this branch

  1. Substitute some tests' if-statements with regular expressions. 1a. This is part code cleaning and part experimentation. Regex is great for finding complex text patterns, but regex itself can be complex, so that's why I've held off until now. 1b. One thing I found during the experimentation phase. Avoid re.search except for simple queries, it's slow since it compiles a new re.Pattern object each time it's called. 1b. Using a predefined pattern and using re.compile outside the for-loop is best for speed because regex compilation takes time, so doing it only once instead of every iteration of a for-loop is best. re.Pattern objects (the output of re.compile) have their own search method which is better suited for searching using a pre-compiled pattern.
  2. Move the culprits data to a json file. The dictionary was getting a bit big. 2a. Make sure that you have setuptools installed when generating because this change requires a module from that package to work. 2b. I added a file in the CL Tools directory to generate a new json file based on the dictionary in the script. 2c. Use --add-data "crash_culprits.json;." for pyinstaller to embed the json file into the exe.
  3. Prettied up some other code (mostly bo4_check_settings)