Fetching GitHub submodules

Yesterday, I took the first step towards fetching information from GitHub. Today added code for checking if the repository contains submodules and will return that instance. Then we may use it to access submodule information like name, submodule_git_url etc.

See: https://developer.github.com/v3/repos/contents/#response-if-content-is-a-submodule

I used x.raw_data.get(typeto check if x a submodule or not. Actually raw_data contains many other attributes (like html_url, git_url, name, sha, type etc.) that provide additional info. about the instance itself. And for fetching the original repository link, I used: x.raw_data.get(submodule_git_url).

Here is the code for the particular file: https://github.com/mandeeps708/Github-API-Fun/blob/master/get-submodules.py

More about repository methods in PyGithub: http://pygithub.github.io/PyGithub/v1/github_objects/Repository.html

Rate Limit: https://developer.github.com/v3/#rate-limiting

For requests using Basic Authentication or OAuth, you can make up to 5,000 requests per hour. For unauthenticated requests, the rate limit allows you to make up to 60 requests per hour. Unauthenticated requests are associated with your IP address, and not the user making requests.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s