Skip to content

Commit 02845b4

Browse files
committed
fixes-in-code-quality
1 parent c8accaa commit 02845b4

File tree

2 files changed

+17
-17
lines changed

2 files changed

+17
-17
lines changed

translator/app/translator/platforms/logrhythm_axon/mapping.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ def __init__(self, default_source: Optional[dict] = None):
1010
def is_suitable(self) -> bool:
1111
return True
1212

13-
def __str__(self):
13+
def __str__(self) -> str:
1414
return "general_information.log_source.type_name"
1515

1616

translator/app/translator/platforms/logrhythm_axon/renders/logrhythm_axon_query.py

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
from typing import Union
2020

2121
from app.translator.const import DEFAULT_VALUE_TYPE
22-
from app.translator.core.custom_types.tokens import LogicalOperatorType
22+
from app.translator.core.custom_types.tokens import LogicalOperatorType, OperatorType
2323
from app.translator.core.exceptions.core import StrictPlatformException
2424
from app.translator.core.exceptions.render import BaseRenderException
2525
from app.translator.core.mapping import LogSourceSignature, SourceMapping
@@ -43,36 +43,36 @@ class LogRhythmAxonFieldValue(BaseQueryFieldValue):
4343
escape_manager = microsoft_escape_manager
4444

4545
def __is_complex_regex(self, regex: str) -> bool:
46-
regex_items = ("[", "]", "(", ")", "{", "}", "+", "?", "^", "$", "\d", "\w", "\s", "-")
47-
return any(v in regex_items for v in regex)
46+
regex_items = ("[", "]", "(", ")", "{", "}", "+", "?", "^", "$", "\\d", "\\w", "\\s", "-")
47+
return any(v in regex for v in regex_items)
4848

49-
def __is_regex(self, value: str) -> bool:
50-
regex_items = ("", "[", "]", "(", ")", "{", "}", "*", "+", "?", "^", "$", "|", ".", "\d", "\w", "\s", "\\", "-")
51-
return any(v in regex_items for v in value)
49+
def __is_contain_regex_items(self, value: str) -> bool:
50+
regex_items = ("[", "]", "(", ")", "{", "}", "*", "+", "?", "^", "$", "|", ".", "\\d", "\\w", "\\s", "\\", "-")
51+
return any(v in value for v in regex_items)
5252

53-
def __regex_to_str_list(self, value: Union[int, str]) -> list[list[str]]: # noqa
53+
def __regex_to_str_list(self, value: Union[int, str]) -> list[list[str]]: # noqa: PLR0912
5454
value_groups = []
5555

5656
stack = [] # [(element: str, escaped: bool)]
5757

58-
for index in range(len(value)):
59-
if value[index] == "\\":
58+
for char in value:
59+
if char == "\\":
6060
if stack and stack[-1][0] == "\\" and stack[-1][1] is False:
6161
stack.pop()
62-
stack.append((value[index], True))
62+
stack.append((char, True))
6363
else:
6464
stack.append(("\\", False))
65-
elif value[index] == "|":
65+
elif char == "|":
6666
if stack and stack[-1][0] == "\\" and stack[-1][1] is False:
6767
stack.pop()
68-
stack.append((value[index], True))
68+
stack.append((char, True))
6969
elif stack:
7070
value_groups.append("".join(element[0] for element in stack))
7171
stack = []
7272
else:
73-
stack.append((value[index], False))
73+
stack.append((char, False))
7474
if stack:
75-
value_groups.append("".join(element[0] for element in stack if element[0] != '\\' or element[-1] is True))
75+
value_groups.append("".join(element[0] for element in stack if element[0] != "\\" or element[-1] is True))
7676

7777
joined_components = []
7878
for value_group in value_groups:
@@ -133,7 +133,7 @@ def not_equal_modifier(self, field: str, value: DEFAULT_VALUE_TYPE) -> str:
133133
def contains_modifier(self, field: str, value: DEFAULT_VALUE_TYPE) -> str:
134134
if isinstance(value, list):
135135
return f"({self.or_token.join(self.contains_modifier(field=field, value=v) for v in value)})"
136-
if isinstance(value, str) and self.__is_regex(value):
136+
if isinstance(value, str) and self.__is_contain_regex_items(value):
137137
if self.__is_complex_regex(value):
138138
raise LogRhythmRegexRenderException
139139
values = self.__regex_to_str_list(value)
@@ -194,7 +194,7 @@ def apply_token(self, token: Union[FieldValue, Keyword, Identifier], source_mapp
194194
try:
195195
return self.field_value_map.apply_field_value(
196196
field="general_information.raw_message",
197-
operator=Identifier(token_type="contains"),
197+
operator=Identifier(token_type=OperatorType.CONTAINS),
198198
value=token.value,
199199
)
200200
except LogRhythmRegexRenderException as exc:

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy