From 12db22b6c9de3e9ea4ca2b6246f6abfd1b66818b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Per=20=C3=98yvind=20Karlsen?= Date: Wed, 1 Jun 2016 06:26:37 +0200 Subject: rather get more up to date list of users from https://people.mageia.org/u/ --- MgaRepo/log.py | 35 ++++++++++++++++++++++++++++++----- 1 file changed, 30 insertions(+), 5 deletions(-) diff --git a/MgaRepo/log.py b/MgaRepo/log.py index 980429b..126e8c0 100644 --- a/MgaRepo/log.py +++ b/MgaRepo/log.py @@ -561,15 +561,40 @@ def get_old_log(pkgdirurl): chlog.seek(0) return chlog +from html.parser import HTMLParser +class TagParser(HTMLParser): + li = False + ahref = False + namepat = re.compile("(?P.*?)\s*\((?P.*?)\)") + + def handle_starttag(self, tag, attrs): + if tag == "li": + self.li = True + if self.li and tag == "a": + for att in attrs: + if att[0] == "href": + self.ahref = True + + def handle_endtag(self, tag): + if self.li and tag == "a": + self.ahref = False + if tag == "li": + self.li = False + + def handle_data(self, data): + if self.li and self.ahref: + found = self.namepat.match(data) + if found and found.group("user") and found.group("name"): + usermap[found.group("user")] = "%s <%s@mageia.org>" % (found.group("name"), found.group("user")) + def _map_user_names(): import urllib.request if not usermap: - # This user map is from 2013-08-24, so it's rather dated, but sufficing for those listed... - f = urllib.request.urlopen("http://gitweb.mageia.org/software/infrastructure/svn-git-migration/plain/metadata/mageia-user-map.txt") - for user in f.read().decode("UTF-8").splitlines(): - username, namemail = user.split(" = ") - usermap[username] = namemail + f = urllib.request.urlopen("https://people.mageia.org/u/") + users = f.read().decode("UTF-8") f.close() + parser = TagParser() + parser.feed(users) def get_changelog(pkgdirurl, another=None, svn=True, rev=None, size=None, submit=False, sort=False, template=None, macros=[], exported=None, -- cgit v1.2.1