MCPcopy Create free account
hub / github.com/SourceCode-AI/aura / FilePatternMatcher

Class FilePatternMatcher

aura/pattern_matching.py:128–146  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

126
127
128class FilePatternMatcher():
129 def __init__(self, signature):
130 self._signature = signature
131 self.__compiled = PatternMatcher.compile_patterns([signature])[0]
132
133 def __repr__(self):
134 return f"<FilePatternMatcher({repr(self._signature)})>"
135
136 def match(self, value: ScanLocation) -> bool:
137 if self._signature.get("target", "full") == "full":
138 targets = (str(value.location),)
139 elif self._signature["target"] == "part":
140 targets = value.location.parts
141 elif self._signature["target"] == "filename":
142 targets = (value.location.name,)
143 else:
144 raise ValueError(f"Unknown pattern target: '{self._signature['target']}'")
145
146 return any(self.__compiled.match(x) for x in targets)
147
148
149class RegexPattern(StringPatternMatcher):

Callers 2

test_file_patternsFunction · 0.90
get_file_patternsFunction · 0.85

Calls

no outgoing calls

Tested by 1

test_file_patternsFunction · 0.72