github-api-tools-with-python
GitHub API scripts
Science Score: 44.0%
This score indicates how likely this project is to be science-related based on various indicators:
-
✓CITATION.cff file
Found CITATION.cff file -
✓codemeta.json file
Found codemeta.json file -
✓.zenodo.json file
Found .zenodo.json file -
○DOI references
-
○Academic publication links
-
○Committers with academic emails
-
○Institutional organization owner
-
○JOSS paper metadata
-
○Scientific vocabulary similarity
Low similarity (13.0%) to scientific vocabulary
Repository
GitHub API scripts
Basic Info
- Host: GitHub
- Owner: SixArm
- Language: Python
- Default Branch: main
- Size: 12.7 KB
Statistics
- Stars: 4
- Watchers: 2
- Forks: 0
- Open Issues: 0
- Releases: 0
Metadata Files
README.md
GitHub API tools with python
GitHub API tools to use with your own repositories.
These tools are simple and intended for learning:
Python 3 with pip3
GitHub API: https://developer.github.com/v3/
PyGitHub: https://pygithub.readthedocs.io/en/latest/introduction.html
Tools are in the directory bin:
Example
Example code that connects to GitHub and reads repo information:
```python
!/usr/bin/env python3
import os import sys from pprint import pprint import logging import json from github import Github
def githubpersonalaccesstoken(): x = os.getenv("GITHUBPERSONALACCESSTOKEN") if x is None: print("This script needs an environment variable GITHUBPERSONALACCESS_TOKEN.", file=sys.stderr) quit() return x
def githubclient(): return Github(githubpersonalaccesstoken())
GITHUBCLIENT = githubclient()
def main(): githubownerrepo = sys.argv[1] user = GITHUBCLIENT.getuser() pprint(user) repo = GITHUBCLIENT.getrepo(githubownerrepo) pprint(repo) for label in repo.getlabels(): print(f"{githubowner_repo} label:{label.name} color:{label.color}")
if name== "main": main() ```
Setup
Setup: GitHub personal access token
These scripts need to use your GitHub personal access token.
To generate your GitHub personal access token:
- Go to your profile settings tokens page at https://github.com/settings/tokens.
- Do "Generate new token".
- Type in a descriptive name, such as "repo list".
- Check the scope "repo" so you can use your token to access repositories.
- Click Generate token.
- You should see a new token such as "gpt_fe7f2bf4057de85eb638dc7356047b".
To export your GitHub personal access token:
Run:
sh
export GITHUB_PERSONAL_ACCESS_TOKEN="ghp_fe7f2bf4057de85eb638dc7356047b"
Verify:
sh
echo $GITHUB_PERSONAL_ACCESS_TOKEN
You may want to add your personal access token to your user account startup files such as .bashrc or .zshenv or similar.
Setup: Dependencies
These scripts use the Python library PyGithub.
You can install it any way you like, such as:
sh
pip3 install --upgrade PyGithub
Troubleshooting
Troubleshooting: No module named pip3
If you get an error message such as:
sh
No module named pip3
Then try to install pip3:
sh
easy_install pip3
Troubleshooting: No module named github
If you get an error message such as:
sh
ModuleNotFoundError: No module named 'github'
Then try to install using a specific python instance:
sh
python3 -m pip install --upgrade pip
python3 -m pip install PyGithub
Troubleshooting: macOS, Python 3, pip3
If you get a pip3 error message such as:
Traceback (most recent call last):
File "/Library/Developer/CommandLineTools/usr/bin/pip3", line 10, in <module>
sys.exit(main())
TypeError: 'module' object is not callable
Then try to uninstall pip:
sh
python3 -m pip install --upgrade pip
Troubleshooting: macOS, Python 3, pip3, homebrew
If you are using macOS Catalina, python 3.7, and pip3, and you get an error message that shows pip3 is aborting, then see: https://github.com/Homebrew/homebrew-core/issues/44996
And try this:
sh
rm -rf python3.7/site-packages/asn1crypto
pip3 install asn1crypto
Troubleshooting: GitHub Enterprise
If you use Github Enterprise with custom hostname, then you may need to adjust this script by doing:
python
g = Github(base_url="https://{hostname}/api/v3", login_or_token="token")
Owner
- Name: SixArm
- Login: SixArm
- Kind: organization
- Email: sixarm@sixarm.com
- Location: San Francisco
- Website: http://sixarm.com
- Twitter: sixarm
- Repositories: 580
- Profile: https://github.com/SixArm
SixArm Software
Citation (CITATION.cff)
cff-version: 1.2.0
title: GitHub API tools with python
message: >-
If you use this work and you want to cite it,
then you can use the metadata from this file.
type: software
authors:
- given-names: Joel Parker
family-names: Henderson
email: joel@joelparkerhenderson.com
affiliation: joelparkerhenderson.com
orcid: 'https://orcid.org/0009-0000-4681-282X'
identifiers:
- type: url
value: 'https://github.com/SixArm/github-api-tools-with-python/'
description: GitHub API tools with python
repository-code: 'https://github.com/SixArm/github-api-tools-with-python/'
abstract: >-
GitHub API tools with python
license: See license file
GitHub Events
Total
- Watch event: 1
- Push event: 1
Last Year
- Watch event: 1
- Push event: 1
Committers
Last synced: about 1 year ago
Top Committers
| Name | Commits | |
|---|---|---|
| Joel Parker Henderson | j****l@j****m | 9 |
Committer Domains (Top 20 + Academic)
Issues and Pull Requests
Last synced: 12 months ago
All Time
- Total issues: 0
- Total pull requests: 0
- Average time to close issues: N/A
- Average time to close pull requests: N/A
- Total issue authors: 0
- Total pull request authors: 0
- Average comments per issue: 0
- Average comments per pull request: 0
- Merged pull requests: 0
- Bot issues: 0
- Bot pull requests: 0
Past Year
- Issues: 0
- Pull requests: 0
- Average time to close issues: N/A
- Average time to close pull requests: N/A
- Issue authors: 0
- Pull request authors: 0
- Average comments per issue: 0
- Average comments per pull request: 0
- Merged pull requests: 0
- Bot issues: 0
- Bot pull requests: 0