Skip to content

Commit dddc4c4

Browse files
author
piotrj
committed
searching improvements
1 parent 1b28199 commit dddc4c4

File tree

2 files changed

+19
-29
lines changed

2 files changed

+19
-29
lines changed

src/librer.py

+13-21
Original file line numberDiff line numberDiff line change
@@ -1508,9 +1508,9 @@ def ver_number(var):
15081508
self.find_filename_glob_entry = Entry(find_filename_frame,textvariable=self.find_name_glob_var,validate="key")
15091509
self.find_filename_fuzz_entry = Entry(find_filename_frame,textvariable=self.find_name_fuzz_var,validate="key")
15101510

1511-
self.find_filename_regexp_entry.bind("<KeyPress>", self.find_mod_keypress)
1512-
self.find_filename_glob_entry.bind("<KeyPress>", self.find_mod_keypress)
1513-
self.find_filename_fuzz_entry.bind("<KeyPress>", self.find_mod_keypress)
1511+
self.find_filename_regexp_entry.bind("<KeyRelease>", self.find_mod_keypress)
1512+
self.find_filename_glob_entry.bind("<KeyRelease>", self.find_mod_keypress)
1513+
self.find_filename_fuzz_entry.bind("<KeyRelease>", self.find_mod_keypress)
15141514

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

1527-
self.find_filename_fuzzy_threshold_entry.bind("<KeyPress>", self.find_mod_keypress)
1527+
self.find_filename_fuzzy_threshold_entry.bind("<KeyRelease>", self.find_mod_keypress)
15281528

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

1554-
self.find_cd_regexp_entry.bind("<KeyPress>", self.find_mod_keypress)
1555-
self.find_cd_glob_entry.bind("<KeyPress>", self.find_mod_keypress)
1556-
self.find_cd_fuzz_entry.bind("<KeyPress>", self.find_mod_keypress)
1554+
self.find_cd_regexp_entry.bind("<KeyRelease>", self.find_mod_keypress)
1555+
self.find_cd_glob_entry.bind("<KeyRelease>", self.find_mod_keypress)
1556+
self.find_cd_fuzz_entry.bind("<KeyRelease>", self.find_mod_keypress)
15571557

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

1570-
self.find_cd_fuzzy_threshold_entry.bind("<KeyPress>", self.find_mod_keypress)
1570+
self.find_cd_fuzzy_threshold_entry.bind("<KeyRelease>", self.find_mod_keypress)
15711571

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

1599-
find_size_min_entry.bind("<KeyPress>", self.find_mod_keypress)
1600-
find_size_max_entry.bind("<KeyPress>", self.find_mod_keypress)
1599+
find_size_min_entry.bind("<KeyRelease>", self.find_mod_keypress)
1600+
find_size_max_entry.bind("<KeyRelease>", self.find_mod_keypress)
16011601

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

1619-
find_modtime_min_entry.bind("<KeyPress>", self.find_mod_keypress)
1620-
find_modtime_max_entry.bind("<KeyPress>", self.find_mod_keypress)
1619+
find_modtime_min_entry.bind("<KeyRelease>", self.find_mod_keypress)
1620+
find_modtime_max_entry.bind("<KeyRelease>", self.find_mod_keypress)
16211621

16221622
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'
16231623
self.widget_tooltip(find_modtime_min_entry,time_toltip)
@@ -2394,7 +2394,6 @@ def find_items(self):
23942394
self_progress_dialog_on_find_update_lab_image = self_progress_dialog_on_find.update_lab_image
23952395
self_get_hg_ico = self.get_hg_ico
23962396

2397-
last_res_check = 0
23982397
librer_core_files_search_quant = librer_core.files_search_quant
23992398
fnumber_librer_core_files_search_quant = fnumber(librer_core_files_search_quant)
24002399
fnumber_records_len = fnumber(records_len)
@@ -2405,12 +2404,7 @@ def find_items(self):
24052404
######################################################################################
24062405

24072406
change0 = self_progress_dialog_on_find_update_lab_text(0,librer_core.info_line)
2408-
if now>last_res_check+1:
2409-
#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))})' )
2410-
change3 = self_progress_dialog_on_find_update_lab_text(3,f'Found Files: {fnumber(librer_core.find_res_quant)}' )
2411-
last_res_check=now
2412-
else:
2413-
change3 = False
2407+
change3 = self_progress_dialog_on_find_update_lab_text(3,f'Found Files: {fnumber(librer_core.find_res_quant)}' )
24142408

24152409
curr_files = librer_core.total_search_progress
24162410

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

24252419
if self.action_abort:
24262420
librer_core.abort()
2427-
#librer_core.search_record_ref.abort()
2428-
#break
24292421

24302422
if change0 or change3 or prev_curr_files != curr_files:
24312423
prev_curr_files = curr_files

src/record.py

+6-8
Original file line numberDiff line numberDiff line change
@@ -185,13 +185,13 @@ def print_info(*args):
185185
if res := test_regexp(name_regexp):
186186
exit(res)
187187

188-
name_func_to_call = lambda x : search(name_regexp,x)
188+
name_func_to_call = lambda x : re_compile(name_regexp).search(x)
189189
name_search_kind='regexp'
190190
elif name_glob:
191191
if name_case_sens:
192-
name_func_to_call = lambda x : re_compile(translate(name_glob)).match(x)
192+
name_func_to_call = lambda x : re_compile(translate(name_glob)).search(x)
193193
else:
194-
name_func_to_call = lambda x : re_compile(translate(name_glob), IGNORECASE).match(x)
194+
name_func_to_call = lambda x : re_compile(translate(name_glob), IGNORECASE).search(x)
195195
name_search_kind='glob'
196196
elif name_fuzzy:
197197
name_func_to_call = lambda x : bool(SequenceMatcher(None, name_fuzzy, x).ratio()>file_fuzzy_threshold)
@@ -219,21 +219,19 @@ def print_info(*args):
219219
cd_search_kind='regexp'
220220
if res := test_regexp(cd_regexp):
221221
exit(res)
222-
cd_func_to_call = lambda x : re_search(cd_regexp,x)
222+
cd_func_to_call = lambda x : re_compile(cd_regexp).search(x)
223223

224224
elif cd_glob:
225225
custom_data_needed=True
226226
cd_search_kind='glob'
227227
if cd_case_sens:
228-
#cd_func_to_call = lambda x : fnmatch(x,cd_regexp)
229-
cd_func_to_call = lambda x : re_compile(translate(cd_glob)).match(x)
228+
cd_func_to_call = lambda x : re_compile(translate(cd_glob)).search(x)
230229
else:
231-
cd_func_to_call = lambda x : re_compile(translate(cd_glob), IGNORECASE).match(x)
230+
cd_func_to_call = lambda x : re_compile(translate(cd_glob), IGNORECASE).search(x)
232231
elif cd_fuzzy:
233232
custom_data_needed=True
234233
cd_search_kind='fuzzy'
235234
cd_func_to_call = lambda x : bool(SequenceMatcher(None,cd_fuzzy, x).ratio()>cd_fuzzy_threshold)
236-
#cd_fuzzy_threshold = float(cd_fuzzy_threshold) if find_cd_search_kind == 'fuzzy' else 0
237235
elif cd_without:
238236
cd_search_kind='without'
239237
cd_func_to_call = None

0 commit comments

Comments
 (0)