MCPcopy
hub / github.com/psf/black / _submatch

Method _submatch

src/blib2to3/pytree.py:672–697  ·  view source on GitHub ↗

Match the pattern's content to the node's children. This assumes the node type matches and self.content is not None. Returns True if it matches, False if not. If results is not None, it must be a dict which will be updated with the nodes matching named sub

(self, node, results=None)

Source from the content-addressed store, hash-verified

670 self.name = name
671
672 def _submatch(self, node, results=None) -> bool:
673 """
674 Match the pattern's content to the node's children.
675
676 This assumes the node type matches and self.content is not None.
677
678 Returns True if it matches, False if not.
679
680 If results is not None, it must be a dict which will be
681 updated with the nodes matching named subpatterns.
682
683 When returning False, the results dict may still be updated.
684 """
685 if self.wildcards:
686 for c, r in generate_matches(self.content, node.children):
687 if c == len(node.children):
688 if results is not None:
689 results.update(r)
690 return True
691 return False
692 if len(self.content) != len(node.children):
693 return False
694 for subpattern, child in zip(self.content, node.children):
695 if not subpattern.match(child, results):
696 return False
697 return True
698
699
700class WildcardPattern(BasePattern):

Callers

nothing calls this directly

Calls 2

generate_matchesFunction · 0.85
matchMethod · 0.45

Tested by

no test coverage detected