<commit_before>from hwt.hdlObjects.types.hdlType import HdlType


class Enum(HdlType):
    """
    Hdl enum type

    :ivar name: name of this type
    :ivar _allValues: tuple of all values for this enum
    :note: for each value there is a property on this type object
    """

    def __init__(self, name, valueNames):
        """
        :param name: name for this type
        :param valueNames: sequence of string which will be used as names for enum
            members
        """
        super(Enum, self).__init__()
        self.name = name
        self._allValues = tuple(valueNames)
        for n in valueNames:
            v = self.fromPy(n)
            setattr(self, n, v)

    def __eq__(self, other):
        return self is other

    def __hash__(self):
        return hash((self.name, self._allValues))

    def all_mask(self):
        return 1

    def bit_length(self):
        return len(self._allValues).bit_length()

    @classmethod
    def getValueCls(cls):
        try:
            return cls._valCls
        except AttributeError:
            from hwt.hdlObjects.types.enumVal import EnumVal
            cls._valCls = EnumVal
            return cls._valCls<commit_msg>enum check if name for member is available<commit_after>from hwt.hdlObjects.types.hdlType import HdlType


class Enum(HdlType):
    """
    Hdl enum type

    :ivar name: name of this type
    :ivar _allValues: tuple of all values for this enum
    :note: for each value there is a property on this type object
    """

    def __init__(self, name, valueNames):
        """
        :param name: name for this type
        :param valueNames: sequence of string which will be used as names for enum
            members
        """
        super(Enum, self).__init__()
        self.name = name
        self._allValues = tuple(valueNames)
        for name in valueNames:
            v = self.fromPy(name)
            assert not hasattr(self, name)
            setattr(self, name, v)

    def __eq__(self, other):
        return self is other

    def __hash__(self):
        return hash((self.name, self._allValues))

    def all_mask(self):
        return 1

    def bit_length(self):
        return len(self._allValues).bit_length()

    @classmethod
    def getValueCls(cls):
        try:
            return cls._valCls
        except AttributeError:
            from hwt.hdlObjects.types.enumVal import EnumVal
            cls._valCls = EnumVal
            return cls._valCls
{'fraction_non_alphanumeric': 0.07897934386391252, 'fraction_numerical': 0.0008100445524503848, 'mean_word_length': 2.0569306930693068, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '491205', 'n_tokens_mistral': 721, 'n_tokens_neox': 706, 'n_words': 232}