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

CHANGE StatusType to Enum #151

Merged
merged 2 commits into from
Jan 20, 2017
Merged

CHANGE StatusType to Enum #151

merged 2 commits into from
Jan 20, 2017

Conversation

shukon
Copy link
Collaborator

@shukon shukon commented Jan 17, 2017

Implementing issue #81, adding human-readable mapping of StatusTypes. The originally wished for

\>\>\> print(mapping[status])

is realized through Enum as

\>\>\> print(status.name)

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.

@coveralls
Copy link

Coverage Status

Coverage increased (+0.08%) to 76.041% when pulling 82d729c on issue/#81 into 912b4de on development.

2 similar comments
@coveralls
Copy link

Coverage Status

Coverage increased (+0.08%) to 76.041% when pulling 82d729c on issue/#81 into 912b4de on development.

@coveralls
Copy link

coveralls commented Jan 17, 2017

Coverage Status

Coverage increased (+0.08%) to 76.041% when pulling 82d729c on issue/#81 into 912b4de on development.

Copy link
Contributor

@mfeurer mfeurer left a 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)
Copy link
Contributor

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.

Copy link
Collaborator Author

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

@coveralls
Copy link

coveralls commented Jan 19, 2017

Coverage Status

Coverage increased (+0.09%) to 76.052% when pulling 4a088bb on issue/#81 into 912b4de on development.

@mlindauer mlindauer merged commit a47c111 into development Jan 20, 2017
@mlindauer mlindauer deleted the issue/#81 branch January 20, 2017 12:34
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.

None yet

4 participants