jenkins-bot has submitted this change. ( https://gerrit.wikimedia.org/r/c/pywikibot/core/+/938812 )
Change subject: [bugfix] Add 'yue' code_aliases to wikipedia_family.py
......................................................................
[bugfix] Add 'yue' code_aliases to wikipedia_family.py
- call a __post_init__() class method in Family.__new__ class if present
- raise a RuntimeError if the __post_init__() method is not a class method
- update deprecation message when using Family.__init__()
- add a __post_init__() class method to wikipedia_family.py and
wiktionary_family.py to add the 'yue'/'zh-yue' alias to cls.code_aliases
- add __init__() and __post_init__ descriptions to documentation
Bug: T341960
Change-Id: Ie8dbb0b5f3c9a40cd1f3bf61e64f7e8f1bbf1076
---
M docs/api_ref/family.rst
M pywikibot/family.py
M pywikibot/families/wiktionary_family.py
M pywikibot/families/wikipedia_family.py
4 files changed, 97 insertions(+), 4 deletions(-)
Approvals:
Xqt: Looks good to me, approved
jenkins-bot: Verified
diff --git a/docs/api_ref/family.rst b/docs/api_ref/family.rst
index 042b337..3a61f22 100644
--- a/docs/api_ref/family.rst
+++ b/docs/api_ref/family.rst
@@ -4,3 +4,48 @@
.. automodule:: family
:synopsis: Objects representing MediaWiki families
+
+ .. autoclass:: Family
+
+ .. method:: __init__()
+
+ Initializer
+
+ .. deprecated:: 3.0.20180710
+ Use :meth:`__post_init__` instead.
+ .. versionchanged:: 8.3
+ A FutureWarning is printed instead of a ``NotImplementedWarning``.
+ The deprecation may be removed in a future release and a
+ ``RuntimeError`` will be thrown instead.
+
+ .. method:: __post_init__()
+ :classmethod:
+
+ Post-init processing for Family class.
+
+ The allocator will call this class method after the Family class was
+ created and no :meth:`__init__()` method is used and ``__post_init__()``
+ is defined in your Family subclass. This can be used for example to
+ expand Family attribute lists.
+
+ .. warning:: The ``__post_init__()`` classmethod cannot be inherited
+ from a superclass. The current family file class is considered
+ only.
+
+ .. caution:: Never modify the current attributes directly; always use
+ a copy. Otherwise the base class is modified which leads to
+ unwanted side-effects.
+
+ **Example:**
+
+ .. code-block:: Python
+
+ @classmethod
+ def __post_init__(cls):
+ """Add 'yue' code alias."""
+ aliases = cls.code_aliases.copy()
+ aliases['yue'] = 'zh-yue'
+ cls.code_aliases = aliases
+
+ .. versionadded:: 8.3
+
diff --git a/pywikibot/families/wikipedia_family.py b/pywikibot/families/wikipedia_family.py
index a972c83..e7a542c 100644
--- a/pywikibot/families/wikipedia_family.py
+++ b/pywikibot/families/wikipedia_family.py
@@ -216,6 +216,16 @@
'de': ('Archiv',),
}
+ @classmethod
+ def __post_init__(cls):
+ """Add 'yue' code alias due to :phab:`T341960`.
+
+ .. versionadded:: 8.3
+ """
+ aliases = cls.code_aliases.copy()
+ aliases['yue'] = 'zh-yue'
+ cls.code_aliases = aliases
+
def encodings(self, code):
"""Return a list of historical encodings for a specific site."""
# Historic compatibility
diff --git a/pywikibot/families/wiktionary_family.py b/pywikibot/families/wiktionary_family.py
index eb92bc2..5478747 100644
--- a/pywikibot/families/wiktionary_family.py
+++ b/pywikibot/families/wiktionary_family.py
@@ -87,3 +87,13 @@
'ar': ('/شرح', '/doc'),
'sr': ('/док', ),
}
+
+ @classmethod
+ def __post_init__(cls):
+ """Add 'zh-yue' code alias due to :phab:`T341960`.
+
+ .. versionadded:: 8.3
+ """
+ aliases = cls.code_aliases.copy()
+ aliases['zh-yue'] = 'yue'
+ cls.code_aliases = aliases
diff --git a/pywikibot/family.py b/pywikibot/family.py
index 6a1e26e..9660c83 100644
--- a/pywikibot/family.py
+++ b/pywikibot/family.py
@@ -5,6 +5,7 @@
# Distributed under the terms of the MIT license.
#
import collections
+import inspect
import logging
import string
import sys
@@ -13,6 +14,7 @@
import warnings
from importlib import import_module
from itertools import chain
+from textwrap import fill
from os.path import basename, dirname, splitext
from typing import Optional
@@ -55,9 +57,8 @@
"""Allocator."""
# any Family class defined in this file are abstract
if cls in globals().values():
- raise TypeError(
- 'Abstract Family class {} cannot be instantiated; '
- 'subclass it instead'.format(cls.__name__))
+ raise TypeError(f'Abstract Family class {cls.__name__} cannot be'
+ ' instantiated; subclass it instead')
# Override classproperty
cls.instance = super().__new__(cls)
@@ -67,13 +68,23 @@
if '__init__' in cls.__dict__:
# Initializer deprecated. Families should be immutable and any
# instance / class modification should go to allocator (__new__).
- cls.__init__ = deprecated(cls.__init__)
+ cls.__init__ = deprecated(instead='__post_init__() classmethod',
+ since='3.0.20180710')(cls.__init__)
# Invoke initializer immediately and make initializer no-op.
# This is to avoid repeated initializer invocation on repeated
# invocations of the metaclass's __call__.
cls.instance.__init__()
cls.__init__ = lambda self: None # no-op
+ elif '__post_init__' not in cls.__dict__:
+ pass
+ elif inspect.ismethod(cls.__post_init__): # classmethod check
+ cls.__post_init__()
+ else:
+ raise RuntimeError(fill(
+ f'__post_init__() method of {cls.__module__}.{cls.__name__}'
+ ' class or its superclass must be a classmethod. Please check'
+ ' your family file.', width=66))
return cls.instance
--
To view, visit https://gerrit.wikimedia.org/r/c/pywikibot/core/+/938812
To unsubscribe, or for help writing mail filters, visit https://gerrit.wikimedia.org/r/settings
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Change-Id: Ie8dbb0b5f3c9a40cd1f3bf61e64f7e8f1bbf1076
Gerrit-Change-Number: 938812
Gerrit-PatchSet: 6
Gerrit-Owner: Xqt <info(a)gno.de>
Gerrit-Reviewer: Meno25 <meno25mail(a)gmail.com>
Gerrit-Reviewer: Xqt <info(a)gno.de>
Gerrit-Reviewer: Zhuyifei1999 <zhuyifei1999(a)gmail.com>
Gerrit-Reviewer: jenkins-bot
Gerrit-MessageType: merged
jenkins-bot has submitted this change. ( https://gerrit.wikimedia.org/r/c/pywikibot/i18n/+/940107 )
Change subject: Localisation updates from https://translatewiki.net.
......................................................................
Localisation updates from https://translatewiki.net.
Change-Id: Ia10f173ee03a8b4638b00a917e15449ef7f25d1f
---
M category/gl.json
M unusedfiles/gl.json
M pywikibot/gl.json
M replicate_wiki/sr.json
A replicate_wiki/gl.json
M unprotect/gl.json
M redirect/gl.json
7 files changed, 37 insertions(+), 11 deletions(-)
Approvals:
L10n-bot: Looks good to me, approved
jenkins-bot: Verified
diff --git a/category/gl.json b/category/gl.json
index f0eecd8..a2ce1d7 100644
--- a/category/gl.json
+++ b/category/gl.json
@@ -8,7 +8,7 @@
},
"category-adding": "Bot: Engado a categoría \"[[:Category:%(newcat)s|%(newcat)s]]\"",
"category-also-in": "(tamén en %(alsocat)s)",
- "category-clean": "Bot: Elimino a categoría %(category)s que xa está en %(child)s",
+ "category-clean": "Bot: Elimino a categoría %(category)s porque xa está dentro de %(child)s",
"category-listifying": "Bot: Listando a partir de %(fromcat)s ({{PLURAL:%(num)d|1 entrada|%(num)d entradas}})",
"category-removing": "Bot: Elimino desde \"%(oldcat)s\"",
"category-renamed": "Bot: Traslado desde \"%(oldcat)s\". Autores: %(authors)s",
diff --git a/pywikibot/gl.json b/pywikibot/gl.json
index 37dcf55..c44a59d 100644
--- a/pywikibot/gl.json
+++ b/pywikibot/gl.json
@@ -7,7 +7,7 @@
]
},
"pywikibot-bot-prefix": "Robot:",
- "pywikibot-cosmetic-changes": "; cambios estética",
+ "pywikibot-cosmetic-changes": "; cambios estéticos",
"pywikibot-enter-category-name": "Insira o nome da categoría:",
"pywikibot-enter-file-links-processing": "As ligazóns a que páxina de ficheiro se deben procesar?",
"pywikibot-enter-finished-browser": "Prema na tecla \"Intro\" cando remate no navegador.",
diff --git a/redirect/gl.json b/redirect/gl.json
index 16b1f7f..13dfeb1 100644
--- a/redirect/gl.json
+++ b/redirect/gl.json
@@ -9,6 +9,6 @@
"redirect-fix-broken-moved": "Arranxo a redirección rota cara á páxina de destino trasladada \"%(to)s\"",
"redirect-fix-double": "Arranxo a redirección dobre cara a \"%(to)s\"",
"redirect-fix-loop": "Arranxo a redirección en bucle cara a \"%(to)s\"",
- "redirect-remove-broken": "Redirección cara a unha páxina eliminada ou en branco",
+ "redirect-remove-broken": "Redirección cara a unha páxina eliminada ou que non existe",
"redirect-remove-loop": "O destino da redirección crea un bucle"
}
diff --git a/replicate_wiki/gl.json b/replicate_wiki/gl.json
new file mode 100644
index 0000000..40997a1
--- /dev/null
+++ b/replicate_wiki/gl.json
@@ -0,0 +1,12 @@
+{
+ "@metadata": {
+ "authors": [
+ "Toliño"
+ ]
+ },
+ "replicate_wiki-headline": "Páxinas que difiren da orixinal",
+ "replicate_wiki-missing-users": "Administradores do orixinal que faltan aquí",
+ "replicate_wiki-same-pages": "Todas as páxinas importantes son iguais",
+ "replicate_wiki-same-users": "Todos os usuarios do orixinal tamén están presentes neste wiki",
+ "replicate_wiki-summary": "Bot: Sincronización wiki desde %(source)s"
+}
diff --git a/replicate_wiki/sr.json b/replicate_wiki/sr.json
index 98a5d14..9c610ec 100644
--- a/replicate_wiki/sr.json
+++ b/replicate_wiki/sr.json
@@ -4,6 +4,9 @@
"Milicevic01"
]
},
+ "replicate_wiki-headline": "Странице које се разликују од оригинала",
+ "replicate_wiki-missing-users": "Админи из оригинала којих нема овде",
"replicate_wiki-same-pages": "Све важне странице су исте",
+ "replicate_wiki-same-users": "Сви корисници из оригинала су такође присутни на овом викију",
"replicate_wiki-summary": "Бот: усклађено са %(source)s."
}
diff --git a/unprotect/gl.json b/unprotect/gl.json
index 986bc4d..e244a89 100644
--- a/unprotect/gl.json
+++ b/unprotect/gl.json
@@ -1,12 +1,13 @@
{
"@metadata": {
"authors": [
- "Elisardojm"
+ "Elisardojm",
+ "Toliño"
]
},
- "unprotect-category": "Bot: desprotección de tódalas páxinas da categoría %(cat)s",
- "unprotect-images": "Bot: desprotección de tódalas imaxes da páxina %(page)s",
- "unprotect-links": "Bot: desprotección de tódalas páxinas ligadas desde %(page)s",
- "unprotect-ref": "Bot: desprotección de tódalas páxinas que ligan cara a %(page)s",
- "unprotect-simple": "Bot: desprotección dunha lista de ficheiros"
+ "unprotect-category": "Bot: Desprotexo tódalas páxinas da categoría %(cat)s",
+ "unprotect-images": "Bot: Desprotexo tódalas imaxes da páxina %(page)s",
+ "unprotect-links": "Bot: Desprotexo tódalas páxinas ligadas desde %(page)s",
+ "unprotect-ref": "Bot: Desprotexo tódalas páxinas que ligan cara a %(page)s",
+ "unprotect-simple": "Bot: Desprotexo unha lista de ficheiros"
}
diff --git a/unusedfiles/gl.json b/unusedfiles/gl.json
index 6867cd9..f41fc2e 100644
--- a/unusedfiles/gl.json
+++ b/unusedfiles/gl.json
@@ -1,8 +1,9 @@
{
"@metadata": {
"authors": [
- "Elisardojm"
+ "Elisardojm",
+ "Toliño"
]
},
- "unusedfiles-comment": "Bot: marcando o ficheiro como orfo"
+ "unusedfiles-comment": "Bot: Marco o ficheiro como orfo"
}
--
To view, visit https://gerrit.wikimedia.org/r/c/pywikibot/i18n/+/940107
To unsubscribe, or for help writing mail filters, visit https://gerrit.wikimedia.org/r/settings
Gerrit-Project: pywikibot/i18n
Gerrit-Branch: master
Gerrit-Change-Id: Ia10f173ee03a8b4638b00a917e15449ef7f25d1f
Gerrit-Change-Number: 940107
Gerrit-PatchSet: 1
Gerrit-Owner: L10n-bot <l10n-bot(a)translatewiki.net>
Gerrit-Reviewer: L10n-bot <l10n-bot(a)translatewiki.net>
Gerrit-Reviewer: jenkins-bot
Gerrit-MessageType: merged