| 3020 | |
| 3021 | |
| 3022 | class FlagValue(object): |
| 3023 | __slots__ = ["value", "names", "multi"] |
| 3024 | |
| 3025 | def _fixvalue(self, value): |
| 3026 | # type: (Any) -> int |
| 3027 | if not value: |
| 3028 | return 0 |
| 3029 | if isinstance(value, str): |
| 3030 | value = value.split('+') if self.multi else list(value) |
| 3031 | if isinstance(value, list): |
| 3032 | y = 0 |
| 3033 | for i in value: |
| 3034 | y |= 1 << self.names.index(i) |
| 3035 | value = y |
| 3036 | return int(value) |
| 3037 | |
| 3038 | def __init__(self, value, names): |
| 3039 | # type: (Union[List[str], int, str], Union[List[str], str]) -> None |
| 3040 | self.multi = isinstance(names, list) |
| 3041 | self.names = names |
| 3042 | self.value = self._fixvalue(value) |
| 3043 | |
| 3044 | def __hash__(self): |
| 3045 | # type: () -> int |
| 3046 | return hash(self.value) |
| 3047 | |
| 3048 | def __int__(self): |
| 3049 | # type: () -> int |
| 3050 | return self.value |
| 3051 | |
| 3052 | def __eq__(self, other): |
| 3053 | # type: (Any) -> bool |
| 3054 | return self.value == self._fixvalue(other) |
| 3055 | |
| 3056 | def __lt__(self, other): |
| 3057 | # type: (Any) -> bool |
| 3058 | return self.value < self._fixvalue(other) |
| 3059 | |
| 3060 | def __le__(self, other): |
| 3061 | # type: (Any) -> bool |
| 3062 | return self.value <= self._fixvalue(other) |
| 3063 | |
| 3064 | def __gt__(self, other): |
| 3065 | # type: (Any) -> bool |
| 3066 | return self.value > self._fixvalue(other) |
| 3067 | |
| 3068 | def __ge__(self, other): |
| 3069 | # type: (Any) -> bool |
| 3070 | return self.value >= self._fixvalue(other) |
| 3071 | |
| 3072 | def __ne__(self, other): |
| 3073 | # type: (Any) -> bool |
| 3074 | return self.value != self._fixvalue(other) |
| 3075 | |
| 3076 | def __and__(self, other): |
| 3077 | # type: (int) -> FlagValue |
| 3078 | return self.__class__(self.value & self._fixvalue(other), self.names) |
| 3079 | __rand__ = __and__ |
no outgoing calls
no test coverage detected
searching dependent graphs…