-
Notifications
You must be signed in to change notification settings - Fork 12
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
Fix offset type #8
base: master
Are you sure you want to change the base?
Conversation
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.
It's looking good! Only real question is about the "not implemented" error, I'm leaning towards just the continue like you have there since its probably a better experience for consumers of the library. What do you think?
PS. as you can probably tell i wrote this a very long time ago, it's probably time to revisit to API and look at how its used to polish it up to modern python standards and release a v1.0.
Do you mind sharing some snippets or your repo so i can see how you use this library?
if _byte != "nn": | ||
test_hex.append(ord(bytes.fromhex(_byte))) | ||
else: | ||
test_hex.append(None) | ||
|
||
for _loc, _byte in enumerate(test_hex): | ||
if signature["offset"] == "any": | ||
# any offset not supported yet | ||
continue |
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.
Should we raise a not implemented error?
@@ -1477,20 +1477,24 @@ def __init__(self, signature, *arg, **kw): | |||
self.__dict__ = signature | |||
|
|||
|
|||
def compare_sig(file_header, test_hex_string) -> bool: | |||
def compare_sig(file_header, signature) -> bool: |
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.
fantastic
@@ -7,7 +7,7 @@ def readme(): | |||
return f.read() | |||
|
|||
setup(name='pyfsig', | |||
version='0.6', | |||
version='0.8.3', |
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.
good catch!
we should probably update the offsets in the json dict to be integers rather than strings |
I agree with you. Throwing a "not implemented" error will disrupt normal usage. I believe using continue is a good solution here, or we can list all the tested signatures first. In my example, I only need to verify if the file is in ['jpg', 'mp4'], so it's very straightforward. However, I believe we can adhere to modern Python standards to refactor the code. Some developers prefer not to use |
Hi,
It looks like the function does not work for offset signatures, I did some fixes but it does not support the 'any' type.