def parse_str_enum_value(value, enum_class, default=NOTSET, unknown_member_error=None):
    if ((value is None) and (default is not NOTSET)):
        value = default
    elif isinstance(value, str):
        try:
            value = enum_class[value]
        except KeyError:
            raise ValueError((unknown_member_error or "Unknown element of {cls} '{value}'. The only known are: {available}").format(cls=enum_class.__name__, value=value, available=', '.join((e.name for e in enum_class))))
    elif isinstance(value, enum_class):
        pass
    else:
        raise TypeError(('Expected value type string or %s, but got %s' % (enum_class.__name__, type(value).__name__)))
    return value
def parse_str_enum_value(value, enum_class, default=NOTSET, unknown_member_error=None):
    if ((value is None) and (default is not NOTSET)):
        value = default
    elif isinstance(value, str):
        try:
            value = enum_class[value]
        except KeyError:
            raise ValueError((unknown_member_error or "Unknown element of {cls} '{value}'. The only known are: {available}").format(cls=enum_class.__name__, value=value, available=', '.join((e.name for e in enum_class))))
    elif isinstance(value, enum_class):
        pass
    else:
        raise TypeError(('Expected value type string or %s, but got %s' % (enum_class.__name__, type(value).__name__)))
    return value