PyGithub - how to get contents of the subfolder in the repo

I am trying to get contents of the subfolder "github" in a given github repository. This does not seem to work.

repo = g.get_repo("PyGithub/PyGithub")
contents = repo.get_contents("github")
while len(contents) > 1:
    file_content = contents.pop(0)
    if file_content.type == "dir":
        contents.extend(repo.get_contents(file_content.path))
    else:
        print(file_content)

Answers

The code snippet works just fine:

enter image description here

What errors are you getting?

Posted on by Anonymous

Relevant tags