in Utils/prepare_data.py [0:0]
def traverse_files_and_generate_questions(root_folder: str):
output = []
for subdir, dirs, files in os.walk(root_folder):
for file in files:
file_path = os.path.join(subdir, file)
relative_path = os.path.relpath(file_path, root_folder)
extension = file.split('.')[-1]
try:
with open(file_path, 'r', encoding='utf-8') as f:
content = f.read()
output.append(f'{relative_path}\n'
f'```{extension}\n{content}\n```\n')
print(f'Appending {relative_path}')
except UnicodeDecodeError:
print(f'Can\'t read file {file_path}, it\'s not a text file')
return "\n".join(output)