diff --git a/UI/UI_math.py b/UI/UI_math.py index 3d4ab66..1e53ad6 100644 --- a/UI/UI_math.py +++ b/UI/UI_math.py @@ -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) + + + diff --git a/network/http_client.py b/network/http_client.py index 7d396dc..3a0b998 100644 --- a/network/http_client.py +++ b/network/http_client.py @@ -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): diff --git a/studio/studio_file_selectLayer.py b/studio/studio_file_selectLayer.py index 49b8019..8b2f569 100644 --- a/studio/studio_file_selectLayer.py +++ b/studio/studio_file_selectLayer.py @@ -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