jenkins-bot has submitted this change and it was merged.
Change subject: calculating crossnamespace from authornamespaces; use
collections.defaultdict for crossnamespace
......................................................................
calculating crossnamespace from authornamespaces;
use collections.defaultdict for crossnamespace
Change-Id: I19405fbaa7fa1d8d6d7077629762cbd0629adfa1
---
M pywikibot/families/wikisource_family.py
M pywikibot/family.py
2 files changed, 6 insertions(+), 47 deletions(-)
Approvals:
DrTrigon: Checked; Looks good to me, but someone else must approve
Merlijn van Deen: Looks good to me, approved
jenkins-bot: Verified
diff --git a/pywikibot/families/wikisource_family.py
b/pywikibot/families/wikisource_family.py
index cb06da6..9660bcc 100644
--- a/pywikibot/families/wikisource_family.py
+++ b/pywikibot/families/wikisource_family.py
@@ -87,48 +87,6 @@
'zh': [102],
}
- self.crossnamespace[0] = {
- '_default': self.authornamespaces,
- }
- self.crossnamespace[100] = {
- 'bg': self.authornamespaces,
- 'cs': self.authornamespaces,
- 'hr': self.authornamespaces,
- 'hu': self.authornamespaces,
- 'hy': self.authornamespaces,
- 'ko': self.authornamespaces,
- 'tr': self.authornamespaces,
- }
-
- self.crossnamespace[102] = {
- 'ar': self.authornamespaces,
- 'be': self.authornamespaces,
- 'da': self.authornamespaces,
- 'en': self.authornamespaces,
- 'eo': self.authornamespaces,
- 'fa': self.authornamespaces,
- 'fr': self.authornamespaces,
- 'it': self.authornamespaces,
- 'la': self.authornamespaces,
- 'nl': self.authornamespaces,
- 'no': self.authornamespaces,
- 'pt': self.authornamespaces,
- 'ro': self.authornamespaces,
- 'vi': self.authornamespaces,
- 'zh': self.authornamespaces,
- }
-
- self.crossnamespace[104] = {
- 'pl': self.authornamespaces,
- }
-
- self.crossnamespace[106] = {
- 'ca': self.authornamespaces,
- 'et': self.authornamespaces,
- 'sv': self.authornamespaces,
- }
-
- self.crossnamespace[108] = {
- 'he': self.authornamespaces,
- }
-
+ for key, values in self.authornamespaces.iteritems():
+ for item in values:
+ self.crossnamespace[item].update({key: self.authornamespaces})
diff --git a/pywikibot/family.py b/pywikibot/family.py
index fb4511c..abd304d 100644
--- a/pywikibot/family.py
+++ b/pywikibot/family.py
@@ -10,8 +10,9 @@
import logging
import re
import urllib
-import config2 as config
+import collections
+import config2 as config
import pywikibot
logger = logging.getLogger("pywiki.wiki.family")
@@ -709,7 +710,7 @@
# values are dicts where:
# keys are the languages that can be linked to from the lang+ns, or
# '_default'; values are a list of namespace numbers
- self.crossnamespace = {}
+ self.crossnamespace = collections.defaultdict(dict)
##
## Examples :
## Allowing linking to pt' 102 NS from any other lang' 0 NS is
--
To view, visit
https://gerrit.wikimedia.org/r/86085
To unsubscribe, visit
https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I19405fbaa7fa1d8d6d7077629762cbd0629adfa1
Gerrit-PatchSet: 2
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Owner: Xqt <info(a)gno.de>
Gerrit-Reviewer: DrTrigon <dr.trigon(a)surfeu.ch>
Gerrit-Reviewer: Ladsgroup <ladsgroup(a)gmail.com>
Gerrit-Reviewer: Legoktm <legoktm.wikipedia(a)gmail.com>
Gerrit-Reviewer: Merlijn van Deen <valhallasw(a)arctus.nl>
Gerrit-Reviewer: jenkins-bot