Using | to have more than one searches in the same time.
This commit is contained in:
parent
cb7e89be29
commit
11a884d9d4
|
@ -174,3 +174,23 @@ def alphanum_key(s):
|
||||||
def sort_nicely(l):
|
def sort_nicely(l):
|
||||||
l.sort(key=alphanum_key)
|
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)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -30,6 +30,7 @@ from project_manager import pm_project
|
||||||
#UI modules
|
#UI modules
|
||||||
from UI import UI_elements
|
from UI import UI_elements
|
||||||
from UI import UI_color
|
from UI import UI_color
|
||||||
|
from UI import UI_math
|
||||||
|
|
||||||
from studio import story
|
from studio import story
|
||||||
from studio import analytics
|
from studio import analytics
|
||||||
|
@ -794,8 +795,6 @@ def prompt_layer(win, call):
|
||||||
ActiveTab = win.current["remote-folder-data"][cur]["active_tab"]
|
ActiveTab = win.current["remote-folder-data"][cur]["active_tab"]
|
||||||
DisplayList = win.current["remote-folder-data"][cur][ActiveTab]
|
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:
|
try:
|
||||||
for f in DisplayList:
|
for f in DisplayList:
|
||||||
|
@ -805,24 +804,8 @@ def prompt_layer(win, call):
|
||||||
if fdata.get("finished"):
|
if fdata.get("finished"):
|
||||||
continue
|
continue
|
||||||
|
|
||||||
# found = True
|
if win.text["http_client_search"]["text"] and not UI_math.found(f, win.text["http_client_search"]["text"]):
|
||||||
# if win.text["http_client_search"]["text"]:
|
continue
|
||||||
# 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
|
|
||||||
|
|
||||||
ticon = "unchecked"
|
ticon = "unchecked"
|
||||||
if fdata.get("to_download", True):
|
if fdata.get("to_download", True):
|
||||||
|
|
|
@ -231,7 +231,7 @@ def layer(win, call):
|
||||||
|
|
||||||
######################## FILTERING STARTS ##########################
|
######################## FILTERING STARTS ##########################
|
||||||
|
|
||||||
okay = True
|
okay = UI_math.found(filename, win.text["file_select_search"]["text"])
|
||||||
|
|
||||||
# Remove all _backup files
|
# Remove all _backup files
|
||||||
if "_backup" in filename:
|
if "_backup" in filename:
|
||||||
|
@ -240,10 +240,10 @@ def layer(win, call):
|
||||||
|
|
||||||
# By search
|
# By search
|
||||||
|
|
||||||
for stuff in win.text["file_select_search"]["text"].split(" "):
|
# for stuff in win.text["file_select_search"]["text"].split(" "):
|
||||||
if stuff:
|
# if stuff:
|
||||||
if stuff.lower() not in filename.lower():
|
# if stuff.lower() not in filename.lower():
|
||||||
okay = False
|
# okay = False
|
||||||
|
|
||||||
# By folder
|
# By folder
|
||||||
folderfound = False
|
folderfound = False
|
||||||
|
|
Loading…
Reference in a new issue