-
Notifications
You must be signed in to change notification settings - Fork 217
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
CHANGE StatusType to Enum #151
Conversation
2 similar comments
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.
This looks good except for my one comment. I think we can assume that the runhistory.json file will either be only opened by people using python, or by people being able to manipulate a dictionary prior to assessing it.
if "__enum__" in obj: | ||
# object is marked as enum | ||
name, member = obj["__enum__"].split(".") | ||
return getattr(globals()[name], member) |
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.
We only want to parse a single enum, all other enums should not be parsed. Thus, I think this should be more restrictive.
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.
Integrated a simple check for the name of the enum. Should a TypeError be raised if another enum than StatusType is detected?
if name == "StatusType": return getattr(globals()[name], member)
else: return obj
Implementing issue #81, adding human-readable mapping of StatusTypes. The originally wished for
is realized through Enum as
JSON-serialization of runhistories is affected: status is now saved by customized JSON-Encoder.
This might affect the possibility of reading in the JSON-file from another language/without the object_hook.