diff options
author | Marc Bonnici <marc.bonnici@arm.com> | 2018-11-29 10:31:39 +0000 |
---|---|---|
committer | setrofim <setrofim@gmail.com> | 2018-12-07 09:55:17 +0000 |
commit | 4f67cda89fc3966a9c08b5799e289aca93ad38dd (patch) | |
tree | 9a579054eb066322abb67fb80ed58123e4a63892 | |
parent | 0113940c85d64e02b9eb627737708b58f2816c66 (diff) |
utils/types: When creating an enum also try to deserialize from POD
Allows for recreating an Enum from a full string representation of the Enum
rather than just the name of the Enum.
-rw-r--r-- | wa/utils/types.py | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/wa/utils/types.py b/wa/utils/types.py index a498778a..751e0bbf 100644 --- a/wa/utils/types.py +++ b/wa/utils/types.py @@ -635,7 +635,10 @@ def enum(args, start=0, step=1): if name == attr: return attr - raise ValueError('Invalid enum value: {}'.format(repr(name))) + try: + return Enum.from_pod(name) + except ValueError: + raise ValueError('Invalid enum value: {}'.format(repr(name))) reserved = ['values', 'levels', 'names'] |