Esempio n. 1
0
def find_filtermode(fname):
    """
    Derive enum value from string found in filename.
    For downward compatibility, search for both patterns (e.g. '0filter' and
    'nofilter').
    """
    from constants import FILTER_MODES
    names = ["nofilter", "prefilter", "postfilter"]
    for enumval, name in zip(sorted(FILTER_MODES.keys()), names):
        if "{}filter".format(enumval) in fname or name in fname:
            return enumval
    raise KeyError("Filter mode could not be deduced from filename!")