def mask_to_str(mask, enum_map):
    """
    Attempts to produce a string of set flags from the given mask and dict of enum value-to-name mappings
    mask: int - bitmask from e.g. Windows API
    enum_map: dict[int -> str]
    returns a string in the form: FLAG 1 | FLAG 2 ...
    """
    flags_set = []
    for flag in enum_map.keys():
        if mask & flag == flag:
            flags_set.append(enum_map[flag])
    return ' | '.join(flags_set)
