[gimp-web/wip/Jehan/issue-236-new-sponsor-page] plugins: get back a per-country listing with location details next to…
- From: Jehan <jehanp src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp-web/wip/Jehan/issue-236-new-sponsor-page] plugins: get back a per-country listing with location details next to…
- Date: Sat, 28 Aug 2021 22:54:57 +0000 (UTC)
commit 7d5198b9ebcda807c519f0ae75de715aefd1ae05
Author: Jehan <jehan girinstud io>
Date: Sun Aug 29 00:54:08 2021 +0200
plugins: get back a per-country listing with location details next to…
… each mirror sponsor.
plugins/gimp_mirrors/gimp_mirrors.py | 43 ++++++++++++++++++++++++++----------
1 file changed, 31 insertions(+), 12 deletions(-)
---
diff --git a/plugins/gimp_mirrors/gimp_mirrors.py b/plugins/gimp_mirrors/gimp_mirrors.py
index 87d3bd21..fd1048a4 100644
--- a/plugins/gimp_mirrors/gimp_mirrors.py
+++ b/plugins/gimp_mirrors/gimp_mirrors.py
@@ -35,12 +35,23 @@ class UnexpectedException(Exception): pass
def html_output(data):
html = u"<dl class='download-mirrors'>\n"
- html += u"<ul>"
- for name, values in sorted(data.items()):
- html += u"<li><a href='{}'>{}</a> (<em>{}</em>)</li>".format(values['url'],
- name,
- values['location'])
- html += u"</ul>"
+ for country, values in sorted(data.items()):
+ html += u"<dt>{}</dt>".format(country)
+
+ for name, info in sorted(values.items()):
+ url = info['url']
+ location = info['location']
+ if isinstance(url, str):
+ # In Python3 str are unicode strings.
+ tmp = url
+ else:
+ tmp = url.decode('utf-8')
+ if location is not None:
+ html += u"<dd><a href='{}'>{}</a> (<em>{}</em>)</dd>\n".format(tmp, name, location)
+ else:
+ html += u"<dd><a href='{}'>{}</a></dd>\n".format(tmp, name)
+
+ html += u"</dl>"
return html
@@ -83,13 +94,21 @@ def do_mirrors(path, context):
print("WARNING: cannot resolve record for {}: {} ".format(record, domain))
if 'location' in data[record]:
- location = '{}, {}'.format(data[record]['location'], country)
+ location = data[record]['location']
else:
- location = country
- mirrors[record] = {
- 'url': data[record]['about'],
- 'location': location
- }
+ location = None
+
+ if country in mirrors:
+ mirrors[country][record] = {
+ 'url': data[record]['about'],
+ 'location': location
+ }
+ else:
+ mirrors[country] = { record: {
+ 'url': data[record]['about'],
+ 'location': location
+ }
+ }
try:
with open( path, 'rb') as f:
s = f.read()
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]