Xqt has submitted this change. (
https://gerrit.wikimedia.org/r/c/pywikibot/core/+/1343054?usp=email )
Change subject: generate_family_file: Build mappings in one pass
......................................................................
generate_family_file: Build mappings in one pass
Build hostname, path, and protocol mappings during one traversal of the
detected wikis. Reuse each parsed server URL for its hostname and scheme.
Change-Id: I3bbcf3f455f55c64e8f4e7b80d3e718d6b682125
---
M pywikibot/scripts/generate_family_file.py
1 file changed, 11 insertions(+), 10 deletions(-)
Approvals:
Xqt: Verified; Looks good to me, approved
diff --git a/pywikibot/scripts/generate_family_file.py
b/pywikibot/scripts/generate_family_file.py
index 19905b1..43415f4 100755
--- a/pywikibot/scripts/generate_family_file.py
+++ b/pywikibot/scripts/generate_family_file.py
@@ -270,17 +270,18 @@
self.show('Terminating.')
sys.exit(1)
- code_hostname_pairs = '\n '.join(
- f"'{k}': '{urlparse(w.server).netloc}',"
- for k, w in self.wikis.items())
+ hostname_pairs = []
+ path_pairs = []
+ protocol_pairs = []
+ for code, wiki in self.wikis.items():
+ parsed_server = urlparse(wiki.server)
+ hostname_pairs.append(f"'{code}': '{parsed_server.netloc}',")
+ path_pairs.append(f"'{code}': '{wiki.scriptpath}',")
+ protocol_pairs.append(f"'{code}': '{parsed_server.scheme}',")
- code_path_pairs = '\n '.join(
- f"'{k}': '{w.scriptpath}',"
- for k, w in self.wikis.items())
-
- code_protocol_pairs = '\n '.join(
- f"'{k}': '{urlparse(w.server).scheme}',"
- for k, w in self.wikis.items())
+ code_hostname_pairs = '\n '.join(hostname_pairs)
+ code_path_pairs = '\n '.join(path_pairs)
+ code_protocol_pairs = '\n '.join(protocol_pairs)
content = family_template % {
'url': self.base_url, 'name': self.name,
--
To view, visit
https://gerrit.wikimedia.org/r/c/pywikibot/core/+/1343054?usp=email
To unsubscribe, or for help writing mail filters, visit
https://gerrit.wikimedia.org/r/settings?usp=email
Gerrit-MessageType: merged
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Change-Id: I3bbcf3f455f55c64e8f4e7b80d3e718d6b682125
Gerrit-Change-Number: 1343054
Gerrit-PatchSet: 2
Gerrit-Owner: Mahveotm <[email protected]>
Gerrit-Reviewer: Xqt <[email protected]>
Gerrit-Reviewer: jenkins-bot
_______________________________________________
Pywikibot-commits mailing list -- [email protected]
To unsubscribe send an email to [email protected]