Using | to have more than one searches in the same time.

This commit is contained in:
Victorious Children Studios 2023-12-22 00:10:57 +02:00
parent cb7e89be29
commit 11a884d9d4
3 changed files with 28 additions and 25 deletions

View file

@ -174,3 +174,23 @@ def alphanum_key(s):
def sort_nicely(l):
l.sort(key=alphanum_key)
def found(t, q):
# Function for search.
# Making sure that both text and query are not case sensetive.
t = t.lower()
q = q.lower()
ors = []
for c in q.split("|"): # OR
f = True
for w in c.split(" "): # AND
if w not in t:
f = False
ors.append(f)
return any(ors)

View file

@ -30,6 +30,7 @@ from project_manager import pm_project
#UI modules
from UI import UI_elements
from UI import UI_color
from UI import UI_math
from studio import story
from studio import analytics
@ -794,8 +795,6 @@ def prompt_layer(win, call):
ActiveTab = win.current["remote-folder-data"][cur]["active_tab"]
DisplayList = win.current["remote-folder-data"][cur][ActiveTab]
# if win.text["http_client_search"]["text"]:
# DisplayList = fnmatch.filter(DisplayList, win.text["http_client_search"]["text"])
try:
for f in DisplayList:
@ -805,24 +804,8 @@ def prompt_layer(win, call):
if fdata.get("finished"):
continue
# found = True
# if win.text["http_client_search"]["text"]:
# for word in win.text["http_client_search"]["text"].split(" "):
# if word.lower() not in f.lower():
# found = False
# continue
if win.text["http_client_search"]["text"]:
searchtext = win.text["http_client_search"]["text"]
rthings = "[]*?!"
found = False
for thing in rthings:
if thing in searchtext:
found = True
break
if not found:
searchtext = "*"+searchtext+"*"
if not fnmatch.fnmatch(f, searchtext):
continue
if win.text["http_client_search"]["text"] and not UI_math.found(f, win.text["http_client_search"]["text"]):
continue
ticon = "unchecked"
if fdata.get("to_download", True):

View file

@ -231,7 +231,7 @@ def layer(win, call):
######################## FILTERING STARTS ##########################
okay = True
okay = UI_math.found(filename, win.text["file_select_search"]["text"])
# Remove all _backup files
if "_backup" in filename:
@ -240,10 +240,10 @@ def layer(win, call):
# By search
for stuff in win.text["file_select_search"]["text"].split(" "):
if stuff:
if stuff.lower() not in filename.lower():
okay = False
# for stuff in win.text["file_select_search"]["text"].split(" "):
# if stuff:
# if stuff.lower() not in filename.lower():
# okay = False
# By folder
folderfound = False