Skip to content

Commit

Permalink
searching improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
piotrj committed Jan 1, 2024
1 parent 1b28199 commit dddc4c4
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 29 deletions.
34 changes: 13 additions & 21 deletions src/librer.py
Original file line number Diff line number Diff line change
Expand Up @@ -1508,9 +1508,9 @@ def ver_number(var):
self.find_filename_glob_entry = Entry(find_filename_frame,textvariable=self.find_name_glob_var,validate="key")
self.find_filename_fuzz_entry = Entry(find_filename_frame,textvariable=self.find_name_fuzz_var,validate="key")

self.find_filename_regexp_entry.bind("<KeyPress>", self.find_mod_keypress)
self.find_filename_glob_entry.bind("<KeyPress>", self.find_mod_keypress)
self.find_filename_fuzz_entry.bind("<KeyPress>", self.find_mod_keypress)
self.find_filename_regexp_entry.bind("<KeyRelease>", self.find_mod_keypress)
self.find_filename_glob_entry.bind("<KeyRelease>", self.find_mod_keypress)
self.find_filename_fuzz_entry.bind("<KeyRelease>", self.find_mod_keypress)

self.find_filename_regexp_entry.grid(row=2, column=1, sticky='we',padx=4,pady=4)
self.find_filename_glob_entry.grid(row=3, column=1, sticky='we',padx=4,pady=4)
Expand All @@ -1524,7 +1524,7 @@ def ver_number(var):
self.find_filename_fuzzy_threshold_lab.grid(row=4, column=2, sticky='wens',padx=4,pady=4)
self.find_filename_fuzzy_threshold_entry.grid(row=4, column=3, sticky='wens',padx=4,pady=4)

self.find_filename_fuzzy_threshold_entry.bind("<KeyPress>", self.find_mod_keypress)
self.find_filename_fuzzy_threshold_entry.bind("<KeyRelease>", self.find_mod_keypress)

self.widget_tooltip(regexp_radio_name,regexp_tooltip + regexp_tooltip_name)
self.widget_tooltip(self.find_filename_regexp_entry,regexp_tooltip + regexp_tooltip_name)
Expand All @@ -1551,9 +1551,9 @@ def ver_number(var):
self.find_cd_glob_entry = Entry(find_cd_frame,textvariable=self.find_cd_glob_var,validate="key")
self.find_cd_fuzz_entry = Entry(find_cd_frame,textvariable=self.find_cd_fuzz_var,validate="key")

self.find_cd_regexp_entry.bind("<KeyPress>", self.find_mod_keypress)
self.find_cd_glob_entry.bind("<KeyPress>", self.find_mod_keypress)
self.find_cd_fuzz_entry.bind("<KeyPress>", self.find_mod_keypress)
self.find_cd_regexp_entry.bind("<KeyRelease>", self.find_mod_keypress)
self.find_cd_glob_entry.bind("<KeyRelease>", self.find_mod_keypress)
self.find_cd_fuzz_entry.bind("<KeyRelease>", self.find_mod_keypress)

self.find_cd_regexp_entry.grid(row=4, column=1, sticky='we',padx=4,pady=4)
self.find_cd_glob_entry.grid(row=5, column=1, sticky='we',padx=4,pady=4)
Expand All @@ -1567,7 +1567,7 @@ def ver_number(var):
self.find_cd_fuzzy_threshold_lab.grid(row=6, column=2, sticky='wens',padx=4,pady=4)
self.find_cd_fuzzy_threshold_entry.grid(row=6, column=3, sticky='wens',padx=4,pady=4)

self.find_cd_fuzzy_threshold_entry.bind("<KeyPress>", self.find_mod_keypress)
self.find_cd_fuzzy_threshold_entry.bind("<KeyRelease>", self.find_mod_keypress)

self.widget_tooltip(regexp_radio_cd,regexp_tooltip + regexp_tooltip_cd)
self.widget_tooltip(self.find_cd_regexp_entry,regexp_tooltip + regexp_tooltip_cd)
Expand Down Expand Up @@ -1596,8 +1596,8 @@ def validate_size_str(val):
find_size_max_entry=Entry(find_size_frame,textvariable=self.find_size_max_var)
find_size_max_entry.grid(row=0, column=3, sticky='we',padx=4,pady=4)

find_size_min_entry.bind("<KeyPress>", self.find_mod_keypress)
find_size_max_entry.bind("<KeyPress>", self.find_mod_keypress)
find_size_min_entry.bind("<KeyRelease>", self.find_mod_keypress)
find_size_max_entry.bind("<KeyRelease>", self.find_mod_keypress)

size_tooltip = 'Integer value [in bytes] or integer with unit.\nLeave the value blank to ignore this criterion.\n\nexamples:\n399\n100B\n125kB\n10MB'
self.widget_tooltip(find_size_min_entry,size_tooltip)
Expand All @@ -1616,8 +1616,8 @@ def validate_size_str(val):
find_modtime_max_entry=Entry(find_modtime_frame,textvariable=self.find_modtime_max_var)
find_modtime_max_entry.grid(row=0, column=3, sticky='we',padx=4,pady=4)

find_modtime_min_entry.bind("<KeyPress>", self.find_mod_keypress)
find_modtime_max_entry.bind("<KeyPress>", self.find_mod_keypress)
find_modtime_min_entry.bind("<KeyRelease>", self.find_mod_keypress)
find_modtime_max_entry.bind("<KeyRelease>", self.find_mod_keypress)

time_toltip = 'Date and time in the format below.\nLeave the value blank to ignore this criterion.\n\nexamples:\n2023-12-14 22:21:20\n2023-12-14 22:21\n2023-12-14\n2023-12'
self.widget_tooltip(find_modtime_min_entry,time_toltip)
Expand Down Expand Up @@ -2394,7 +2394,6 @@ def find_items(self):
self_progress_dialog_on_find_update_lab_image = self_progress_dialog_on_find.update_lab_image
self_get_hg_ico = self.get_hg_ico

last_res_check = 0
librer_core_files_search_quant = librer_core.files_search_quant
fnumber_librer_core_files_search_quant = fnumber(librer_core_files_search_quant)
fnumber_records_len = fnumber(records_len)
Expand All @@ -2405,12 +2404,7 @@ def find_items(self):
######################################################################################

change0 = self_progress_dialog_on_find_update_lab_text(0,librer_core.info_line)
if now>last_res_check+1:
#change3 = self_progress_dialog_on_find_update_lab_text(3,f'Found Files: {fnumber(librer_core.find_res_quant)} ({fnumber(len(librer_core.search_record_ref.find_results))})' )
change3 = self_progress_dialog_on_find_update_lab_text(3,f'Found Files: {fnumber(librer_core.find_res_quant)}' )
last_res_check=now
else:
change3 = False
change3 = self_progress_dialog_on_find_update_lab_text(3,f'Found Files: {fnumber(librer_core.find_res_quant)}' )

curr_files = librer_core.total_search_progress

Expand All @@ -2424,8 +2418,6 @@ def find_items(self):

if self.action_abort:
librer_core.abort()
#librer_core.search_record_ref.abort()
#break

if change0 or change3 or prev_curr_files != curr_files:
prev_curr_files = curr_files
Expand Down
14 changes: 6 additions & 8 deletions src/record.py
Original file line number Diff line number Diff line change
Expand Up @@ -185,13 +185,13 @@ def print_info(*args):
if res := test_regexp(name_regexp):
exit(res)

name_func_to_call = lambda x : search(name_regexp,x)
name_func_to_call = lambda x : re_compile(name_regexp).search(x)
name_search_kind='regexp'
elif name_glob:
if name_case_sens:
name_func_to_call = lambda x : re_compile(translate(name_glob)).match(x)
name_func_to_call = lambda x : re_compile(translate(name_glob)).search(x)
else:
name_func_to_call = lambda x : re_compile(translate(name_glob), IGNORECASE).match(x)
name_func_to_call = lambda x : re_compile(translate(name_glob), IGNORECASE).search(x)
name_search_kind='glob'
elif name_fuzzy:
name_func_to_call = lambda x : bool(SequenceMatcher(None, name_fuzzy, x).ratio()>file_fuzzy_threshold)
Expand Down Expand Up @@ -219,21 +219,19 @@ def print_info(*args):
cd_search_kind='regexp'
if res := test_regexp(cd_regexp):
exit(res)
cd_func_to_call = lambda x : re_search(cd_regexp,x)
cd_func_to_call = lambda x : re_compile(cd_regexp).search(x)

elif cd_glob:
custom_data_needed=True
cd_search_kind='glob'
if cd_case_sens:
#cd_func_to_call = lambda x : fnmatch(x,cd_regexp)
cd_func_to_call = lambda x : re_compile(translate(cd_glob)).match(x)
cd_func_to_call = lambda x : re_compile(translate(cd_glob)).search(x)
else:
cd_func_to_call = lambda x : re_compile(translate(cd_glob), IGNORECASE).match(x)
cd_func_to_call = lambda x : re_compile(translate(cd_glob), IGNORECASE).search(x)
elif cd_fuzzy:
custom_data_needed=True
cd_search_kind='fuzzy'
cd_func_to_call = lambda x : bool(SequenceMatcher(None,cd_fuzzy, x).ratio()>cd_fuzzy_threshold)
#cd_fuzzy_threshold = float(cd_fuzzy_threshold) if find_cd_search_kind == 'fuzzy' else 0
elif cd_without:
cd_search_kind='without'
cd_func_to_call = None
Expand Down

0 comments on commit dddc4c4

Please sign in to comment.