Skip to content

Commit e0f19bc

Browse files
filter markdown files before parsing when building kb
1 parent 9b8adf7 commit e0f19bc

File tree

1 file changed

+10
-7
lines changed

1 file changed

+10
-7
lines changed

app/get_knowledge_base.py

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -200,14 +200,17 @@ def parse_cli_markdown(file_path):
200200

201201
def recursive_parse_directory(root_dir):
202202
""" Recursively parses all markdown files in the directory. """
203-
for dirpath, dirnames, filenames in os.walk(root_dir):
203+
paths = []
204+
for dirpath, _dirnames, filenames in os.walk(root_dir):
204205
for filename in filenames:
205-
if filename.lower().endswith('.md') or filename.lower().endswith('.mdx'):
206-
file_path = os.path.join(dirpath, filename)
207-
if 'cli' in dirpath.lower() or 'cli' in filename.lower():
208-
parse_cli_markdown(file_path)
209-
else:
210-
parse_markdown_file_to_json(file_path)
206+
lower_filename = filename.lower()
207+
if lower_filename.endswith('.md') or lower_filename.endswith('.mdx'):
208+
paths.append(os.path.join(dirpath, filename))
209+
for file_path in paths:
210+
if 'cli' in dirpath.lower() or 'cli' in filename.lower():
211+
parse_cli_markdown(file_path)
212+
else:
213+
parse_markdown_file_to_json(file_path)
211214

212215
if __name__ == "__main__":
213216
setup_repositories()

0 commit comments

Comments
 (0)