Simple match

main
Bob Mottram 2020-04-11 14:14:53 +01:00
parent 82c859852f
commit 1831af8226
1 changed files with 10 additions and 6 deletions

View File

@ -740,17 +740,21 @@ def searchBoxPosts(baseDir: str, nickname: str, domain: str,
""" """
path = baseDir + '/accounts/' + nickname + '@' + domain + '/' + boxName path = baseDir + '/accounts/' + nickname + '@' + domain + '/' + boxName
if not os.path.isdir(path): if not os.path.isdir(path):
print('SEARCH: directory does not exist ' + path)
return [] return []
regObj = re.compile(searchRegex) searchRegex = searchRegex.strip()
# regObj = re.compile(searchRegex)
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 file: with open(filePath, 'r') as postFile:
data = file.read() data = postFile.read()
if not regObj.match(data): # if not regObj.match(data):
continue if searchRegex not in data:
continue
res.append(filePath) res.append(filePath)
if len(res) >= maxResults: if len(res) >= maxResults:
return res return res