Search your posts with multiple keywords

main
Bob Mottram 2020-04-11 14:30:54 +01:00
parent 70443f4d04
commit f556c69ea0
1 changed files with 11 additions and 2 deletions

View File

@ -743,14 +743,23 @@ def searchBoxPosts(baseDir: str, nickname: str, domain: str,
return []
searchStr = searchStr.strip()
if '+' in searchStr:
searchWords = searchStr.split('+')
for index in range(len(searchWords)):
searchWords[index] = searchWords[index].strip()
else:
searchWords = [searchStr]
res = []
for root, dirs, fnames in os.walk(path):
for fname in fnames:
filePath = os.path.join(root, fname)
with open(filePath, 'r') as postFile:
data = postFile.read()
if searchStr not in data:
continue
for keyword in searchWords:
if keyword not in data:
continue
res.append(filePath)
if len(res) >= maxResults: