# -*- coding: utf-8 -*-
#  Copyright (c) 2020. Distributed under the terms of the MIT License.

from enum import unique, Enum


@unique
class ExtendedEnum(Enum):

    def __repr__(self):
        return self.name

    def __str__(self):
        return self.name

    @classmethod
    def from_string(cls, s: str):
        for m in cls:
            if m.name == s:
                return m
        raise AttributeError(f"{str(s)} is not proper member for {cls}.\n",
                             f"Supported names:\n {cls.names_string()}")

    @classmethod
    def names_string(cls):
        return ", ".join([e.name for e in cls])

    @classmethod
    def name_list(cls):
        return [e for e in cls]

    @classmethod
    def name_str_list(cls):
        return [str(e) for e in cls]

    @classmethod
    def values(cls):
        return [e.value for e in cls]
