additions from backlog and removals because of unclear license status that could not be resolved and a bit of gitlab statistics

This commit is contained in:
Trilarion
2021-10-01 14:13:08 +02:00
parent e7ea8fc6ab
commit ac85e5fa99
322 changed files with 1081 additions and 713 deletions

View File

@ -485,6 +485,7 @@ def create_entry_content(entry):
e = entry[field]
e = ['"{}"'.format(x) if any(y in x.value for y in (',', ' (')) else x for x in e]
e = [str(x) for x in e]
e = list(dict.fromkeys(e)) # this removes duplicates while keeping the sorting order
content += '- {}: {}\n'.format(field, ', '.join(e))
content += '\n'

View File

@ -43,6 +43,7 @@ def retrieve_repo_info(repos, token=None):
for repo in repos:
repo = normalize_repo_name(repo)
try:
# get repo
r = g.get_repo(repo)
except GithubException as e:
raise RuntimeError(e) # TODO what to do if repo does not exist?

41
code/utils/osg_gitlab.py Normal file
View File

@ -0,0 +1,41 @@
"""
Everything specific to the Gitlab API (via Python GitLab https://python-gitlab.readthedocs.io/en/stable/)
"""
from dateutil import parser
from gitlab import Gitlab
def normalize_repo_name(repo):
"""
Bring repo to style xxx/yyy
"""
prefix = 'https://gitlab.com/'
if repo.startswith(prefix):
repo = repo[len(prefix):]
suffix = '.git'
if repo.endswith(suffix):
repo = repo[:-len(suffix)]
return repo
def retrieve_repo_info(repos, token=None):
"""
:param repos:
:param token:
:return:
"""
single_repo = isinstance(repos, str)
if single_repo:
repos = (repos,)
result = []
gl = Gitlab('https://gitlab.com')
for repo in repos:
repo = normalize_repo_name(repo)
# get project
p = gl.projects.get(repo)
e = {'description': p.description, 'created': parser.parse(p.created_at), 'contributors': p.repository_contributors(), 'forks': p.forks_count, 'name': p.name, 'last modified': parser.parse(p.last_activity_at), 'stars': p.star_count, 'languages': p.languages()}
result.append(e)
if single_repo:
result = result[0]
return result