Python script to get all the programming languages in a GitHub organization and return a total number of repos using the programming language.
Hard requirements: ๐
- Make sure you know Python 3.0 or older.
- Make sure you have a GitHub Personal Access Token with the
read:org
andrepo:status
permissions. ๐ - Install the Python dependencies:
pip install requests json
GITHUB_TOKEN
The GitHub token requirements for this script are as follows:
The token must have the read:org permission. This permission is required to read the organization's repositories. The token must have the repo:status permission. This permission is required to get the commit status of the repositories.
Once you have a GitHub token with the required permissions, you can set it as an environment variable on your machine. This will allow you to run the script without having to specify the token each time.
To set the token as an environment variable, you can use the following command:
export GITHUB_TOKEN=<your_token>
Once you have set the token as an environment variable, you can run the script by passing the name of the GitHub organization to the main() function.
Usage: ๐ป
python get_org_languages.py <organization_name>
Example:
python get_org_languages.py my-organization
Output: ๐
Programming languages used in `organization-name`:
Ruby: 266071
JavaScript: 311370
CSS: 135455
HTML: 30939
Shell: 54565
C: 1586069
Vim Script: 58
Python: 11074
Dockerfile: 1143
Perl: 363
Raku: 42
CoffeeScript: 8368
License: โ๏ธ
MIT License
Contributing: ๐ค
If you have any suggestions or bug reports, please feel free to write a comment here.
Additional information: โน๏ธ
This script uses the GitHub API to get all the repositories in the organization and then gets the programming languages used in each repository. The script returns a dictionary of programming languages, with the total number of bytes of code written in each language across all repositories in the organization.
This script can be used to get a better understanding of the programming languages used in an organization. This information can be used to make decisions about which programming languages to support and which programming languages to train employees in.
I hope you like this.
Script doesn't seem to accept arguments from the command line. You can use
sys.argv
for that. And it gives an error on line 36: