1 """
2 Perfom flag operations on numbers.
3 """
4
6 """
7 Takes a list of bools and returns
8 a flagbyte.
9 """
10 flag = 0
11 for index, item in enumerate(flaglist):
12 flag = setFlag(flag, index, item)
13 return flag
14
16 """
17 Sets the bit at 'pos' to 'status', and
18 returns the modified flagbyte.
19 """
20 if status:
21 return flagbyte | 2**pos
22 else:
23 return flagbyte & ~2**pos
24
26 """
27 Returns the bit at 'pos' in 'flagbyte'
28 """
29 mask = 2**pos
30 result = flagbyte & mask
31 return (result == mask)
32
34 """
35 Returns the bits specified in the arguments
36 """
37 return [getFlag(flagbyte, pos) for pos in positions]
38