jenkins-bot has submitted this change and it was merged. ( https://gerrit.wikimedia.org/r/583737 )
Change subject: [IMPR] Add code aliases to langs ......................................................................
[IMPR] Add code aliases to langs
- fix generate_family_files for aliases
+ add wikimaniateam + use SubdomainFamily super for Wikimania family
Bug: T248608 Change-Id: Ibddcbffde22bde48661a777a0d7a463acc98e51f --- M pywikibot/families/wikimania_family.py M pywikibot/family.py 2 files changed, 18 insertions(+), 9 deletions(-)
Approvals: Xqt: Looks good to me, approved jenkins-bot: Verified
diff --git a/pywikibot/families/wikimania_family.py b/pywikibot/families/wikimania_family.py index 881e57e..9651f77 100644 --- a/pywikibot/families/wikimania_family.py +++ b/pywikibot/families/wikimania_family.py @@ -23,7 +23,7 @@ '2014', '2015', '2016', '2017', '2018' ]
- codes = ['wikimania'] + codes = ['wikimania', 'team']
code_aliases = {'2019': 'wikimania'}
@@ -32,10 +32,8 @@ @classproperty def langs(cls): """Property listing family languages.""" - codes = cls.codes + cls.closed_wikis - - # shortcut this classproperty - cls.langs = {code: '{}{}.{}'.format(cls.name, code, cls.domain) - for code in codes if code != 'wikimania'} - cls.langs['wikimania'] = 'wikimania.{}'.format(cls.domain) + cls.langs = super(Family, cls).langs + for lang, url in cls.langs.items(): + if not url.startswith(cls.name): + cls.langs[lang] = cls.name + url return cls.langs diff --git a/pywikibot/family.py b/pywikibot/family.py index 43e5e65..bea8eaf 100644 --- a/pywikibot/family.py +++ b/pywikibot/family.py @@ -36,8 +36,9 @@ logger = logging.getLogger('pywiki.wiki.family')
# Legal characters for Family.name and Family.langs keys +# nl_nds code alias requires "_" NAME_CHARACTERS = string.ascii_letters + string.digits -CODE_CHARACTERS = string.ascii_lowercase + string.digits + '-' +CODE_CHARACTERS = string.ascii_lowercase + string.digits + '-_'
class Family(object): @@ -1568,6 +1569,11 @@ # shortcut this classproperty cls.langs = {code: '{0}.{1}'.format(code, cls.domain) for code in codes} + + if hasattr(cls, 'code_aliases'): + cls.langs.update({alias: '{0}.{1}'.format(code, cls.domain) + for alias, code in cls.code_aliases.items()}) + return cls.langs
@classproperty @@ -1597,7 +1603,12 @@ @classproperty def langs(cls): """Property listing family languages.""" - return {code: cls.domain for code in cls.codes} + codes = cls.codes + + if hasattr(cls, 'code_aliases'): + codes += tuple(cls.code_aliases.keys()) + + return {code: cls.domain for code in codes}
def protocol(self, code): """Return 'https' as the protocol."""
pywikibot-commits@lists.wikimedia.org