mirror of https://gitlab.com/bashrc2/epicyon
Search your posts with multiple keywords
parent
70443f4d04
commit
f556c69ea0
13
utils.py
13
utils.py
|
@ -743,14 +743,23 @@ def searchBoxPosts(baseDir: str, nickname: str, domain: str,
|
||||||
return []
|
return []
|
||||||
searchStr = searchStr.strip()
|
searchStr = searchStr.strip()
|
||||||
|
|
||||||
|
if '+' in searchStr:
|
||||||
|
searchWords = searchStr.split('+')
|
||||||
|
for index in range(len(searchWords)):
|
||||||
|
searchWords[index] = searchWords[index].strip()
|
||||||
|
else:
|
||||||
|
searchWords = [searchStr]
|
||||||
|
|
||||||
res = []
|
res = []
|
||||||
for root, dirs, fnames in os.walk(path):
|
for root, dirs, fnames in os.walk(path):
|
||||||
for fname in fnames:
|
for fname in fnames:
|
||||||
filePath = os.path.join(root, fname)
|
filePath = os.path.join(root, fname)
|
||||||
with open(filePath, 'r') as postFile:
|
with open(filePath, 'r') as postFile:
|
||||||
data = postFile.read()
|
data = postFile.read()
|
||||||
if searchStr not in data:
|
|
||||||
continue
|
for keyword in searchWords:
|
||||||
|
if keyword not in data:
|
||||||
|
continue
|
||||||
|
|
||||||
res.append(filePath)
|
res.append(filePath)
|
||||||
if len(res) >= maxResults:
|
if len(res) >= maxResults:
|
||||||
|
|
Loading…
Reference in New Issue