-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhash_event_handler.py
29 lines (23 loc) · 1.15 KB
/
hash_event_handler.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
import sys
from logger import Logger
from event import Event
from event_type import EventType
from event_handler import EventHandler
class HashEventHandler(EventHandler):
def __init__(self, use_verbose_logging):
super().__init__(use_verbose_logging)
def handle_event(self, event, num_processed_by_process_list, num_processed, total_to_process, image_models, skipped_files, append_to_be_skipped):
event_process_id = event.event_process_id
event_data = event.event_data
event_type = event.event_type
if event_type == EventType.FILE_HASHED:
image_models.append(event_data)
num_processed += 1
num_processed_by_process_list[event_process_id-1] += 1
elif event_type == EventType.SKIPPED_FILE_HASH:
if append_to_be_skipped == True:
#we want to skip any file that doesn't load properly, but we only want to write skipped_files from the "duplicates" directory to skipped_files.txt
skipped_files.append(event_data)
num_processed += 1
num_processed_by_process_list[event_process_id-1] += 1
return num_processed