diff --git a/src/python/pyeclib/ec_iface.py b/src/python/pyeclib/ec_iface.py index b9b8064..40feed0 100644 --- a/src/python/pyeclib/ec_iface.py +++ b/src/python/pyeclib/ec_iface.py @@ -39,7 +39,7 @@ class PyECLibEnum(Enum): return list(self) @classmethod - def is_member(cls, name): + def has_enum(cls, name): # returns True if name is a valid member of the enum try: cls.__getattr__(name) @@ -47,6 +47,22 @@ class PyECLibEnum(Enum): return False return True + @classmethod + def get_by_name(cls, name): + try: + obj = cls.__getattr__(name) + except AttributeError: + return None + return obj + + @classmethod + def names(cls): + return [name for name, value in cls.__members__.items()] + + @classmethod + def values(cls): + return [value for name, value in cls.__members__.items()] + def __str__(self): return "%s: %d" % (self.name, self.value)