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

Error Migration and Refactoring for 3.6.0 #549

Merged
merged 9 commits into from
May 1, 2024

Conversation

StandingPadAnimations
Copy link
Collaborator

@StandingPadAnimations StandingPadAnimations commented Mar 1, 2024

This PR is mainly to migrate errors in MCprep to use the new MCprepError class. At some point, we realized the need for being able to return objects with messages, so we also added an optional msg field to MCprepError.

In this PR, we also perform any general refactoring that may crop up as needed. Most of these are related to error handling, but there are a few that for the sake of getting out of the way I've done, which are:

  • Removal of Blender Internal and Blender 2.7X code in world_tools.py
  • Removal of 2.7X link and append operations in bAppendLink, as well as deprecate the active_layer argument

The following functions have been refactored to use the new error type:

  • convert_mtl: Optional[bool] -> Optional[MCprepError]
  • enable_obj_importer: Optional[Bool] -> Union[OBJImportCode, MCprepError]
  • bAppendLink: bool -> Optional[MCprepError]
  • open_program: Union[int, str] -> Optional[MCprepError]

Sometimes an exception may not be so clear cut, so let's allow an
optional message to return
In this commit, we do the following:
- Convert more functions to use MCprepError
- Remove Blender Internal and 2.7X specific code
This refactors the following functions to use the new error type:
- bAppendLink
- open_program

In addition, the function bAppendLink has had all 2.7X related code
removed, although an argument related to 2.7X layers is kept to avoid
widescale breakage
This file is not used at all, and is poorly written. If we need to
revisit this idea, we can use Vivy as reference
Copy link
Member

@TheDuckCow TheDuckCow left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice changes! I see it's still in draft, so just leaving as comments for now. please re-request review once ready for more input

MCprep_addon/materials/default_materials.py Show resolved Hide resolved
Comment on lines 229 to 236
def bv28() -> bool:
"""Check if blender 2.8, for layouts, UI, and properties. """
"""
Check if blender 2.8, for layouts, UI, and properties.

Deprecated in MCprep 3.5, but kept to avoid breakage for now...
"""
env.deprecation_warning()
return min_bv((2, 80))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All of these references have been removed now. If not on this 3.6.0 branch, then check in dev (maybe merging dev into the milestone branch), in which case either way I think this function can just be removed.

MCprep_addon/world_tools.py Show resolved Hide resolved
@StandingPadAnimations
Copy link
Collaborator Author

I think I'll wait till #555 is merged before continuing to work on this, since both #555 and this PR have changes in world_tools.py. One #555 is merged, I'll update this branch with minestone-3-6-0 and continue working on this

Base automatically changed from milestone-3-6-0 to dev April 28, 2024 04:39
@StandingPadAnimations
Copy link
Collaborator Author

I think we should merge this into the CommonMCOBJ branch so we can knock out 2 birds with one stone

@StandingPadAnimations StandingPadAnimations changed the base branch from dev to common-mc-obj-v1 May 1, 2024 03:08
@StandingPadAnimations StandingPadAnimations marked this pull request as ready for review May 1, 2024 03:09
@StandingPadAnimations
Copy link
Collaborator Author

Alright, merging into the CommonMCOBJ branch

@StandingPadAnimations StandingPadAnimations merged commit 76a6d4d into common-mc-obj-v1 May 1, 2024
@StandingPadAnimations StandingPadAnimations deleted the refactoring-3-6-0 branch May 1, 2024 03:10
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.

2 participants