From 4f67cda89fc3966a9c08b5799e289aca93ad38dd Mon Sep 17 00:00:00 2001 From: Marc Bonnici Date: Thu, 29 Nov 2018 10:31:39 +0000 Subject: 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. --- wa/utils/types.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) 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'] -- cgit v1.2.3