>>> import os
>>> import concurrent.futures
>>> import re
>>>
>>> def search_files(keyword, directory, ignored_extensions=None):
... results = []
...
>>> if ignored_extensions is None:
File "<stdin>", line 1
if ignored_extensions is None:
IndentationError: unexpected indent
>>> ignored_extensions = set()
File "<stdin>", line 1
ignored_extensions = set()
IndentationError: unexpected indent
>>>
>>> pattern = re.compile(f'({keyword})', re.IGNORECASE)
File "<stdin>", line 1
pattern = re.compile(f'({keyword})', re.IGNORECASE)
IndentationError: unexpected indent
>>>
>>> def search(file_path):
File "<stdin>", line 1
def search(file_path):
IndentationError: unexpected indent
>>> try:
File "<stdin>", line 1
try:
IndentationError: unexpected indent
>>> with open(file_path, 'r', encoding='utf-8') as file:
File "<stdin>", line 1
with open(file_path, 'r', encoding='utf-8') as file:
IndentationError: unexpected indent
>>> content = file.read()
File "<stdin>", line 1
content = file.read()
IndentationError: unexpected indent
>>> matches = re.finditer(pattern, content)
File "<stdin>", line 1
matches = re.finditer(pattern, content)
IndentationError: unexpected indent
>>> for match in matches:
File "<stdin>", line 1
for match in matches:
IndentationError: unexpected indent
>>> start = max(0, match.start() - 10)
File "<stdin>", line 1
start = max(0, match.start() - 10)
IndentationError: unexpected indent
>>> end = min(len(content), match.end() + 10)
File "<stdin>", line 1
end = min(len(content), match.end() + 10)
IndentationError: unexpected indent
>>> matched_text = content[start:end]
File "<stdin>", line 1
matched_text = content[start:end]
IndentationError: unexpected indent
>>> results.append((file_path, matched_text))
File "<stdin>", line 1
results.append((file_path, matched_text))
IndentationError: unexpected indent
>>> except (IOError, OSError):
File "<stdin>", line 1
except (IOError, OSError):
IndentationError: unexpected indent
>>> pass
File "<stdin>", line 1
pass
IndentationError: unexpected indent
>>>
>>> with concurrent.futures.ThreadPoolExecutor() as executor:
File "<stdin>", line 1
with concurrent.futures.ThreadPoolExecutor() as executor:
IndentationError: unexpected indent
>>> futures = []
File "<stdin>", line 1
futures = []
IndentationError: unexpected indent
>>> for root, _, files in os.walk(directory):
File "<stdin>", line 1
for root, _, files in os.walk(directory):
IndentationError: unexpected indent
>>> for file_name in files:
File "<stdin>", line 1
for file_name in files:
IndentationError: unexpected indent
>>> _, extension = os.path.splitext(file_name)
File "<stdin>", line 1
_, extension = os.path.splitext(file_name)
IndentationError: unexpected indent
>>> if extension.lower() in ignored_extensions:
File "<stdin>", line 1
if extension.lower() in ignored_extensions:
IndentationError: unexpected indent
>>> continue
File "<stdin>", line 1
continue
IndentationError: unexpected indent
>>> file_path = os.path.join(root, file_name)
File "<stdin>", line 1
file_path = os.path.join(root, file_name)
IndentationError: unexpected indent
>>> futures.append(executor.submit(search, file_path))
File "<stdin>", line 1
futures.append(executor.submit(search, file_path))
IndentationError: unexpected indent
>>>
>>> for future in concurrent.futures.as_completed(futures):
File "<stdin>", line 1
for future in concurrent.futures.as_completed(futures):
IndentationError: unexpected indent
>>> pass
File "<stdin>", line 1
pass
IndentationError: unexpected indent
>>>
>>> return results
File "<stdin>", line 1
return results
IndentationError: unexpected indent