Skip to content

Commit b82d08b

Browse files
committed
chg: [tracker regex] improve perf
1 parent af73a12 commit b82d08b

File tree

2 files changed

+8
-5
lines changed

2 files changed

+8
-5
lines changed

bin/modules/Global.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,8 +138,11 @@ def compute(self, message, r_result=False): # TODO move OBJ ID sanitization to i
138138
self.add_message_to_queue(obj=self.obj, queue='Images', message=message)
139139
elif self.obj.type == 'title':
140140
self.add_message_to_queue(obj=self.obj, queue='Titles', message=message)
141+
elif self.obj.type == 'file-name':
142+
pass
141143
else:
142144
self.logger.critical(f"Empty obj: {self.obj} {message} not processed")
145+
return None
143146

144147
# Trackers
145148
if self.obj.type in get_objects_tracked():

bin/trackers/Tracker_Regex.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -70,11 +70,11 @@ def compute(self, message):
7070
return None
7171

7272
content = obj.get_content()
73-
74-
for dict_regex in self.tracked_regexs[obj_type]:
75-
matches = self.regex_finditer(dict_regex['regex'], obj_id, content)
76-
if matches:
77-
self.new_tracker_found(dict_regex['tracked'], 'regex', obj, matches)
73+
if content:
74+
for dict_regex in self.tracked_regexs[obj_type]:
75+
matches = self.regex_finditer(dict_regex['regex'], obj_id, content)
76+
if matches:
77+
self.new_tracker_found(dict_regex['tracked'], 'regex', obj, matches)
7878

7979
def extract_matches(self, re_matches, limit=500, lines=5):
8080
matches = []

0 commit comments

Comments
 (0)