#NEWLINE# def filter_by( lookup , expr_form = 'compound' , minion_id = None ) : #NEWLINE# #INDENT# "\n    Return the first match in a dictionary of target patterns\n\n    .. versionadded:: 2014.7.0\n\n    CLI Example:\n\n    .. code-block:: bash\n\n        salt '*' match.filter_by '{foo*: Foo!, bar*: Bar!}' minion_id=bar03\n\n    Pillar Example:\n\n    .. code-block:: yaml\n\n        {% set roles = salt['match.filter_by']({\n            'web*': ['app', 'caching'],\n            'db*': ['db'],\n        }) %}\n    " #NEWLINE# expr_funcs = dict ( inspect . getmembers ( sys . modules [ __name__ ] , predicate = inspect . isfunction ) ) #NEWLINE# for key in expr_funcs : #NEWLINE# #INDENT# params = ( ( key , minion_id ) if minion_id else ( key , ) ) #NEWLINE# if expr_funcs [ expr_form ] ( * params ) : #NEWLINE# #INDENT# return lookup [ key ] #NEWLINE# #UNINDENT# #UNINDENT# return None