-
-
Notifications
You must be signed in to change notification settings - Fork 133
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
Improve helpers module #297
base: master
Are you sure you want to change the base?
Conversation
UnityPy/helpers/Tpk.py
Outdated
|
||
from .TypeTreeHelper import TypeTreeNode | ||
|
||
TPKTYPETREE: TpkTypeTreeBlob = None | ||
TPKTYPETREE: Optional[TpkTypeTreeBlob] = None |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
TPKTYPETREE is always a TpkTypeTreeBlob due to the init call at the end of the file.
So the Optional would add more trouble, as the other functions here would then need unnecessary None checks.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see.
I guess it would be better if we use something like TPKTYPETREE: TpkTypeTreeBlob = init()
, which is also an execute-at-import behavior but result in more clear intention and better type checking experience which avoid separating the init()
call to the end of the file.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sadly that doesn't work, as the parser classes aren't defined yet at that point.
It simply errors.
Exception has occurred: NameError
name 'TpkFile' is not defined
5ab6d25
to
c695346
Compare
46f2f13
to
2bb0dc1
Compare
According to your 4 reviews. I have changed these things and force-pushed these changes. |
2bb0dc1
to
ac02d0c
Compare
ac02d0c
to
f63ea1f
Compare
Okay. 2 fixes were applyed since the last push:
|
Summary
This PR does some minor improvements on the helpers module. These improvements will not affect the existing features.
Common Changes
Individual Changes
ArchiveStorageDecryptor
: Uses an inline approach to replace the functionto_uint4_array
, which can improve the performance and simplify the code.ResourceReader
: Refactors theget_resource_data
function, because this function used an implicit argument overloading trick (mixed the 4-args invocation and the 3-args invocation, but only 4-args invocation is used externally), which is bad for maintaining.UnityVersion
: Fixes the error in the methodfromString
.