Improved.

This commit is contained in:
Varun 2020-10-12 17:54:15 +05:30
parent 7e17e6f772
commit 1e4f9fcc77
No known key found for this signature in database
GPG Key ID: 93FB46DCF16E0D6F
3 changed files with 16 additions and 6 deletions

View File

@ -1,2 +1,7 @@
# github-gitea-mirror
Simple Python Script To Mirror Repository From Github To Gitea
# Github To Gitea Mirror
Simple Python Script To Mirror Repository / Gist From Github To Gitea
## Why ?
## Usage

View File

@ -6,6 +6,7 @@ import json
import sys
import os
giteaGetUserCache = dict()
THIS_FOLDER = os.path.dirname(os.path.abspath(__file__))
config = json.loads(open(os.path.expanduser("{0}/config.json".format(THIS_FOLDER))).read().strip())
@ -72,10 +73,15 @@ def giteaCreateOrg(orgname):
if r.status_code != 201:
return 'failed'
return json.loads(r.text)["id"]
giteaGetUserCache["{0}".format(orgname)] = json.loads(r.text)["id"]
return giteaGetUserCache[orgname]
def giteaGetUser(username):
if username in giteaGetUserCache:
return giteaGetUserCache[username]
r = session.get(giteaHost('users/{0}'.format(username)))
if r.status_code != 200:
return 'failed'
return json.loads(r.text)["id"]
giteaGetUserCache["{0}".format(username)] = json.loads(r.text)["id"]
return giteaGetUserCache[username]

View File

@ -57,5 +57,4 @@ for repo in gh.get_user().get_gists():
topics.append('public-{0}-gist'.format(repo_owner))
giteaSetRepoTopics(repo_owner,m["repo_name"],topics)
print(" ")
exit(1)
print(" ")