Download this file
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]