def _find_get_patten_match_single(dic, match_func):
"""
Find a matching key from dict. This function returns value when the
found match is the only match in the dict.
Args:
dic (dict): Mapping from a key (str) to corresponding metric (numeric)
from one output of LogReporter.
match_func (func): A function that takes a variable (str) as input and
returns a bool if it is a valid match.
Returns:
str or None
"""
# match_func(str) -> bool
found_key = None
for k in six.iterkeys(dic):
if match_func(k):
if found_key is None:
found_key = k
else:
# The second match is found
return None
return found_key
评论列表
文章目录