From af4707835779ab4316bdd6b61cde95f58b085302 Mon Sep 17 00:00:00 2001 From: Matthias Koeppe Date: Fri, 14 Oct 2022 14:56:11 -0700 Subject: [PATCH 1/5] scripts/geocode.py: Do not fail if geocode.key does not exist --- scripts/geocode.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/scripts/geocode.py b/scripts/geocode.py index ab381ade..eb4b70dd 100755 --- a/scripts/geocode.py +++ b/scripts/geocode.py @@ -33,7 +33,10 @@ # google key for sagemath.org - no longer a free one available # this is an "api key" credential for GCP's "Geocode API" -gkey = open(os.path.expanduser("~/geocode.key")).read().strip() +try: + gkey = open(os.path.expanduser("~/geocode.key")).read().strip() +except FileNotFoundError: + gkey = None # allowed attributes in source xml, for checkXML goodKeys = [ @@ -189,6 +192,8 @@ def getGeo(loc): CSV Geo returns: [200,6,42.730070,-73.690570] [retcode,accuracy,lng,lat] """ + if not gkey: + return None loc = loc.replace(" ", "+") loc = quote(loc.encode('UTF-8')) print(loc, ">>>", end="") From 10ff65d5b1d372737ec128f2b490658052d7a79c Mon Sep 17 00:00:00 2001 From: Matthias Koeppe Date: Fri, 14 Oct 2022 14:57:58 -0700 Subject: [PATCH 2/5] scripts/geocode.py: Handle altnames attribute, display trac account name, use trac query instead of search --- scripts/geocode.py | 26 +++++++++++++++++++------- 1 file changed, 19 insertions(+), 7 deletions(-) diff --git a/scripts/geocode.py b/scripts/geocode.py index eb4b70dd..cc65725c 100755 --- a/scripts/geocode.py +++ b/scripts/geocode.py @@ -40,7 +40,7 @@ # allowed attributes in source xml, for checkXML goodKeys = [ - "name", "location", "work", "description", "url", "pix", "size", "jitter", + "name", "altnames", "location", "work", "description", "url", "pix", "size", "jitter", "trac", "github", "gitlab" ] @@ -98,6 +98,7 @@ def writeToDevmap(): if c.tagName != "contributor": continue dev = c.getAttribute("name") + altnames = c.getAttribute("altnames") loc = c.getAttribute("location") work = c.getAttribute("work") descr = c.getAttribute("description") @@ -137,14 +138,25 @@ def writeToDevmap(): d_el = parseString("%s" % d) td.appendChild(d_el.firstChild) - if len(trac) == 0: - trac = dev - trac = trac.replace(" ", "%20") a = devmap.createElement("a") - a.setAttribute("href", tracSearch + trac) + tracQuery = f"https://trac.sagemath.org/query?" + for trac in trac.split(','): + trac = trac.strip() + if not trac: + continue + tracQuery += f"&or&cc=~{trac}" + tracQuery += f"&or&reporter=~{trac}" + tracQuery += f"&or&owner=~{trac}" + for name in [dev] + altnames.split(','): + name = name.strip() + if not name: + continue + tracQuery += f"&or&author=~{name}" + tracQuery += f"&or&reviewer=~{name}" + tracQuery += "&max=500&col=id&col=summary&col=author&col=status&col=priority&col=milestone&col=reviewer&order=priority" + a.setAttribute("href", tracQuery) a.setAttribute("class", "trac") - #a.setAttribute("target", "_blank") - a.appendChild(devmap.createTextNode("contributions")) + a.appendChild(devmap.createTextNode(f"contributions (trac: {trac})")) td.appendChild(devmap.createElement("br")) td.appendChild(a) From 193cd8c56cd102246b659364cf1de371eb89c975 Mon Sep 17 00:00:00 2001 From: Matthias Koeppe Date: Fri, 14 Oct 2022 14:58:31 -0700 Subject: [PATCH 3/5] conf/contributors.xml: Add an altnames attribute, remove a duplicate --- conf/contributors.xml | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/conf/contributors.xml b/conf/contributors.xml index 436c6ea2..d647c541 100644 --- a/conf/contributors.xml +++ b/conf/contributors.xml @@ -2103,6 +2103,7 @@ Please keep the list in alphabetical order by last name! trac="mkohlhase"/> - Date: Fri, 14 Oct 2022 18:13:39 -0700 Subject: [PATCH 4/5] scripts/geocode.py: Include gh-... accounts in trac search --- scripts/geocode.py | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/scripts/geocode.py b/scripts/geocode.py index cc65725c..d4bf7b55 100755 --- a/scripts/geocode.py +++ b/scripts/geocode.py @@ -104,6 +104,7 @@ def writeToDevmap(): descr = c.getAttribute("description") url = c.getAttribute("url") trac = c.getAttribute("trac") + github = c.getAttribute("github") tr = devmap.createElement("tr") td = devmap.createElement("td") @@ -140,10 +141,12 @@ def writeToDevmap(): a = devmap.createElement("a") tracQuery = f"https://trac.sagemath.org/query?" - for trac in trac.split(','): - trac = trac.strip() - if not trac: - continue + main_trac = None + trac_list = [t.strip() for t in trac.split(',') if t.strip()] + gh_trac_list = [f'gh-{gh.strip()}' for gh in github.split(',') if gh.strip()] + for trac in trac_list + gh_trac_list: + if not main_trac: + main_trac = trac tracQuery += f"&or&cc=~{trac}" tracQuery += f"&or&reporter=~{trac}" tracQuery += f"&or&owner=~{trac}" @@ -156,7 +159,10 @@ def writeToDevmap(): tracQuery += "&max=500&col=id&col=summary&col=author&col=status&col=priority&col=milestone&col=reviewer&order=priority" a.setAttribute("href", tracQuery) a.setAttribute("class", "trac") - a.appendChild(devmap.createTextNode(f"contributions (trac: {trac})")) + if main_trac: + a.appendChild(devmap.createTextNode(f"contributions (trac: {main_trac})")) + else: + a.appendChild(devmap.createTextNode(f"contributions (trac)")) td.appendChild(devmap.createElement("br")) td.appendChild(a) From 43fae198fc5d80bafdc2b66a0e28e0861ad074a8 Mon Sep 17 00:00:00 2001 From: Matthias Koeppe Date: Fri, 14 Oct 2022 19:12:16 -0700 Subject: [PATCH 5/5] scripts/geocode.py: Encode space in URL --- scripts/geocode.py | 1 + 1 file changed, 1 insertion(+) diff --git a/scripts/geocode.py b/scripts/geocode.py index d4bf7b55..57f6080a 100755 --- a/scripts/geocode.py +++ b/scripts/geocode.py @@ -157,6 +157,7 @@ def writeToDevmap(): tracQuery += f"&or&author=~{name}" tracQuery += f"&or&reviewer=~{name}" tracQuery += "&max=500&col=id&col=summary&col=author&col=status&col=priority&col=milestone&col=reviewer&order=priority" + tracQuery = tracQuery.replace(" ", "%20") a.setAttribute("href", tracQuery) a.setAttribute("class", "trac") if main_trac: