git.py 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. #!/usr/bin/env python
  2. import requests
  3. import json
  4. message = "https://codeberg.org/zortazert/python-projects"
  5. query = message.split("/")
  6. if query[2] == "github.com":
  7. github_api = f"https://api.github.com/repos/{query[3]}/{query[4]}"
  8. data = requests.get(github_api)
  9. json_stuff = json.loads(data.text)
  10. mb_size= round(float(json_stuff["size"]) / 1024, 1)
  11. print(f"""
  12. Repo Name: {json_stuff["name"]}
  13. Author Name: {json_stuff["owner"]["login"]}
  14. Size: {mb_size} mb
  15. Branch: {json_stuff["default_branch"]}
  16. Issues: {json_stuff["open_issues"]}
  17. Languages:""")
  18. data_languages = requests.get(f"https://api.github.com/repos/{query[3]}/{query[4]}/languages")
  19. languages_json = json.loads(data_languages.text)
  20. for key in languages_json:
  21. print(key, end=" ")
  22. else:
  23. gitea_api = f"https://{query[2]}/api/v1/repos/{query[3]}/{query[4]}"
  24. data = requests.get(gitea_api)
  25. json_stuff = json.loads(data.text)
  26. mb_size= round(float(json_stuff["size"]) / 1024, 1)
  27. print(f"""Repo Name: {json_stuff["full_name"]}
  28. Author Name: {json_stuff["owner"]["login"]}
  29. Size: {mb_size} mb
  30. Branch: {json_stuff["default_branch"]}
  31. Issues: {json_stuff["open_issues_count"]}
  32. Pull Requests: {json_stuff["open_pr_counter"]}""")
  33. print("Languages:")
  34. data_languages = requests.get(f"https://{query[2]}/api/v1/repos/{query[3]}/{query[4]}/languages")
  35. languages_json = json.loads(data_languages.text)
  36. total = sum(value for c in languages_json.items())
  37. print(total)
  38. for key, value in languages_json.items():
  39. print(key, value)