Skip to content

Commit 5bc4c39

Browse files
filter markdown files before parsing when building kb
1 parent a6a1721 commit 5bc4c39

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
@@ -199,14 +199,17 @@ def parse_cli_markdown(file_path):
199199

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

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

0 commit comments

Comments
 (0)