[go: up one dir, main page]

Menu

[r28]: / from_work / general.py  Maximize  Restore  History

Download this file

12 lines (10 with data), 374 Bytes

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
#!/usr/bin/env python
def get_flags(value, flags, ignore=[]):
"""Return a list of flags for a value.
Arguments:
value - the value to be tested
flags - a dictionary of name -> bit flag mappings
ignore - an optional list of keys to ignore
"""
return [ k for (k,v) in flags.items() if (value & v) > 0
and k not in ignore]