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