def match_node(self, key):
found_node = None
for regex_key, node in six.viewitems(self._key_node_dict):
match_object = re.match("(?:%s)\Z" % regex_key, key)
if match_object is not None:
if found_node is None:
found_node = node
found_regex_key = regex_key
found_match_object = match_object
else:
raise ValueError("The data key '{}' matches multiple keys: "
"'{}' for {} and '{}' for {}.".format(
key, found_regex_key, found_node,
regex_key, node))
if found_node is None:
raise KeyError(key)
return found_regex_key, found_node, found_match_object
评论列表
文章目录