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

Improvements for programmatic usage #55

Open
wants to merge 33 commits into
base: master
Choose a base branch
from

Conversation

queengooborg
Copy link

This PR performs a number of changes tailored towards improving the experience when using DecompilerMC as a module, rather than as a script.

User Story

I use DecompilerMC as a dependency in a toolkit that reads the source code for Minecraft and calculates all of its items and their crafting recipes, which is then used to generate a worth.yml file for EssentialsX.

However, I had to make some adjustments to its code to get it to work in the manner I desired it to. The primary issue I ran into was that sys.exit() was used quite often throughout the code when there was an error, which means that any script that imported it as a module would also quit on error.

Solution

To improve the experience for module use, as well as to provide other minor improvements, the following changes were made:

  • Replace most instances of sys.exit() with thrown exceptions
  • Use pathlib.Path for most filepaths, rather than strings
  • Don't delete manifest.json after parsing, only when redownloading
    • This allows for partial offline use of DecompilerMC
  • Improves various messages

mat-1 and others added 30 commits June 24, 2022 21:21
This step only happens if running in manual mode, so I can't imagine it's quite useful.
Manual mode is really only helpful for debugging, but not really, because each step can only run if the previous step had.  Implementing the ability to pick and choose steps just adds additional complexity to the program for very little gain.
"--forceno" is on by default, but the only reason to set it to False is to enable interactivity when it detects the conflict.  This just adds more complexity to the code, and the better option is to simply have the user specify "--clean" or "--force" instead.
hube12 pushed a commit that referenced this pull request Nov 2, 2024
- Add the path used to open the program from to all relative paths, so program doesn't create new folders in a directory outside the one it's located within
- Replace sys.exits with exception raising (see #55)
- Replace assertion (which can be compiled out) with unskippable test + exception
- Tweak url['..._mappings'] code so correct exception is raised (#50)
- Standardize pathlib usage
- Some code restructuring to reduce the amount of indentation
- Add some typing
- Grammar fixes in code outputs/errors
- Add TODOs to mark areas for future improvement
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants