Beispiel #1
0
 def __or__(self, other) -> Flag:
     if not isinstance(other, self.__class__):
         return NotImplemented
     self_components = _decompose(self.__class__, self._value_)[0]
     other_components = _decompose(self.__class__, other._value_)[0]
     self_primary = list(
         filter(lambda x: x in self._uncombinable, self_components))[:1][0]
     other_combinable = list(
         filter(lambda x: x not in self._uncombinable, other_components))
     usable_output = self_primary
     for val in other_combinable:
         usable_output = Flag.__or__(usable_output, val)
     usable_output._name_ = None if len(
         other_combinable) > 0 else usable_output._name_
     return usable_output
Beispiel #2
0
    def __iter__(self):
        cls = self.__class__

        members, _ = _decompose(cls, self._value_)

        for m in members:
            yield str(m._name_ or m._value_)
Beispiel #3
0
 def __str__(self):
     cls = self.__class__
     if self._name_ is not None:
         return '%s' % (self._name_)
     members, _uncovered = _decompose(cls, self._value_)
     if len(members) == 1 and members[0]._name_ is None:
         return '%r' % (members[0]._value_)
     else:
         return '|'.join([str(m._name_ or m._value_) for m in members])
Beispiel #4
0
 def to_list(self):
     listvalues = []
     if self._name_ is not None:
         listvalues.append(self._name_)
     members, uncovered = _decompose(ContentCategories, self._value_)
     if len(members) == 1 and members[0]._name_ is None:
         listvalues.append(members[0]._value_)
     else:
         for m in members:
             listvalues.append(str(m._name_ or m._value_))
     return listvalues
 def decomposed_name(self, sep='|'):
     return sep.join([e.name for e in _decompose(self.__class__, self)[0]])
Beispiel #6
0
 def _create_pseudo_member_(cls, value):
     value = super()._create_pseudo_member_(value)
     members, _ = enum._decompose(cls, value)
     value._name_ = "|".join([m.name for m in members])
     return value
Beispiel #7
0
 def __str__(self):
     members, _ = enum._decompose(self.__class__,
                                  self._value_)  # type: ignore
     return "|".join([str(m._name_ or m._value_) for m in members])
Beispiel #8
0
 def __repr__(self):
     members, _ = enum._decompose(self.__class__, self._value_)
     return '%s:%s' % (bin(self._value_), '|'.join([str(m._name_ or m._value_) for m in members]))
Beispiel #9
0
def e2s(flag):
    if flag.name is not None:
        return flag.name
    members, _ = enum._decompose(type(flag), flag.value)
    return '|'.join(m.name for m in members)
Beispiel #10
0
 def parts(self) -> tuple['Color', ...]:
     members, uncovered = _decompose(self.__class__, self._value_)
     return tuple(members)
Beispiel #11
0
 def __repr__(self):
     cls = self.__class__
     if self._name_ is not None:
         return self._name_
     members, _ = enum._decompose(cls, self._value_)
     return "|".join([str(m._name_ or m._value_) for m in members])
Beispiel #12
0
 def update_event(self, inp=-1):
     self.set_output_val(0, enum._decompose(self.input(0), self.input(1)))
Beispiel #13
0
	def __iter__(self):
		members, extra_flags = _decompose(self.__class__, self.value)
		return (m for m in members if m._value_ != 0)