Skip to content

Commit

Permalink
Adjusting Format
Browse files Browse the repository at this point in the history
  • Loading branch information
fabian-moessner committed Oct 7, 2024
1 parent cffe57b commit 7a2ca1f
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
12 changes: 6 additions & 6 deletions logprep/filter/lucene_filter.py
Original file line number Diff line number Diff line change
Expand Up @@ -237,23 +237,23 @@ def __init__(self, tree: luqum.tree, special_fields: dict = None):
for key in self._special_fields_map:
self._special_fields[key] = special_fields.get(key) if special_fields.get(key) else []

if not self._special_fields['regex_fields']:
if not self._special_fields["regex_fields"]:
self.recognize_regex_and_add_special_fields()
else:
# DEPRECATION: regex_fields are no longer necessary.
logger.warning("[Deprecation]: special_fields are no longer necessary. "
"Use Lucene regex annotation for filter ")
"Use Lucene regex annotation for filter "
)

self._last_search_field = None

def recognize_regex_and_add_special_fields(self):
""" Recognize regex expressions in filter and add those fields to regex_fields.
"""
""" Recognize regex expressions in filter and add those fields to regex_fields. """
for child in self._tree.children:
try:
value = child.children[0].value[1:-1]
if value.startswith('/') and value.endswith('/'):
self._special_fields['regex_fields'].append(child.name)
if value.startswith("/") and value.endswith("/"):
self._special_fields["regex_fields"].append(child.name)
child.children[0].value = f'"{value[1:-1]}"'
except:
pass
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/filter/test_lucene_filter.py
Original file line number Diff line number Diff line change
Expand Up @@ -462,7 +462,7 @@ def test_creates_lucene_compliance_filter_two_matching_regex_keys_of_two(self):
RegExFilterExpression(["regex_key_two"], ".*value.*"),
)

def test_creates_lucene_compliance_filter_with_one_matching_and_one_missmatching_regex_key_of_two(self):
def test_creates_lucene_compliance_filter_one_matching_one_missmatch_regex_key_of_two(self):
lucene_filter = LuceneFilter.create(
'regex_key_one: "/.*value.*/" AND key_two: "value"',
)
Expand Down

0 comments on commit 7a2ca1f

Please sign in to comment.