This repository has been archived on 2022-06-22. You can view files and clone it, but cannot push or open issues or pull requests.
github-gitea-mirror/helper.py

33 lines
854 B
Python
Raw Normal View History

2020-10-12 10:06:10 +00:00
#!/usr/bin/env python
# https://github.com/PyGithub/PyGithub
from github import Github
import requests
import json
import sys
import os
config = json.loads(open(os.path.expanduser("./config.json")).read().strip())
def giteaSession():
session = requests.Session()
session.headers.update({
"Content-type" : "application/json",
"Authorization" : "token {0}".format(config['gitea']['accesstoken']),
})
return session
session = giteaSession()
def giteaSetRepoTopics(owner,repo_name,topics):
m = {
"topics":topics,
}
r = session.put("{0}/api/v1/repos/{1}/{2}/topics".format(config['gitea']['host'],owner,repo_name), data=json.dumps(m))
if r.status_code == 204:
print(' ---> SUCCESS : Repository Topics Set')
else:
print(' ---> ERROR : Unable To SetRepository Topics')