From fc664d5ad3eedd351da5cf27c85d2b2cf6242038 Mon Sep 17 00:00:00 2001 From: kenna-bmcdevitt Date: Mon, 26 Aug 2024 16:45:17 -0500 Subject: [PATCH] made get repo contents method work recursively --- github_searcher.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/github_searcher.py b/github_searcher.py index b4b6aea..f267379 100644 --- a/github_searcher.py +++ b/github_searcher.py @@ -55,8 +55,12 @@ class GithubSearcher(): def get_repo_contents(self, repo): try: contents = repo.get_contents("") - for content_file in contents: - print(content_file) + while contents: + file_content = contents.pop(0) + if file_content.type == "dir": + contents.extend(repo.get_contents(file_content.path)) + else: + print(file_content) return contents except GithubException as e: logging.error(f"Error getting repository contents: {e}")