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

Method compile_patterns

aura/pattern_matching.py:79–96  ·  view source on GitHub ↗

Compile all defined string pattern matchers into a dictionary indexed by type :signatures: a list of defined signatures (loaded from json file)

(cls, signatures: List[dict])

Source from the content-addressed store, hash-verified

77
78 @classmethod
79 def compile_patterns(cls, signatures: List[dict]) -> List[PatternMatcher]:
80 """
81 Compile all defined string pattern matchers into a dictionary indexed by type
82 :signatures: a list of defined signatures (loaded from json file)
83 """
84 types = PatternMatcher.get_patterns()
85
86 compiled = []
87 for s in signatures:
88 if type(s) == str:
89 s = {"type": "exact", "pattern": s, "message": "n/a"}
90
91 if s["type"] not in types:
92 raise ValueError("Unknown signature type: " + s["type"])
93
94 compiled.append(types[s["type"]](s))
95
96 return compiled
97
98 @classmethod
99 def find_matches(cls, value, signatures: list):

Callers 3

test_string_matchingFunction · 0.80
__init__Method · 0.80
__init__Method · 0.80

Calls 1

get_patternsMethod · 0.80

Tested by 1

test_string_matchingFunction · 0.64