Bitwise order option of list all states
This commit is contained in:
parent
90f494a1f6
commit
98387157f5
@ -240,14 +240,29 @@ class State:
|
|||||||
return self.__alias(k, *args)
|
return self.__alias(k, *args)
|
||||||
|
|
||||||
|
|
||||||
def all(self, pure=False, numeric=False, ignore_auto=True):
|
def __all_bit(self):
|
||||||
|
r = []
|
||||||
|
r.append(self.name(0))
|
||||||
|
v = 1
|
||||||
|
while v < self.__limit:
|
||||||
|
r.append(self.name(v))
|
||||||
|
v <<= 1
|
||||||
|
return r
|
||||||
|
|
||||||
|
|
||||||
|
def all(self, pure=False, numeric=False, ignore_auto=True, bit_order=False):
|
||||||
"""Return list of all unique atomic and alias state strings.
|
"""Return list of all unique atomic and alias state strings.
|
||||||
|
|
||||||
:rtype: list of ints
|
:rtype: list of ints
|
||||||
:return: states
|
:return: states
|
||||||
"""
|
"""
|
||||||
l = []
|
l = []
|
||||||
for k in dir(self):
|
v = None
|
||||||
|
if bit_order:
|
||||||
|
v = self.__all_bit()
|
||||||
|
else:
|
||||||
|
v = dir(self)
|
||||||
|
for k in v:
|
||||||
state = None
|
state = None
|
||||||
if k[0] == '_' and ignore_auto:
|
if k[0] == '_' and ignore_auto:
|
||||||
continue
|
continue
|
||||||
@ -263,6 +278,7 @@ class State:
|
|||||||
l.append(state)
|
l.append(state)
|
||||||
else:
|
else:
|
||||||
l.append(k)
|
l.append(k)
|
||||||
|
if not bit_order:
|
||||||
l.sort()
|
l.sort()
|
||||||
return l
|
return l
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user