Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit cf9964b

Browse files
committed
Created script.py as per avinashkranjan#126
1 parent 4bc64f3 commit cf9964b

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

‎Github Size-Contributor-List/script.py

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
import requests
2+
import argparse
3+
4+
def main(args):
5+
GITHUB_URL = f" https://api.github.com/repos/{args.o}/{args.n}"
6+
res = requests.get(GITHUB_URL).json()
7+
response_collaborators = requests.get(f"{GITHUB_URL}/contributors").json()
8+
9+
response_text = f"Size of repository is {res.get('size')}"
10+
11+
list_of_contributors = []
12+
13+
for x in response_collaborators:
14+
list_of_contributors.append(x.get("login"))
15+
16+
with open("output.txt", "w") as text:
17+
text.write(response_text + "\n" + "List of contributors is as follows: " + str(list_of_contributors))
18+
19+
20+
if __name__ == "__main__":
21+
parser = argparse.ArgumentParser("This script displays the size and list of contributors for a specific repo")
22+
parser.add_argument("-o", help="The name of the user", type=str, required=True)
23+
parser.add_argument("-n", help="The name of the repo", type=str, required=True)
24+
25+
args = parser.parse_args()
26+
27+
main(args)

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /